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

Skip to content

MCPToolset.from_server fails, raising NotImplementedError #611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pkduongsu opened this issue May 7, 2025 · 3 comments
Closed

MCPToolset.from_server fails, raising NotImplementedError #611

pkduongsu opened this issue May 7, 2025 · 3 comments

Comments

@pkduongsu
Copy link

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:

  1. Run the agent on a Windows machine with Python 3.12 installed.
  2. 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" }"
    }
    }
    }
    }
  3. Run adk web
  4. 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

@BenMawnMahlauNBTC
Copy link

BenMawnMahlauNBTC commented May 7, 2025

this is an mcp issue, not an adk issue. there are a bunch of prs on the mcp repo with working fixes for this... none of them have been merged yet. modelcontextprotocol/python-sdk#555

@DeanChensj
Copy link
Collaborator

Thanks @BenMawnMahlauNBTC for the pointer!

@DeanChensj DeanChensj closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2025
@pkduongsu
Copy link
Author

Thanks @BenMawnMahlauNBTC!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants