A request whose `id` is not an i64 or a string is parsed as a notification
Maintainer antworten meist innerhalb von 3 Tagen
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 62/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- rust
- Bereich
- backend-api-design
Rechercherichtung
Start with the JsonRpcMessage untagged enum and NumberOrString parsing in the message model; the issue provides a reproducer using ClientJsonRpcMessage and serde_json::from_str. Check how parsing distinguishes requests from notifications and how invalid ids can be reported as -32600 Invalid Request. Done means the listed id cases no longer silently parse as notifications.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
JsonRpcMessage is #[serde(untagged)]. When id is present but does not deserialize as NumberOrString (i64 or string), the Request variant fails and the message falls through to Notification, which ignores the extra id field. The server then never answers, so the client waits until its own timeout instead of getting -32600 Invalid Request.
To Reproduce (main at 808124b)
let raw = r#"{"jsonrpc":"2.0","id":1.0,"method":"tools/list"}"#;
let msg: rmcp::model::ClientJsonRpcMessage = serde_json::from_str(raw).unwrap();
assert!(matches!(msg, rmcp::model::ClientJsonRpcMessage::Request(_))); // fails: Notification
Same result for 9223372036854775808 (i64::MAX + 1), 1e2, 1.5, true and null. 9223372036854775807 parses as a request.
Expected behavior
A message that carries id and method is a request. If the id is not one the SDK supports, reject it with -32600 rather than treating it as a notification. 1.0 and 1e2 are integral JSON numbers and could reasonably be accepted as 1 and 100.
Additional context
Found by running the same request ids through several SDKs. The Go SDK has a related report in modelcontextprotocol/go-sdk#1376. I checked message parsing only, not a live server.
I'd like to send a fix: decide request vs notification by the presence of id, and report an invalid id as an error.
AI disclosure: found and drafted with Claude Code; I reviewed it and ran the cases above.
- Vorherrschende Sprache
- Rust
- Sterne
- 4k
- Forks
- 662
- Ø Merge
- 3 T. 19 Std.
- Gemergte PRs (30 T.)
- 35
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/rust-sdk
-
Streamable HTTP client: a 401 or 403 with a JSON-RPC error body and no WWW-Authenticate loses its HTTP statusEvtl. vergeben @aton-of-data hat das vor 3 Tagen übernommen. Offenbug P2 ready for work T-security T-transport
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
modelcontextprotocol/rust-sdk#1339 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
auth: refresh_token() requests offline_access that was never granted, so refreshes fail with invalid_scopeEvtl. vergeben @jstar0 hat das vor 5 Tagen übernommen. Offenbug P1 ready for work T-security T-transport
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
modelcontextprotocol/rust-sdk#1330 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
P3 question Stale T-documentation T-enhancement
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 86/100
modelcontextprotocol/rust-sdk#1155 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Clean up sessions after legacy initialize parsing failsEvtl. vergeben @bolinfest hat das heute übernommen. Offenbug P2 ready for work T-transport
modelcontextprotocol/rust-sdk#1357 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Expose body-free HTTP status and Retry-After metadataEvtl. vergeben @bolinfest hat das heute übernommen. Offen
modelcontextprotocol/rust-sdk#1356 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
Alle Issues in modelcontextprotocol/rust-sdk
Ähnliche Issues
-
agent:iq3-xxs area: cli duplication enhancement priority: P3 ready-for-agent
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
bytecodealliance/rustix#1703 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
bug discussion
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
medialab/xan#1201 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
farion1231/cc-switch#8298 ·
Maintainer antworten meist innerhalb von 1 Tag