Skip to content

fix: keep stdio server handling messages after one fails - #1205

Open
prathamgoyal787 wants to merge 1 commit into
modelcontextprotocol:mainfrom
prathamgoyal787:fix/stdio-server-survives-failed-message
Open

prathamgoyal787 wants to merge 1 commit into
modelcontextprotocol:mainfrom
prathamgoyal787:fix/stdio-server-survives-failed-message

Conversation

@prathamgoyal787

Copy link
Copy Markdown

StdioServerTransportProvider sends every inbound message through a single flatMap, so an error from one message ends the whole inbound stream. McpServerSession.handle passes notification-handler errors through with doOnError. One example: a client sends notifications/roots/list_changed, then answers the server's roots/list with an error. After that, the stdio server process stays alive but never answers another request, not even ping.

This change handles errors per message: they're logged and the stream keeps going.

Added shouldKeepHandlingMessagesAfterOneFails to StdioServerTransportProviderTests. It fails on main (the ping after the failing notification is never handled) and passes with this change. All mcp-core tests pass.

StdioServerTransportProvider fed every inbound message through one flatMap, so an error from a single message (for example a failing notification handler) terminated the inbound stream. The server process stayed alive but never answered another request, not even ping. Errors are now handled per message, logged, and the stream keeps going.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant