[DEBUG] MCP server "<name>": Connection failed after 36ms: [
{
"code": "invalid_union",
"errors": [
[
{
"expected": "string",
"code": "invalid_type",
"path": [
"method"
],
"message": "Invalid input: expected string, received undefined"
},
{
"code": "unrecognized_keys",
"keys": [
"result"
],
"path": [],
"message": "Unrecognized key: \"result\""
}
],
[
{
"expected": "string",
"code": "invalid_type",
"path": [
"method"
],
"message": "Invalid input: expected string, received undefined"
},
{
"code": "unrecognized_keys",
"keys": [
"id",
"result"
],
"path": [],
"message": "Unrecognized keys: \"id\", \"result\""
}
],
[
{
"expected": "object",
"code": "invalid_type",
"path": [
"result",
"_meta"
],
"message": "Invalid input: expected object, received null"
}
],
[
{
"expected": "object",
"code": "invalid_type",
"path": [
"error"
],
"message": "Invalid input: expected object, received undefined"
},
{
"code": "unrecognized_keys",
"keys": [
"result"
],
"path": [],
"message": "Unrecognized key: \"result\""
}
]
],
"path": [],
"message": "Invalid input"
}
]
Describe the bug
null-value properties ofJSONRPCResponse(like_metaofRequestResult) incorrectly serialize tonullin the response JSON, instead of being omitted.According to the Spec,
nullis not an allowed value. It allows either omitting the property or an object value.The MCP server is unusable.
⚠️ Claude & Claude Code do strict schema checking, which is valid. They reject the MCP response and assume the MCP connection fails.
To Reproduce
Steps to reproduce the behavior:
kotlin-sdkMCP server with Claude Code.Expected behavior
Connection succeeds.
Logs
From Claude Code's debug log: