Description
Describe the bug
The MCP client fails to initialize due to a NotImplementedError
when attempting to create a subprocess on Windows using Python 3.12. This error occurs within the asyncio
library, specifically in the _make_subprocess_transport
function.
To Reproduce
Steps to reproduce the behavior:
- Run the agent on a Windows machine with Python 3.12 installed.
- Initialize LlmAgent that uses MCPToolset for tools, with StdioServerParameters. In my case, I tried to use the NotionMCP:
{
"mcpServers": {
"notionApi": {
"command": "npx",
"args": ["-y", "@notionhq/notion-mcp-server"],
"env": {
"OPENAPI_MCP_HEADERS": "{"Authorization": "Bearer ntn_****", "Notion-Version": "2022-06-28" }"
}
}
}
} - Run adk web
- The error will occur during the MCP session initialization when creating a subprocess.
Desktop:
Windows11
Python 3.12.10
ADK version: 0.4.0
Expected Result:
The MCP client should initialize successfully, and the Notion tools should be available.
Actual Result:
The MCP client fails to initialize, raising a NotImplementedError
. The traceback is as follows:
Traceback (most recent call last):
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\mcp\client\stdio\win32.py", line 72, in create_windows_process
process = await anyio.open_process(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\anyio_core_subprocesses.py", line 190, in open_process
return await get_async_backend().open_process(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\anyio_backends_asyncio.py", line 2561, in open_process
process = await asyncio.create_subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\asyncio\subprocess.py", line 224, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 1756, in subprocess_exec
transport = await self._make_subprocess_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 528, in _make_subprocess_transport
raise NotImplementedError
NotImplementedError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\agent\tools.py", line 38, in init_notion_tools
_notion_tools, _exit_stack = await MCPToolset.from_server(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\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:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 659, in enter_async_context
result = await _enter(cm)
^^^^^^^^^^^^^^^^
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 258, in aenter
raise e
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 255, in aenter
await self._initialize()
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\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\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\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\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\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:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 659, in enter_async_context
result = await enter(cm)
^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 210, in aenter
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\mcp\client\stdio_init.py", line 113, in stdio_client
process = await create_platform_compatible_process(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\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\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\mcp\client\stdio\win32.py", line 85, in create_windows_process
process = await anyio.open_process(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\anyio_core_subprocesses.py", line 190, in open_process
return await get_async_backend().open_process(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pkduo\OneDrive\Máy tính\Agent\notion_agent\env\Lib\site-packages\anyio_backends_asyncio.py", line 2561, in open_process
process = await asyncio.create_subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\asyncio\subprocess.py", line 224, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 1756, in subprocess_exec
transport = await self._make_subprocess_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 528, in _make_subprocess_transport
raise NotImplementedError
NotImplementedError