Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ impl<'de> Deserialize<'de> for Envelope {
fn visit_map<A: MapAccess<'de>>(self, mut map: A) -> Result<Self::Value, A::Error> {
let mut object = serde_json::Map::new();
while let Some(key) = map.next_key::<String>()? {
if matches!(key.as_str(), "jsonrpc" | "id" | "result" | "error")
&& object.contains_key(&key)
if matches!(
key.as_str(),
"jsonrpc" | "id" | "method" | "params" | "result" | "error"
) && object.contains_key(&key)
{
return Err(A::Error::custom("duplicate JSON-RPC envelope field"));
}
// Only reserved envelope fields need uniqueness here.
// Tool results remain opaque JSON, without a local schema.
object.insert(key, map.next_value::<Value>()?);
}
Ok(Envelope(Value::Object(object)))
Expand Down
12 changes: 12 additions & 0 deletions tests/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,18 @@ async fn bounded_frames_serial_backpressure_and_broken_stdout_release_the_actual
-32600,
"jsonrpc",
),
(
b"{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"method\":\"ping\"}\n".to_vec(),
false,
-32600,
"jsonrpc",
),
(
b"{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{},\"params\":{}}\n".to_vec(),
false,
-32600,
"jsonrpc",
),
] {
let fixture = Fixture::start().await;
let mut bridge = Bridge::start(&fixture.origin, ORG);
Expand Down