Skip to content

Python client incompatible with typescript server #347

@p11o

Description

@p11o

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/missing

Expected 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions