Describe the bug
When an initialize request has a valid JSON-RPC envelope and a recognized method name, but is missing required fields such as params.protocolVersion, the Kotlin SDK appears to return different JSON-RPC error codes depending on the transport:
- stdio returns
-32603 Internal error, with the error message exposing the underlying Kotlin serialization exception.
- Streamable HTTP returns
-32600 Invalid Request.
For the same JSON-RPC method and payload, I would expect the transports to classify the error consistently.
- Environment
- Reproduced with stable release
0.13.0 (b7eeeb12058099f980fa98d1468506489a6b5f32)
- Transports: stdio and Streamable HTTP
To reproduce
- Start a Kotlin SDK MCP server over stdio or Streamable HTTP.
- Send this malformed
initialize request:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{},"clientInfo":{"name":"repro","version":"0.1.0"}}}
The request intentionally omits params.protocolVersion.
Expected behavior
Because the method exists but the method-specific params are incomplete, I would expect a consistent JSON-RPC error. The exact message can vary, but the error category should be stable across transports for the same input.
Logs
stdio returns -32603 Internal error. The error message appears to expose the underlying kotlinx.serialization.MissingFieldException message:
{"id":1,"error":{"code":-32603,"message":"Fields [protocolVersion, capabilities, clientInfo] are required for type with serial name 'io.modelcontextprotocol.kotlin.sdk.types.InitializeRequestParams', but they were missing"},"jsonrpc":"2.0"}
Streamable HTTP returns -32600 Invalid Request for the same request.
In both cases, the server remained usable.
Describe the bug
When an
initializerequest has a valid JSON-RPC envelope and a recognized method name, but is missing required fields such asparams.protocolVersion, the Kotlin SDK appears to return different JSON-RPC error codes depending on the transport:-32603 Internal error, with the error message exposing the underlying Kotlin serialization exception.-32600 Invalid Request.For the same JSON-RPC method and payload, I would expect the transports to classify the error consistently.
0.13.0(b7eeeb12058099f980fa98d1468506489a6b5f32)To reproduce
initializerequest:{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{},"clientInfo":{"name":"repro","version":"0.1.0"}}}The request intentionally omits
params.protocolVersion.Expected behavior
Because the method exists but the method-specific params are incomplete, I would expect a consistent JSON-RPC error. The exact message can vary, but the error category should be stable across transports for the same input.
Logs
stdio returns
-32603 Internal error. The error message appears to expose the underlyingkotlinx.serialization.MissingFieldExceptionmessage:{"id":1,"error":{"code":-32603,"message":"Fields [protocolVersion, capabilities, clientInfo] are required for type with serial name 'io.modelcontextprotocol.kotlin.sdk.types.InitializeRequestParams', but they were missing"},"jsonrpc":"2.0"}Streamable HTTP returns
-32600 Invalid Requestfor the same request.In both cases, the server remained usable.