Skip to content
Merged
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
42 changes: 41 additions & 1 deletion crates/rmcp/src/transport/async_rw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,22 +249,25 @@ const UTF8_BOM: &[u8; 3] = b"\xEF\xBB\xBF";
/// Check if a method is a standard MCP method (request, response, or notification).
/// This includes both requests and notifications defined in the MCP specification.
///
/// Based on MCP specification 2025-06-18: https://modelcontextprotocol.io/specification/2025-06-18
/// Based on MCP specification 2026-07-28: https://modelcontextprotocol.io/specification/2026-07-28
fn is_standard_method(method: &str) -> bool {
matches!(
method,
"initialize"
| "ping"
| "server/discover"
| "prompts/get"
| "prompts/list"
| "resources/list"
| "resources/read"
| "resources/subscribe"
| "resources/unsubscribe"
| "resources/templates/list"
| "subscriptions/listen"
| "tools/call"
| "tools/list"
| "completion/complete"
| "elicitation/create"
| "logging/setLevel"
| "roots/list"
| "sampling/createMessage"
Expand All @@ -282,6 +285,7 @@ fn is_standard_notification(method: &str) -> bool {
| "notifications/resources/list_changed"
| "notifications/resources/updated"
| "notifications/roots/list_changed"
| "notifications/subscriptions/acknowledged"
| "notifications/tools/list_changed"
)
}
Expand Down Expand Up @@ -582,6 +586,9 @@ mod test {
assert!(is_standard_notification("notifications/tools/list_changed"));
assert!(is_standard_notification("notifications/message"));
assert!(is_standard_notification("notifications/roots/list_changed"));
assert!(is_standard_notification(
"notifications/subscriptions/acknowledged"
));

// Test that non-standard notifications are not recognized
assert!(!is_standard_notification("notifications/stderr"));
Expand All @@ -590,6 +597,39 @@ mod test {
assert!(!is_standard_notification("some/other/method"));
}

#[test]
fn test_2026_07_28_standard_method_check() {
for method in [
"elicitation/create",
"server/discover",
"subscriptions/listen",
] {
assert!(is_standard_method(method), "{method} should be standard");
}
}

#[test]
fn test_current_standard_notification_is_not_ignored() {
let method = "notifications/subscriptions/acknowledged";
let notification = serde_json::json!({
"jsonrpc": "2.0",
"method": method,
});

assert!(!should_ignore_notification(&notification, method));
}

#[test]
fn test_unknown_notification_is_ignored() {
let method = "notifications/custom";
let notification = serde_json::json!({
"jsonrpc": "2.0",
"method": method,
});

assert!(should_ignore_notification(&notification, method));
}

#[test]
fn test_compatibility_function() {
// Test the compatibility function directly
Expand Down