fix(streamable_http): include MCP method in client JSON-RPC error messages - #912
fix(streamable_http): include MCP method in client JSON-RPC error messages#912syf2211 wants to merge 1 commit into
Conversation
…sages Track the originating MCP method on pending streamable-HTTP client requests (sampling/createMessage, elicitation/create, roots/list) and use it when wrapping JSON-RPC errors returned by the client. Fixes mark3labs#817
|
Connected to Huly®: MCP_G-476 |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAdds a Method-aware sampling error plumbing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing as duplicate of #822, which already addresses the same issue with a similar approach. Thanks! |
Summary
Include the originating MCP method name when wrapping JSON-RPC errors returned by the client over streamable HTTP transport.
Motivation
handleSamplingResponseis shared bysampling/createMessage,elicitation/create, androots/list, but previously hardcoded all client-side JSON-RPC errors assampling error %d: %s. This made it impossible to distinguish elicitation failures from sampling failures without fragile string matching.Fixes #817
Changes
pendingClientRequestto track both the response channel and MCP method for pending client requests<method> error <code>: <message>(e.g.elicitation/create error -32601: Method not found)TestStreamableHTTPServer_ClientRequestErrorIncludesMethodTests
All tests passed.
Notes
sampling/createMessage error ...instead ofsampling error ...for accuracy. Error strings are not a stable API; callers should inspecterrorvalues rather than parse message text.stdiotransport error messages are unchanged (out of scope for this issue).Summary by CodeRabbit