From cda4f631a36a4414f59fc67f1e5e9de055e4ffe4 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 1 Dec 2026 13:10:29 +0100 Subject: [PATCH] fix(supervisor-network): answer MCP L7 refusals in-protocol instead of HTTP 403 MCP clients read an HTTP 401 or 403 as an authorization challenge and cache the server as needing sign-in. A refused JSON-RPC request on an mcp endpoint now gets a JSON-RPC error on HTTP 200 (-32600 with supportedVersions for a revision refusal, -32601 for a method refusal), and a refused notification gets an empty HTTP 202. The OCSF deny event is unchanged. Non-POST and non-JSON bodies keep the HTTP deny response. Closes #6048 Signed-off-by: Evan Lezar --- .../src/l7/mcp.rs | 61 ++++ .../src/l7/relay.rs | 314 ++++++++++++++++-- .../l7/relay/correlation_dispatch_tests.rs | 7 +- .../l7/relay/token_grant_ownership_tests.rs | 4 +- .../src/l7/rest.rs | 35 +- docs/how-it-works/policies/schema.mdx | 6 +- 6 files changed, 382 insertions(+), 45 deletions(-) diff --git a/crates/openshell-supervisor-network/src/l7/mcp.rs b/crates/openshell-supervisor-network/src/l7/mcp.rs index 26538c9467..7021c07d3f 100644 --- a/crates/openshell-supervisor-network/src/l7/mcp.rs +++ b/crates/openshell-supervisor-network/src/l7/mcp.rs @@ -103,6 +103,67 @@ impl std::fmt::Display for McpProtocolVersionError { impl std::error::Error for McpProtocolVersionError {} +/// JSON-RPC error code for a request the endpoint refuses by revision. +pub(super) const JSONRPC_INVALID_REQUEST: i64 = -32600; +/// JSON-RPC error code for a request the endpoint refuses by method. +pub(super) const JSONRPC_METHOD_NOT_FOUND: i64 = -32601; + +/// How a policy refusal of an MCP JSON-RPC message is answered on the wire. +/// +/// An HTTP 401 or 403 reads as an authorization challenge to MCP clients, so +/// a refusal travels as a JSON-RPC error (HTTP 200) for requests and as an +/// HTTP 202 acknowledgement for notifications, which have no response. +#[derive(Debug, Clone, PartialEq)] +pub(super) enum McpRefusalAnswer { + /// JSON-RPC error response (one object, or an array for a batch). + Error(serde_json::Value), + /// The message carried only notifications: acknowledge without a body. + Accepted, +} + +/// Build the answer for a refused MCP message, or `None` when the body is not +/// a JSON-RPC message (the caller keeps its HTTP answer). +pub(super) fn refusal_answer( + request: &L7Request, + code: i64, + message: &str, + data: Option<&serde_json::Value>, +) -> Option { + // Only a POST carries an MCP message; any other method keeps its HTTP answer. + if request.action != "POST" { + return None; + } + let header_end = request + .raw_header + .windows(4) + .position(|window| window == b"\r\n\r\n")? + + 4; + let body: serde_json::Value = serde_json::from_slice(&request.raw_header[header_end..]).ok()?; + let error_for = |message_value: &serde_json::Value| -> Option { + message_value.get("method")?; + let id = message_value.get("id")?; + let mut error = serde_json::json!({ "code": code, "message": message }); + if let Some(data) = data { + error["data"] = data.clone(); + } + Some(serde_json::json!({ "jsonrpc": "2.0", "id": id, "error": error })) + }; + match &body { + serde_json::Value::Object(_) => { + Some(error_for(&body).map_or(McpRefusalAnswer::Accepted, McpRefusalAnswer::Error)) + } + serde_json::Value::Array(items) if !items.is_empty() => { + let errors: Vec<_> = items.iter().filter_map(error_for).collect(); + Some(if errors.is_empty() { + McpRefusalAnswer::Accepted + } else { + McpRefusalAnswer::Error(serde_json::Value::Array(errors)) + }) + } + _ => None, + } +} + /// Describe how the request selected its MCP revision. /// /// Initial and post-middleware inspection supply their current request so the diff --git a/crates/openshell-supervisor-network/src/l7/relay.rs b/crates/openshell-supervisor-network/src/l7/relay.rs index 4512dce4cb..b59054da91 100644 --- a/crates/openshell-supervisor-network/src/l7/relay.rs +++ b/crates/openshell-supervisor-network/src/l7/relay.rs @@ -442,6 +442,7 @@ where if let Err(error) = crate::l7::mcp::validate_request_metadata(request, &info) { reject_mcp_protocol_version( error, + &config.mcp_versions, request, &info, client, @@ -459,6 +460,7 @@ where Err(error) => { reject_mcp_protocol_version( error, + &config.mcp_versions, request, &info, client, @@ -473,10 +475,77 @@ where } } +/// Deliver a refusal of an MCP JSON-RPC message in-protocol: a JSON-RPC error +/// on HTTP 200 for requests, an empty HTTP 202 for notifications. +async fn send_mcp_refusal( + answer: crate::l7::mcp::McpRefusalAnswer, + client: &mut W, + ctx: &L7EvalContext, + correlation: Option<&RequestCorrelation>, +) -> Result<()> +where + W: AsyncWrite + Unpin, +{ + let request_id = correlation.map(RequestCorrelation::request_id); + match answer { + crate::l7::mcp::McpRefusalAnswer::Error(body) => { + let status = "200 OK"; + if let Some(request_id) = request_id { + crate::l7::rest::send_json_response_with_request_id( + &ctx.policy_name, + body, + client, + status, + request_id, + ) + .await + } else { + crate::l7::rest::send_json_response(&ctx.policy_name, body, client, status).await + } + } + crate::l7::mcp::McpRefusalAnswer::Accepted => { + crate::l7::rest::send_accepted_response(&ctx.policy_name, client, request_id).await + } + } +} + +/// Answer an L7 policy refusal on an `mcp` endpoint in-protocol. Returns +/// `false` when the request is not a JSON-RPC POST, so the caller keeps its +/// HTTP deny response. +async fn send_mcp_policy_refusal( + config: &L7EndpointConfig, + req: &crate::l7::provider::L7Request, + reason: &str, + client: &mut W, + ctx: &L7EvalContext, + correlation: &RequestCorrelation, +) -> Result +where + W: AsyncWrite + Unpin, +{ + if config.protocol != L7Protocol::Mcp { + return Ok(false); + } + let Some(answer) = + crate::l7::mcp::refusal_answer(req, crate::l7::mcp::JSONRPC_METHOD_NOT_FOUND, reason, None) + else { + return Ok(false); + }; + // A 401/403 reads as an authorization challenge to MCP clients. + correlation.record_response_status(match answer { + crate::l7::mcp::McpRefusalAnswer::Accepted => 202, + crate::l7::mcp::McpRefusalAnswer::Error(_) => 200, + }); + correlation.record_outcome(HttpOutcome::Denied); + send_mcp_refusal(answer, client, ctx, Some(correlation)).await?; + Ok(true) +} + /// Emit the same transport or policy rejection at initial and final inspection. #[allow(clippy::too_many_arguments)] async fn reject_mcp_protocol_version( error: crate::l7::mcp::McpProtocolVersionError, + supported_versions: &[openshell_core::mcp::McpProtocolVersion], request: &crate::l7::provider::L7Request, info: &crate::l7::jsonrpc::JsonRpcRequestInfo, client: &mut W, @@ -494,6 +563,20 @@ where observer.observe(EndpointResult::PolicyDenied); } let reason = error.rejection_detail(request); + // A 401/403 reads as an authorization challenge to MCP clients, so a + // revision refusal of a JSON-RPC message is answered in-protocol. + let mcp_refusal_answer = match error { + crate::l7::mcp::McpProtocolVersionError::NotAllowed(_) => { + let supported: Vec<&str> = supported_versions.iter().map(|v| v.as_str()).collect(); + crate::l7::mcp::refusal_answer( + request, + crate::l7::mcp::JSONRPC_INVALID_REQUEST, + &reason, + Some(&serde_json::json!({ "supportedVersions": supported })), + ) + } + _ => None, + }; let summary = l7_protocol_log_summary(None, Some(info)); let event = build_l7_request_event( ctx, @@ -510,7 +593,13 @@ where | crate::l7::mcp::McpProtocolVersionError::UnsupportedHeaderValue | crate::l7::mcp::McpProtocolVersionError::InvalidRequestMetadata => 400, crate::l7::mcp::McpProtocolVersionError::MethodNotAllowed => 405, - crate::l7::mcp::McpProtocolVersionError::NotAllowed(_) => 403, + crate::l7::mcp::McpProtocolVersionError::NotAllowed(_) => { + match mcp_refusal_answer.as_ref() { + Some(crate::l7::mcp::McpRefusalAnswer::Accepted) => 202, + Some(crate::l7::mcp::McpRefusalAnswer::Error(_)) => 200, + None => 403, + } + } }; correlation.record_rejection(status, HttpOutcome::Denied, None); correlation.emit(event); @@ -525,6 +614,9 @@ where | crate::l7::mcp::McpProtocolVersionError::MethodNotAllowed => "l7_parse_rejection", }; emit_activity(ctx, true, deny_group); + if let Some(answer) = mcp_refusal_answer { + return send_mcp_refusal(answer, client, ctx, correlation).await; + } let body = serde_json::json!({ "error": error.response_code(), "detail": reason, @@ -2244,6 +2336,12 @@ where if let Some(observer) = observer.as_ref() { observer.observe(EndpointResult::PolicyDenied); } + if send_mcp_policy_refusal(config, &req, &reason, client, ctx, &correlation) + .await + .map_err(&capture_error)? + { + return Ok(()); + } { correlation.record_response_status(403); correlation.record_outcome(HttpOutcome::Denied); @@ -3579,8 +3677,12 @@ where if let Some(observer) = observer.as_ref() { observer.observe(EndpointResult::PolicyDenied); } - correlation.record_response_status(403); - correlation.record_outcome(HttpOutcome::Denied); + if send_mcp_policy_refusal(config, &req, &reason, client, ctx, &correlation) + .await + .map_err(&capture_error)? + { + return Ok(()); + } crate::l7::rest::RestProvider::default() .deny_with_redacted_target( &req, @@ -12275,7 +12377,12 @@ network_policies: } else { r#"{"jsonrpc":"2.0","id":2,"method":"status.set"}"# }, - "403 Forbidden", + // An `mcp` refusal is a JSON-RPC error, checked below. + if protocol == "mcp" { + "200 OK" + } else { + "403 Forbidden" + }, ), ("/public", "{}", "200 OK"), ] { @@ -12362,6 +12469,13 @@ network_policies: "{protocol} {path}: {}", String::from_utf8_lossy(&response) ); + if protocol == "mcp" && path == "/services/catalog" { + assert!( + String::from_utf8_lossy(&response).contains("-32601"), + "mcp refusal must be a JSON-RPC error: {}", + String::from_utf8_lossy(&response) + ); + } drop(app); tokio::time::timeout(std::time::Duration::from_secs(5), relay) .await @@ -12371,7 +12485,7 @@ network_policies: let received = server.await.unwrap(); assert_eq!( received.is_empty(), - expected == "403 Forbidden", + path == "/services/catalog", "{protocol} {path}: denied calls must not reach upstream" ); } @@ -13813,7 +13927,7 @@ network_policies: "{response}" ); assert_eq!( - response.contains("403 Forbidden"), + response.contains("403 Forbidden") || response.contains("\"error\""), !second_allowed, "{response}" ); @@ -15355,7 +15469,8 @@ network_policies: } else if should_forward { "204 No Content" } else { - "403 Forbidden" + // MCP refusals are JSON-RPC errors, not HTTP 403. + "200 OK" }; assert!( response.starts_with(&format!("HTTP/1.1 {status}")), @@ -15460,14 +15575,14 @@ network_policies: serde_json::json!({"name":"blocked"}), "tools/call", Some("blocked"), - "403 Forbidden", + "200 OK", ), ( "vendor/unlisted", serde_json::json!({}), "vendor/unlisted", None, - "403 Forbidden", + "200 OK", ), ] { let mut headers = @@ -15675,21 +15790,21 @@ network_policies: ), ( "MCP-Protocol-Version: 2025-06-18\r\n", - "403 Forbidden", - "mcp_protocol_version_not_allowed", + "200 OK", + "-32600", "selected MCP revision 2025-06-18 from MCP-Protocol-Version", ), ( "", - "403 Forbidden", - "mcp_protocol_version_not_allowed", + "200 OK", + "-32600", "missing MCP-Protocol-Version header fallback; send the client/server revision explicitly", ), ] { let (response, forwarded) = run_rejected_mcp_request( false, headers, - br#"{"jsonrpc":"2.0","id":7,"result":{"ok":true}}"#, + br#"{"jsonrpc":"2.0","id":7,"method":"tools/list"}"#, ) .await; assert!( @@ -15723,7 +15838,7 @@ network_policies: } const MCP_VERSION_DENIALS: &[(&str, &str, &str)] = &[ - ("", "403 Forbidden", "mcp_protocol_version_not_allowed"), + ("", "200 OK", "-32600"), ( "MCP-Protocol-Version: \r\n", "400 Bad Request", @@ -15739,16 +15854,8 @@ network_policies: "400 Bad Request", "unsupported_mcp_protocol_version", ), - ( - "MCP-Protocol-Version: 2026-07-28\r\n", - "403 Forbidden", - "mcp_protocol_version_not_allowed", - ), - ( - "MCP-Protocol-Version: 2025-06-18\r\n", - "403 Forbidden", - "mcp_protocol_version_not_allowed", - ), + ("MCP-Protocol-Version: 2026-07-28\r\n", "200 OK", "-32600"), + ("MCP-Protocol-Version: 2025-06-18\r\n", "200 OK", "-32600"), ]; #[tokio::test] @@ -15876,7 +15983,7 @@ network_policies: let mut receiver = install_mcp_test_observation(&mut config, &mut ctx).await; let (mut app, mut client) = tokio::io::duplex(8192); let (mut upstream, mut server) = tokio::io::duplex(8192); - let body = br#"{"jsonrpc":"2.0","id":7,"result":{"ok":true}}"#; + let body = br#"{"jsonrpc":"2.0","id":7,"method":"tools/list"}"#; let request = format!( "POST /mcp HTTP/1.1\r\nHost: mcp.example.test:8000\r\nContent-Type: application/json\r\n{version_headers}Content-Length: {}\r\nConnection: close\r\n\r\n", body.len() @@ -16263,20 +16370,165 @@ network_policies: let mut response = Vec::new(); client.read_to_end(&mut response).await.unwrap(); let response = String::from_utf8(response).expect("UTF-8 response"); - assert!(response.starts_with("HTTP/1.1 403 Forbidden"), "{response}"); - assert!( - response.contains("mcp_protocol_version_not_allowed"), - "{response}" - ); + assert!(response.starts_with("HTTP/1.1 200 OK"), "{response}"); assert!( response.contains(&format!("x-openshell-request-id: {REQUEST_ID}\r\n")), "{response}" ); let response_body: serde_json::Value = serde_json::from_str(response.split_once("\r\n\r\n").unwrap().1).unwrap(); + assert_eq!(response_body["id"], 2); + assert_eq!(response_body["error"]["code"], -32600); assert!(response_body.get("request_id").is_none()); } + /// Send one POST through the `mcp` relay and return the raw response plus + /// the OCSF event messages emitted for it. + async fn mcp_refusal_exchange(protocol_version: &str, body: &str) -> (String, Vec) { + let (config, engine, ctx) = mcp_test_relay_context(); + let capture = openshell_ocsf::test_support::OcsfCapture::default(); + let _guard = capture.install(); + let (mut app, mut relay_client) = tokio::io::duplex(8192); + let (mut relay_upstream, mut upstream) = tokio::io::duplex(8192); + let relay = tokio::spawn(async move { + relay_jsonrpc( + &config, + &engine, + &mut relay_client, + &mut relay_upstream, + &ctx, + ) + .await + }); + let request = format!( + "POST /mcp HTTP/1.1\r\nHost: mcp.example.test:8000\r\nContent-Type: application/json\r\nMCP-Protocol-Version: {protocol_version}\r\nContent-Length: {}\r\n\r\n{body}", + body.len() + ); + app.write_all(request.as_bytes()).await.unwrap(); + let mut response = Vec::new(); + tokio::time::timeout( + std::time::Duration::from_secs(2), + app.read_to_end(&mut response), + ) + .await + .expect("refusal should reach the client") + .unwrap(); + relay.await.unwrap().unwrap(); + let mut forwarded = Vec::new(); + drop(app); + upstream.read_to_end(&mut forwarded).await.unwrap(); + assert!( + forwarded.is_empty(), + "a refused message must not reach upstream" + ); + let messages = capture + .json_events() + .iter() + .filter_map(|event| event["message"].as_str().map(str::to_owned)) + .collect(); + (String::from_utf8(response).unwrap(), messages) + } + + fn assert_not_an_authorization_challenge(response: &str) { + assert!( + response.starts_with("HTTP/1.1 200 OK") + || response.starts_with("HTTP/1.1 202 Accepted"), + "{response}" + ); + assert!(!response.contains("policy_denied"), "{response}"); + } + + #[tokio::test] + async fn mcp_revision_refusal_of_a_request_is_a_jsonrpc_error() { + let (response, messages) = mcp_refusal_exchange( + "2026-07-28", + r#"{"jsonrpc":"2.0","id":7,"method":"server/discover"}"#, + ) + .await; + assert_not_an_authorization_challenge(&response); + assert!(response.starts_with("HTTP/1.1 200 OK"), "{response}"); + let body: serde_json::Value = + serde_json::from_str(response.split_once("\r\n\r\n").unwrap().1).unwrap(); + assert_eq!(body["jsonrpc"], "2.0"); + assert_eq!(body["id"], 7); + assert_eq!(body["error"]["code"], -32600); + assert_eq!( + body["error"]["data"]["supportedVersions"], + serde_json::json!(["2025-11-25"]) + ); + assert!( + messages + .iter() + .any(|message| message.starts_with("L7_REQUEST deny POST") + && message.contains( + "reason=MCP protocol version 2026-07-28 is not allowed by endpoint policy" + )), + "{messages:?}" + ); + } + + #[tokio::test] + async fn mcp_revision_refusal_of_a_notification_is_accepted_without_a_body() { + let (response, messages) = mcp_refusal_exchange( + "2026-07-28", + r#"{"jsonrpc":"2.0","method":"notifications/initialized"}"#, + ) + .await; + assert_not_an_authorization_challenge(&response); + assert!(response.starts_with("HTTP/1.1 202 Accepted"), "{response}"); + assert!( + response.to_ascii_lowercase().contains("content-length: 0"), + "{response}" + ); + assert!(response.ends_with("\r\n\r\n"), "{response}"); + assert!( + messages + .iter() + .any(|message| message.starts_with("L7_REQUEST deny POST") + && message.contains("is not allowed by endpoint policy")), + "{messages:?}" + ); + } + + #[tokio::test] + async fn mcp_method_refusal_of_a_request_is_a_jsonrpc_error() { + let (response, messages) = mcp_refusal_exchange( + "2025-11-25", + r#"{"jsonrpc":"2.0","id":"abc","method":"tools/list"}"#, + ) + .await; + assert_not_an_authorization_challenge(&response); + assert!(response.starts_with("HTTP/1.1 200 OK"), "{response}"); + let body: serde_json::Value = + serde_json::from_str(response.split_once("\r\n\r\n").unwrap().1).unwrap(); + assert_eq!(body["id"], "abc"); + assert_eq!(body["error"]["code"], -32601); + assert!( + messages.iter().any( + |message| message.starts_with("JSONRPC_L7_REQUEST decision=deny") + && message.contains("reason=MCP core method is not permitted by policy") + ), + "{messages:?}" + ); + } + + #[tokio::test] + async fn mcp_method_refusal_of_a_notification_is_accepted_without_a_body() { + let (response, messages) = mcp_refusal_exchange( + "2025-11-25", + r#"{"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":1}}"#, + ) + .await; + assert_not_an_authorization_challenge(&response); + assert!(response.starts_with("HTTP/1.1 202 Accepted"), "{response}"); + assert!( + messages + .iter() + .any(|message| message.starts_with("JSONRPC_L7_REQUEST decision=deny")), + "{messages:?}" + ); + } + #[tokio::test] async fn mcp_relay_forwards_jsonrpc_response_frame() { let (config, tunnel_engine, ctx) = mcp_test_relay_context(); diff --git a/crates/openshell-supervisor-network/src/l7/relay/correlation_dispatch_tests.rs b/crates/openshell-supervisor-network/src/l7/relay/correlation_dispatch_tests.rs index 6526a42b13..0fd9c657f2 100644 --- a/crates/openshell-supervisor-network/src/l7/relay/correlation_dispatch_tests.rs +++ b/crates/openshell-supervisor-network/src/l7/relay/correlation_dispatch_tests.rs @@ -1230,12 +1230,7 @@ async fn production_single_mcp_policy_deny_correlates_record_and_receipt() { .await; assert!(exchange.output.forwarded.is_empty()); - assert!( - exchange - .output - .response - .starts_with(b"HTTP/1.1 403 Forbidden\r\n") - ); + assert!(exchange.output.response.starts_with(b"HTTP/1.1 200 OK\r\n")); let event = assert_policy_record(&exchange, "l7-mcp", "Denied", "/mcp"); assert!( event["message"] diff --git a/crates/openshell-supervisor-network/src/l7/relay/token_grant_ownership_tests.rs b/crates/openshell-supervisor-network/src/l7/relay/token_grant_ownership_tests.rs index 4357309eb8..5b13395a56 100644 --- a/crates/openshell-supervisor-network/src/l7/relay/token_grant_ownership_tests.rs +++ b/crates/openshell-supervisor-network/src/l7/relay/token_grant_ownership_tests.rs @@ -630,8 +630,10 @@ async fn native_protocol_denials_do_not_resolve_grants_or_forward_bytes() { .exchange_body("/native", &native_protocol_body(protocol, "blocked")) .await; let capture = connection.finish().await; + // MCP refusals are JSON-RPC errors on HTTP 200, not an HTTP 403. + let status = if protocol == "mcp" { "200" } else { "403" }; assert!( - response.starts_with("HTTP/1.1 403"), + response.starts_with(&format!("HTTP/1.1 {status}")), "{protocol}: {response}" ); fixture.resolver.assert_calls(&[]); diff --git a/crates/openshell-supervisor-network/src/l7/rest.rs b/crates/openshell-supervisor-network/src/l7/rest.rs index af73e7bdc5..892db1cf62 100644 --- a/crates/openshell-supervisor-network/src/l7/rest.rs +++ b/crates/openshell-supervisor-network/src/l7/rest.rs @@ -3547,6 +3547,34 @@ pub(crate) async fn send_json_response_with_request_id( .await } +/// Acknowledge a JSON-RPC notification with an empty `202 Accepted`. +pub(crate) async fn send_accepted_response( + policy_name: &str, + client: &mut C, + request_id: Option<&str>, +) -> Result<()> { + let request_id = request_id.map_or_else(String::new, |request_id| { + format!( + "{}: {request_id}\r\n", + openshell_core::token_grant_failure::REQUEST_ID_HEADER + ) + }); + let response = format!( + "HTTP/1.1 202 Accepted\r\n\ + Content-Length: 0\r\n\ + X-OpenShell-Policy: {policy_name}\r\n\ + {request_id}\ + Connection: close\r\n\ + \r\n" + ); + client + .write_all(response.as_bytes()) + .await + .into_diagnostic()?; + client.flush().await.into_diagnostic()?; + Ok(()) +} + async fn send_json_response_internal( policy_name: &str, body: serde_json::Value, @@ -7070,11 +7098,8 @@ mod tests { if let Some(mut peer) = peer { let mut response = String::new(); peer.read_to_string(&mut response).await.unwrap(); - assert!(response.starts_with("HTTP/1.1 403 Forbidden"), "{response}"); - assert!( - response.contains("mcp_protocol_version_not_allowed"), - "{response}" - ); + assert!(response.starts_with("HTTP/1.1 200 OK"), "{response}"); + assert!(response.contains("-32600"), "{response}"); } } } diff --git a/docs/how-it-works/policies/schema.mdx b/docs/how-it-works/policies/schema.mdx index bb87555ab0..b8c42c96e6 100644 --- a/docs/how-it-works/policies/schema.mdx +++ b/docs/how-it-works/policies/schema.mdx @@ -462,11 +462,13 @@ allow its traffic without MCP inspection. Use the response's error code and detail to distinguish a protocol problem from a policy denial: +OpenShell answers a policy refusal of an MCP JSON-RPC message in-protocol, because MCP clients read an HTTP `401` or `403` as a request for authorization. A refused request gets HTTP `200` with a JSON-RPC error that echoes its `id`: code `-32600` with `data.supportedVersions` for a revision that `mcp.versions` excludes, or `-32601` for a denied method or tool call. A refused notification gets an empty HTTP `202`. The sandbox log records the denial either way. + - `unsupported_mcp_protocol_version` (`400`) means this OpenShell build does not support the header's revision. Configure the client to use a revision that OpenShell and the server support and that `mcp.versions` permits. -- `mcp_protocol_version_not_allowed` (`403`) means the selected revision is supported but excluded by the endpoint policy. Use a compatible revision the policy permits, or ask the policy owner to review `mcp.versions`. +- `mcp_protocol_version_not_allowed` (JSON-RPC error `-32600`) means the selected revision is supported but excluded by the endpoint policy. Use a compatible revision the policy permits, or ask the policy owner to review `mcp.versions`. - A detail that names the missing-header fallback means OpenShell selected `2025-03-26`, even if the policy defaults to `2025-11-25`. Send the client/server revision explicitly in `MCP-Protocol-Version`; the policy must permit it. - `invalid_mcp_request` (`400`) can mean the method is unavailable in the selected revision. For example, `tasks/get` is unavailable in `2025-06-18`. Use a method available in that revision, or configure the client and server to use a compatible revision that includes it and is permitted by policy. Adding an allow rule or enabling `allow_all_known_mcp_methods` cannot override this protocol check. -- A rule denial (`403` under `enforcement: enforce`) requires a policy review. An extension method needs an exact method allow rule; a denied tool call may need a matching tool selector. An explicit deny rule takes precedence, so adding an allow rule cannot override it. Ask the policy owner to review the relevant allow or deny rule. +- A rule denial (JSON-RPC error `-32601` under `enforcement: enforce`) requires a policy review. An extension method needs an exact method allow rule; a denied tool call may need a matching tool selector. An explicit deny rule takes precedence, so adding an allow rule cannot override it. Ask the policy owner to review the relevant allow or deny rule. #### Sessionless MCP Requests