ZOD errors when connecting to MCP server
Hi,
I'm trying to develop a simple mcp server. When I'm connecting with the [MCPInspector](https://modelcontextprotocol.io/docs/tools/inspector) I'm getting a ZOD error:
```
Created client transport
Created server transport
Received POST message for sessionId b14088d5-5726-4278-92c1-d89c01822cdd
Received POST message for sessionId b14088d5-5726-4278-92c1-d89c01822cdd
Error from MCP server: ZodError: [
{
"code": "invalid_union",
"unionErrors": [
{
"issues": [
{
"code": "invalid_union",
"unionErrors": [
{
"issues": [
{
"code": "invalid_type",
"expected": "string",
"received": "null",
"path": [
"id"
],
"message": "Expected string, received null"
}
],
"name": "ZodError"
},
{
"issues": [
{
"code": "invalid_type",
"expected": "number",
"received": "null",
"path": [
"id"
],
"message": "Expected number, received null"
}
],
"name": "ZodError"
}
],
"path": [
"id"
],
"message": "Invalid input"
},
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"method"
],
"message": "Required"
},
{
"code": "unrecognized_keys",
"keys": [
"error"
],
"path": [],
"message": "Unrecognized key(s) in object: 'error'"
}
],
"name": "ZodError"
},
{
"issues": [
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"method"
],
"message": "Required"
},
{
"code": "unrecognized_keys",
"keys": [
"id",
"error"
],
"path": [],
"message": "Unrecognized key(s) in object: 'id', 'error'"
}
],
"name": "ZodError"
},
{
"issues": [
{
"code": "invalid_union",
"unionErrors": [
{
"issues": [
{
"code": "invalid_type",
"expected": "string",
"received": "null",
"path": [
"id"
],
"message": "Expected string, received null"
}
],
"name": "ZodError"
},
{
"issues": [
{
"code": "invalid_type",
"expected": "number",
"received": "null",
"path": [
"id"
],
"message": "Expected number, received null"
}
],
"name": "ZodError"
}
],
"path": [
"id"
],
"message": "Invalid input"
},
{
"code": "invalid_type",
"expected": "object",
"received": "undefined",
"path": [
"result"
],
"message": "Required"
},
{
"code": "unrecognized_keys",
"keys": [
"error"
],
"path": [],
"message": "Unrecognized key(s) in object: 'error'"
}
],
"name": "ZodError"
},
{
"issues": [
{
"code": "invalid_union",
"unionErrors": [
{
"issues": [
{
"code": "invalid_type",
"expected": "string",
"received": "null",
"path": [
"id"
],
"message": "Expected string, received null"
}
],
"name": "ZodError"
},
{
"issues": [
{
"code": "invalid_type",
"expected": "number",
"received": "null",
"path": [
"id"
],
"message": "Expected number, received null"
}
],
"name": "ZodError"
}
],
"path": [
"id"
],
"message": "Invalid input"
}
],
"name": "ZodError"
}
],
"path": [],
"message": "Invalid input"
}
]
at get error (file:///Users/ralphkube/.npm/_npx/5a9d879542beca3a/node_modules/zod/v3/types.js:39:31)
at ZodUnion.parse (file:///Users/ralphkube/.npm/_npx/5a9d879542beca3a/node_modules/zod/v3/types.js:114:22)
at deserializeMessage (file:///Users/ralphkube/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:26:33)
at ReadBuffer.readMessage (file:///Users/ralphkube/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:19:16)
at StdioClientTransport.processReadBuffer (file:///Users/ralphkube/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:141:50)
at Socket.<anonymous> (file:///Users/ralphkube/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:103:22)
at Socket.emit (node:events:507:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5) {
issues: [
{
code: 'invalid_union',
unionErrors: [Array],
path: [],
message: 'Invalid input'
}
],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
errors: [
{
code: 'invalid_union',
unionErrors: [Array],
path: [],
message: 'Invalid input'
}
]
}
```
关闭于 2025-10-24 1 条评论