-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Describe the bug
When using a stdio_client to connect to a FastMCP server on Windows, the connection fails with an McpError: Invalid request parameters. This occurs even with a minimal, "hello world" server setup, which suggests a fundamental incompatibility between these components on Windows.
Affected version
Note: I am not using Docker. I installed the library using pip.
To find the version, please run this command in your terminal and paste the output below:
pip show mcp
(If your package is named differently, like github-mcp-server
, please use that name instead of mcp
)
Steps to reproduce the behavior
-
Create a file named
test_server.py
with the following code:Python
# test_server.py from mcp.server.fastmcp import FastMCP mcp = FastMCP("simple-test-server") @mcp.tool() async def hello(name: str) -> str: """A simple tool that returns a greeting.""" return f"Hello, {name}" if __name__ == "__main__": mcp.run()
-
Create another file in the same directory named
test_client.py
with the following code:Python
# test_client.py import asyncio import sys from types import SimpleNamespace from mcp import ClientSession from mcp.client.stdio import stdio_client async def run_test_client(): server_config = SimpleNamespace( command=sys.executable, args=["test_server.py"], env=None, cwd=None, encoding='utf-8', encoding_error_handler='ignore' ) print("--- Starting simple server ---") async with stdio_client(server_config) as (read_stream, write_stream): async with ClientSession(read_stream, write_stream) as session: tools = await session.list_tools() print("Available tools:", [tool.name for tool in tools]) result = await session.call_tool("hello", {"name": "World"}) print("\nServer says:", result.output_text) if __name__ == "__main__": asyncio.run(run_test_client())
-
From the terminal, run the client:
python test_client.py
-
See the error traceback in the output.
Expected vs actual behavior
Expected behavior: The client should connect successfully, print Available tools: ['hello']
, and then print Server says: Hello, World
.
Actual behavior: The client fails immediately when trying to list the tools, raising an McpError: Invalid request parameters
.
Logs
--- Starting simple server ---
- Exception Group Traceback (most recent call last):
| File "D:\CODE\projects\Currency_Agent\answer\test_client.py", line 32, in
| asyncio.run(run_test_client())
| File "C:\Users[username]\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
| return runner.run(main)
| ^^^^^^^^^^^^^^^^
| File "C:\Users[username]\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
| return self.loop.run_until_complete(task)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "C:\Users[username]\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
| return future.result()
| ^^^^^^^^^^^^^^^
| File "D:\CODE\projects\Currency_Agent\answer\test_client.py", line 21, in run_test_client
| async with stdio_client(server_config) as (read_stream, write_stream):
| File "C:\Users[username]\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 222, in aexit
| await self.gen.athrow(typ, value, traceback)
| File "D:\CODE\projects\Currency_Agent.venv\Lib\site-packages\mcp\client\stdio_init.py", line 180, in stdio_client
| async with (
| File "D:\CODE\projects\Currency_Agent.venv\Lib\site-packages\anyio_backends_asyncio.py", line 772, in aexit
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Exception Group Traceback (most recent call last):
| File "D:\CODE\projects\Currency_Agent.venv\Lib\site-packages\mcp\client\stdio_init_.py", line 187, in stdio_client
| yield read_stream, write_stream
| File "D:\CODE\projects\Currency_Agent\answer\test_client.py", line 22, in run_test_client
| async with ClientSession(read_stream, write_stream) as session:
| File "D:\CODE\projects\Currency_Agent.venv\Lib\site-packages\anyio_backends_asyncio.py", line 772, in aexit
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "D:\CODE\projects\Currency_Agent\answer\test_client.py", line 24, in run_test_client
| tools = await session.list_tools()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "D:\CODE\projects\Currency_Agent.venv\Lib\site-packages\mcp\client\session.py", line 386, in list_tools
| result = await self.send_request(
| ^^^^^^^^^^^^^^^^^^^^^^^^
| File "D:\CODE\projects\Currency_Agent.venv\Lib\site-packages\mcp\shared\session.py", line 286, in send_request
| raise McpError(response_or_error.error)
| mcp.shared.exceptions.McpError: Invalid request parameters
+------------------------------------