Client accepts JSON-RPC response containing both result and error
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia tracciando l'enum JsonRpcMessage senza tag attraverso JsonRpcResponse e il percorso della richiesta call_tool. Riproduci la risposta malformata descritta nell'issue, quindi aggiungi la copertura per una risposta contenente sia result sia error. Il lavoro è completato quando la richiesta in sospeso restituisce un errore invece di Ok(CallToolResult), mantenendo il comportamento della connessione indicato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
The rmcp 3.4.0 client accepts a malformed JSON-RPC response containing both result and error. It resolves the pending tools/call as Ok(CallToolResult), using the result and silently ignoring the error.
JSON-RPC responses must contain either result or error, not both.
Environment
- rmcp: 3.4.0 (
rmcp-v3.4.0, commitfd7811f) - rustc: 1.98.1
- macOS arm64
- Protocol: MCP
2026-07-28 - Transports: stdio and Streamable HTTP
To reproduce
- Connect an rmcp client to an MCP server.
- Send a
tools/callrequest. - Have the server return a response shaped like:
{
"jsonrpc": "2.0",
"id": 1,
"result": { "content": [], "resultType": "complete" },
"error": { "code": -32603, "message": "injected error" }
}
A minimal client call is:
let result = client
.call_tool(
CallToolRequestParams::new("malformed_message")
.with_arguments(
serde_json::json!({"variant": "result-with-error"})
.as_object()
.unwrap()
.clone(),
),
)
.await;
assert!(result.is_err());
This was found while testing MCP Failure Lab 0.9.0. The malformed_message tool intentionally returned a response containing both result and error.
I reproduced it with the mcp-failure-lab@0.9.0 package and the v0.9.0 Git tag over stdio and Streamable HTTP.
Expected behavior
The client rejects the response as an invalid JSON-RPC message and returns an error for the pending request. The connection may remain usable afterward.
Actual behavior
call_tool returns Ok(CallToolResult). A subsequent normal request succeeds.
Additional context
The likely parser path is the untagged JsonRpcMessage enum: JsonRpcResponse accepts the result shape while Serde ignores the unexpected error field.
Other tested official clients, including C# ModelContextProtocol 2.2.0, reject the same wire response.
- Lingua principale
- Rust
- Stelle
- 3.9k
- Fork
- 645
- Merge medio
- 4g 22h
- PR unite (30g)
- 37
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/rust-sdk
-
streamable-http server: a supplied Mcp-Method contradicting an initialize body is silently accepted Apertabug P1 ready for work T-transport
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
modelcontextprotocol/rust-sdk#1271 ·
-
bug P2 ready for work T-model
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
modelcontextprotocol/rust-sdk#1242 ·
-
P3 question T-documentation T-enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
modelcontextprotocol/rust-sdk#1155 ·
-
bug P0 ready for work T-security T-transport
modelcontextprotocol/rust-sdk#1272 · 1 assegnatario ·
-
bug P1 ready for work T-security T-transport
modelcontextprotocol/rust-sdk#1268 · 1 reazione · 1 assegnatario ·
Tutte le issue di modelcontextprotocol/rust-sdk
Issue simili
-
bug github_actions
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
registrystack/registry-stack#1393 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
longbridge/gpui-kit#3223 ·
-
bug engine
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
rocky-data/rocky#2181 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
oasisprotocol/oasis-sdk#2523 ·
-
[indexer] [QA] Add a focused test for the new NonRetryableError / assertSocketAlive() behavior. Apertabot:ai-assisted component:indexer QA-roadmap status:untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
midnightntwrk/midnight-indexer#1557 ·