Skip to content

Malformed initialize request with missing required params returns different JSON-RPC error codes per transport #830

@cclabadmin

Description

@cclabadmin

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

  1. Start a Kotlin SDK MCP server over stdio or Streamable HTTP.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions