-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
Describe the bug
Python client is not compatible with Typescript Server.
Python sdk v1.5.0
Typescript sdk 1.7.0
To Reproduce
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def connect_to_server():
server_params = StdioServerParameters(
command="bun",
args=["index.ts"],
env=None
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
val = await session.call_tool("tool", {})
print("\nResponse from tool:", val)
asyncio.run(connect_to_server())import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
(async () => {
const server = new McpServer({
name: "example",
version: "0.1.0"
});
server.tool(
"tool",
"my tool description",
z.object({
"arg1": z.string().optional(),
}).shape,
async (args) => {
return { "tool": "test" };
}
);
const transport = new StdioServerTransport();
await server.connect(transport);
})(); | File "/app/.venv/lib/python3.13/site-packages/pydantic/main.py", line 627, in model_validate
| return cls.__pydantic_validator__.validate_python(
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
| obj, strict=strict, from_attributes=from_attributes, context=context
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| )
| ^
| pydantic_core._pydantic_core.ValidationError: 1 validation error for CallToolResult
| content
| Field required [type=missing, input_value={'tool': 'test'}, input_type=dict]
| For further information visit https://errors.pydantic.dev/2.10/v/missingExpected behavior
It should accept the response. There is validation on the response from the mcp server in the python client that is incompatible somehow.
Screenshots
N/A
Desktop (please complete the following information):
- OS: Ubuntu
Metadata
Metadata
Assignees
Labels
No labels