MCP: dispatch incoming requests and notifications through SDK envelopes
CI / UI Checks (pull_request) Successful in 14s
CI / Rust Checks (pull_request) Successful in 35m55s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
CI / UI Checks (pull_request) Successful in 14s
CI / Rust Checks (pull_request) Successful in 35m55s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
This commit is contained in:
1 parent
156a849087
commit
0de1e94df4
8 files changed
+662
-33
No files matched your search
@@ -12,10 +12,7 @@ use super::rmcp_dispatch::{
|
||||
};
|
||||
use crate::{
|
||||
auth::VerifiedMachineCredential,
|
||||
jsonrpc::{
|
||||
is_notification, jsonrpc_error, jsonrpc_result, method_name, negotiated_protocol_version,
|
||||
params, request_id,
|
||||
},
|
||||
jsonrpc::{jsonrpc_error, jsonrpc_result, negotiated_protocol_version, params, request_id},
|
||||
protocol::{
|
||||
CompletionCommand, CompletionOutcome, ContinuationSupport, DispatchDecision, MethodHandler,
|
||||
PromptGetCommand, PromptsCommand, PromptsListCommand, PromptsOutcome, RequestIdentity,
|
||||
@@ -81,7 +78,20 @@ pub(super) async fn handle_modern_request(
|
||||
// matrix row 18). The envelope, identity and mixed-carrier checks — and authentication — have
|
||||
// already run at this point, so this early return cannot admit a malformed identity or a session
|
||||
// conflict, and the notification is never dispatched.
|
||||
if is_notification(message) {
|
||||
let envelope = match crate::protocol::decode_dispatch_envelope(message) {
|
||||
Ok(Some(envelope)) => envelope,
|
||||
_ => {
|
||||
return internal_jsonrpc_error(
|
||||
message,
|
||||
"admitted dispatch envelope could not be decoded",
|
||||
);
|
||||
}
|
||||
};
|
||||
let method = envelope.method();
|
||||
let notification = envelope.is_notification();
|
||||
#[cfg(test)]
|
||||
super::dispatch_observer::sdk_dispatch_envelope_consumed();
|
||||
if notification {
|
||||
return crate::protocol::modern_notification_response();
|
||||
}
|
||||
|
||||
@@ -89,15 +99,14 @@ pub(super) async fn handle_modern_request(
|
||||
Ok(declared_method) => declared_method,
|
||||
Err(response) => return *response,
|
||||
};
|
||||
if declared_method != method_name(message) {
|
||||
if declared_method != method {
|
||||
return crate::protocol::modern_header_mismatch_response(message);
|
||||
}
|
||||
|
||||
// R5/F5: the same registration-backed dispatch as the legacy adapter. The handler is decided by
|
||||
// the owning registration (not by a literal method list inside this adapter), and a method whose
|
||||
// capability is not eligible in this revision is never served here.
|
||||
let dispatch =
|
||||
crate::protocol::dispatch_decision(method_name(message).unwrap_or_default(), version);
|
||||
let dispatch = crate::protocol::dispatch_decision(method.unwrap_or_default(), version);
|
||||
match dispatch {
|
||||
DispatchDecision::Allowed {
|
||||
handler: MethodHandler::Discover,
|
||||
@@ -121,7 +130,7 @@ pub(super) async fn handle_modern_request(
|
||||
request_id(message),
|
||||
crate::protocol::project_modern_result(
|
||||
version,
|
||||
crate::protocol::ping_result(message, version),
|
||||
crate::protocol::ping_result(&json!({"method": "ping"}), version),
|
||||
),
|
||||
),
|
||||
response_mode,
|
||||
|
||||
Reference in new issue
Block a user