You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python-based MCP servers crash when a second client connects through ToolHive's stdio proxy. The proxy forwards a second initialize request to an already-initialized session, causing a Pydantic validation error that crashes the Python process.
Steps to reproduce
Deploy a Python MCP server via ToolHive with stdio transport: thv run docker.io/mcp/git:latest --name git --transport stdio --proxy-mode streamable-http
Connect a first MCP client - works fine
Connect a second MCP client or wait several minutes for ToolHive's internal health check
Container crashes with exit code 1
Expected behavior
The proxy should handle multiple client connections by either:
Multiplexing clients onto the single stdio session without re-sending initialize
Resetting the session before forwarding a new initialize
Actual behavior
The proxy forwards the second initialize request to the active stdio session. The Python MCP SDK's _receive_loop tries to validate it as a ClientRequest (which only accepts post-initialization requests like ping, tools/call, etc.), fails with validation errors, and crashes:
pydantic_core.ValidationError: 20 validation errors for ClientRequest
InitializeRequest.params
Field required [type=missing, input_value={'method': 'initialize', ...
Node.js MCP servers, for example, don't crash on unexpected messages, so they're unaffected.
I was able to reproduce the crash locally just using the python sdk and not the git server. The good news is that the latest Python MCP SDK (v1.26.0) fixes it. The server does not crash when a second MCP client connects. I also validated the git server referenced uses an old version of mcp:
For my test server with the latest mcp version, I was able to connect multiple clients to the thv proxy without problem. Note: from my brief reading of the python mcp source code, it appears the subsequent sessions may overwrite the state of prior sessions. That should only be a problem if you have a stateful mcp server implementation.
Let me know if this unblocks you or you have further questions.
Activity
jerm-dro commentedon Feb 12, 2026
Hey @azavisha-snap thanks for reporting this issue.
I was able to reproduce the crash locally just using the python sdk and not the git server. The good news is that the latest Python MCP SDK (v1.26.0) fixes it. The server does not crash when a second MCP client connects. I also validated the
gitserver referenced uses an old version ofmcp:$ docker run --rm --entrypoint python mcp/git:latest -c "import importlib.metadata; print(importlib.metadata.version('mcp'))" 1.1.0For my test server with the latest mcp version, I was able to connect multiple clients to the
thvproxy without problem. Note: from my brief reading of the python mcp source code, it appears the subsequent sessions may overwrite the state of prior sessions. That should only be a problem if you have a stateful mcp server implementation.Let me know if this unblocks you or you have further questions.