Skip to content
Merged
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
17 changes: 8 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions changelog.d/changed/mcp-notification-before-initialize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- **`rvt-rs-mcp` drops a notification sent before the first request.** With
rmcp 3.12.1, a notification that arrives before `initialize` (or a
`server/discover` probe) no longer ends the connection: the server keeps
waiting for the first request, and a client that sends only a notification
and closes stdin now exits with status 0, as one that closes at once does.
It exited with status 1 before.
4 changes: 2 additions & 2 deletions docs/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ or roots), so it works with a client that offers none of them.
- stdout carries only JSON-RPC. Logs go to stderr (`--log-level`). The server
exits with status 0 when the client closes stdin, whenever that happens: after
a session, after a lone `server/discover` probe (answered before any session
exists) or `initialize`, or before anything was sent. A first message that is
not a request is a failed start and exits 1.
exists) or `initialize`, or before anything was sent. A notification sent
before the first request is dropped (rmcp 3.12.1), so it doesn't change that.

## Handles

Expand Down
32 changes: 27 additions & 5 deletions rvt-mcp/tests/mcp_stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1537,17 +1537,39 @@ fn closing_stdin_at_once_is_a_clean_exit() {
server.finish();
}

/// A first message that is not a request is a real failure to start and keeps
/// its failing status: only a closed connection is treated as leaving.
/// A client that sends only a notification and closes is leaving, as one that
/// closes at once is: rmcp drops the notification (3.12.1, its #1506).
#[test]
fn a_notification_as_the_first_message_is_a_failed_start() {
fn a_notification_then_eof_is_a_clean_exit() {
let mut server = Raw::start(&[]);
server.send(&json!({
"jsonrpc": "2.0", "method": "notifications/initialized"
}));
server.finish();
}

/// rmcp drops a notification that arrives before the first request (rmcp
/// 3.12.1, its #1506), so it neither ends the connection nor stops the
/// `initialize` after it from starting a session.
#[test]
fn a_notification_before_initialize_is_dropped() {
let mut server = Raw::start(&[]);
server.send(&json!({
"jsonrpc": "2.0", "method": "notifications/initialized"
}));
server.send(&json!({
"jsonrpc": "2.0", "id": 1, "method": "initialize",
"params": {
"protocolVersion": "2025-11-25",
"capabilities": {},
"clientInfo": { "name": "rvt-rs-mcp-e2e", "version": "0" }
}
}));
drop(server.stdin.take());
let status = server.wait();
assert!(!status.success(), "exit status {status}");
let reply = server.recv();
assert_eq!(reply["id"], 1, "{reply}");
assert!(reply["result"]["protocolVersion"].is_string(), "{reply}");
server.finish();
}

#[test]
Expand Down
Loading