feat: support SEP-2575 make MCP stateless#3211
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for the MCP stateless protocol version (draft), adding the server/discover method and refactoring JSON-RPC structures to handle per-request metadata like protocol versions and client information. Review feedback highlights several critical issues: JSON field shadowing in request structs that may break unmarshaling, a missing case for the draft version in the method processing loop, and a duplicate error code. Furthermore, the metadata validation logic requires adjustments to maintain backward compatibility with clients not using the new metadata fields and to ensure negotiated protocol versions are not inadvertently overwritten.
cb4b8a9 to
dcf9c44
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements support for the MCP 2026 protocol draft, including metadata validation for protocol versions and client information. It refactors the JSON-RPC request structures to include a standardized _meta object and introduces the server/discover method. Feedback highlights a critical potential nil pointer dereference in the protocol validation logic and a conflict where a new error code duplicates an existing one.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for the Model Context Protocol (MCP) v2026+ by implementing protocol version negotiation, client information validation, and a new server/discover method. It also refactors JSON-RPC message structures to support per-request metadata and adds a standard error for unsupported protocol versions. Feedback includes a critical fix for a colliding error code, the removal of a redundant string check, and suggestions to eliminate code duplication by utilizing shared types from the jsonrpc package.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements support for the MCP 2026 draft protocol, introducing the server/discover method and per-request metadata validation for protocol versions, client info, and capabilities. It refactors JSON-RPC structures to support the _meta field and updates error handling for protocol mismatches. Feedback identifies opportunities to improve HTTP status code mapping for JSON-RPC errors, remove a redundant protocol version check, and correct a header name in an error message.
18fb620 to
a60ede4
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for the MCP draft protocol version, replacing the initialization and ping methods with a new server discovery mechanism. It refactors JSON-RPC request and error structures to support per-request metadata validation, including protocol version and client capabilities. Feedback suggests optimizing performance by avoiding redundant JSON unmarshaling in the draft method processor and improving error handling by replacing fragile string-based checks with structured error codes.
c004bf7 to
1bbcc67
Compare
| case TOOLS_LIST: | ||
| return toolsListHandler(id, resourceMgr, toolset, body) | ||
| return toolsListHandler(id, resourceMgr, toolset, body, stdio) | ||
| case TOOLS_CALL: |
There was a problem hiding this comment.
Does toolCallHandler need the stdio boolean too? Will this error if header is nil accessToken := tools.AccessToken(header.Get(authTokenHeadername))?
Support SEP-2575
This PR also updates our custom auth error code since it contradicts with some new errors added in this SEP.:
For stdio transport:
_meta.io.modelcontextprotocol/protocolVersionwas provided, it will use the protocol version specified (take precedence over existing version).v2024-11-05similar to Toolbox's HTTP transport. Toolbox had a custom transport on v2024-11-05 --> "regular" HTTP POST (without SSE), that does not enforce the initialize methodFor HTTP transport:
_meta.io.modelcontextprotocol/protocolVersionto validate.