Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MCPToolset.from_server fails on Windows with NotImplementedError from asyncio subprocess in Python 3.13, 3.12. 3.11 #585

@dmekalamkv

Description

@dmekalamkv

The bug
When trying to follow the documentation to launch an ADK agent using MCPToolset.from_server(...) with an MCP server run via npx, the system crashes with a RuntimeError: error getting root agent, originating from a NotImplementedError inside Python's asyncio.subprocess. This prevents the agent from initializing entirely.

To Reproduce
Steps to reproduce the behavior:

Install ADK and follow Quickstart setup instructions.

Run the example code for mcp_agent/agent.py provided in the docs

Launch the app with adk web

Observe the server error after session creation:
RuntimeError: error getting root agent with traceback ending in NotImplementedError from asyncio.subprocess_exec.

tools, exit_stack = await MCPToolset.from_server(
connection_params=StdioServerParameters(
command='npx',
args=["-y", "@modelcontextprotocol/server-filesystem", "/absolute/path"]
)
)
Expected behavior
The agent should launch successfully and connect to the MCP server using npx on Windows, as described in the documentation.

Screenshots
N/A (entire error trace is provided below).

Desktop :
OS: Windows 11 (x64)
Python version (python -V): tested in versions 3.13.1, 3.12.0, 3.11.5
ADK version (pip show google-adk): Latest from PyPI (as of May 2025)

Additional context:

I verified all prerequisites from the ADK documentation:

Python ≥ 3.9 is installed (running 3.13.1, 3.12.0, 3.11.5).

Node.js and npx are installed and in PATH.

adk is installed and in PATH.

Error Trace:

2025-05-06 10:35:04,751 - INFO - envs.py:47 - Loaded .env file for multi_tool_agent at C:\Users\Dheeraj Mekala\ai-lab\google_adk\multi_tool_agent.env
2025-05-06 10:35:05,114 - ERROR - fast_api.py:637 - Error in event_generator: error getting root agent,
Traceback (most recent call last):
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\mcp\client\stdio\win32.py", line 72, in create_windows_process
process = await anyio.open_process(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\anyio_core_subprocesses.py", line 190, in open_process
return await get_async_backend().open_process(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\anyio_backends_asyncio.py", line 2561, in open_process
process = await asyncio.create_subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\asyncio\subprocess.py", line 221, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 1694, in subprocess_exec
transport = await self._make_subprocess_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 502, in _make_subprocess_transport
raise NotImplementedError
NotImplementedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\cli\fast_api.py", line 782, in _get_root_agent_async
agent, exit_stack = await root_agent
^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\multi_tool_agent\agent.py", line 8, in create_agent
tools, exit_stack = await MCPToolset.from_server(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 223, in from_server
await async_exit_stack.enter_async_context(toolset)
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 638, in enter_async_context
result = await _enter(cm)
^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 258, in aenter
raise e
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 255, in aenter
await self._initialize()
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 229, in _initialize
self.session = await self.session_manager.create_session()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\tools\mcp_tool\mcp_session_manager.py", line 132, in create_session
return await MCPSessionManager.initialize_session(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\tools\mcp_tool\mcp_session_manager.py", line 173, in initialize_session
transports = await exit_stack.enter_async_context(client)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 638, in enter_async_context
result = await enter(cm)
^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 204, in aenter
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\mcp\client\stdio_init
.py", line 113, in stdio_client
process = await create_platform_compatible_process(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\mcp\client\stdio_init
.py", line 210, in _create_platform_compatible_process
process = await create_windows_process(command, args, env, errlog, cwd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\mcp\client\stdio\win32.py", line 85, in create_windows_process
process = await anyio.open_process(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\anyio_core_subprocesses.py", line 190, in open_process
return await get_async_backend().open_process(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\anyio_backends_asyncio.py", line 2561, in open_process
process = await asyncio.create_subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\asyncio\subprocess.py", line 221, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 1694, in subprocess_exec
transport = await self._make_subprocess_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 502, in _make_subprocess_transport
raise NotImplementedError
NotImplementedError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\cli\fast_api.py", line 625, in event_generator
runner = await _get_runner_async(req.app_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\cli\fast_api.py", line 796, in _get_runner_async
root_agent = await _get_root_agent_async(app_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Dheeraj Mekala\ai-lab\google_adk\test\Lib\site-packages\google\adk\cli\fast_api.py", line 786, in _get_root_agent_async
raise RuntimeError(f"error getting root agent, {e}") from e
RuntimeError: error getting root agent,
INFO: 127.0.0.1:56242 - "GET /apps/multi_tool_agent/users/user/sessions/682eaba7-7102-4730-97d5-cc05d19def4c HTTP/1.1" 200 OK

Metadata

Metadata

Assignees

Labels

tools[Component] This issue is related to tools

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions