fix(mcp): answer server-initiated roots/list requests - #62
Open
syf2211 wants to merge 1 commit into
Open
Conversation
The MCP client advertised roots capability during initialize but dropped inbound JSON-RPC requests in _flush and on SSE streams. Handle roots/list with the current workspace as a file:// root and return -32601 for other server methods. Fixes KlaatAI#59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Handle inbound MCP server requests instead of silently dropping them when the message id does not match a pending client call. The client already advertised
rootsduringinitialize; this makes that capability real.Motivation
Servers that trust the advertised
rootscapability callroots/listduring handshake and block until timeout because_flushtreated every inbound id-bearing message as a client response and dropped unmatched ids (#59).Changes
_flushon JSON-RPC requests vs responses and route server requests to a new handler.roots/listwith the current workspace as afile://root viamcpRootsListResult().-32601for other server-initiated methods the client does not implement.roots/list, pending-response resolution, and unknown-method errors.Tests
bun test src/mcp/ bun run typecheck bun run buildAll pass locally (15 MCP tests, typecheck clean, build OK).
Notes
listChanged: falseremains advertised; roots are static for the session (cwd at request time).Fixes #59