Hi, I tried the MCP Toolbox demo. I was blocked when run “uv run agent.py” command. I got the error message:
an error occurred during closing of asynchronous generator <async_generator object streamablehttp_client at 0x0000022E7A2EAB60>
asyncgen: <async_generator object streamablehttp_client at 0x0000022E7A2EAB60>
- Exception Group Traceback (most recent call last):
| File “E:\workshop\example\agno\cookbook\tools\mcp\mcp_toolbox_demo.venv\Lib\site-packages\anyio_backends_asyncio.py”, line 772, in aexit
| raise BaseExceptionGroup(
| “unhandled errors in a TaskGroup”, self._exceptions
| ) from None
| BaseExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
±±--------------- 1 ----------------
| Traceback (most recent call last):
| File “E:\workshop\example\agno\cookbook\tools\mcp\mcp_toolbox_demo.venv\Lib\site-packages\mcp\client\streamable_http.py”, line 498, in streamablehttp_client
| yield (
| …<3 lines>…
| )
| GeneratorExit
±-----------------------------------
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “E:\workshop\example\agno\cookbook\tools\mcp\mcp_toolbox_demo.venv\Lib\site-packages\mcp\client\streamable_http.py”, line 474, in streamablehttp_client
async with anyio.create_task_group() as tg:
~~~~~~~~~~~~~~~~~~~~~~~^^
File “E:\workshop\example\agno\cookbook\tools\mcp\mcp_toolbox_demo.venv\Lib\site-packages\anyio_backends_asyncio.py”, line 778, in aexit
if self.cancel_scope.exit(type(exc), exc, exc.traceback):
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “E:\workshop\example\agno\cookbook\tools\mcp\mcp_toolbox_demo.venv\Lib\site-packages\anyio_backends_asyncio.py”, line 457, in exit
raise RuntimeError(
…<2 lines>…
)
RuntimeError: Attempted to exit cancel scope in a different task than it was entered in
Traceback (most recent call last):
File “E:\workshop\example\agno\libs\agno\agno\tools\mcp_toolbox.py”, line 92, in _connect_toolbox_client
all_functions = await self.load_multiple_toolsets(toolset_names=self.toolsets)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “E:\workshop\example\agno\libs\agno\agno\tools\mcp_toolbox.py”, line 244, in load_multiple_toolsets
tools = await self.load_toolset(
^^^^^^^^^^^^^^^^^^^^^^^^
…<4 lines>…
)
^
File “E:\workshop\example\agno\libs\agno\agno\tools\mcp_toolbox.py”, line 209, in load_toolset
core_sync_tools = await self.__core_client.load_toolset(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
…<4 lines>…
)
^
File “E:\workshop\example\agno\cookbook\tools\mcp\mcp_toolbox_demo.venv\Lib\site-packages\toolbox_core\client.py”, line 282, in load_toolset
raise RuntimeError(
f"API request failed with status {response.status} ({response.reason}). Server response: {error_text}"
)
RuntimeError: API request failed with status 404 (Not Found). Server response: 404 page not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “E:\workshop\example\agno\cookbook\tools\mcp\mcp_toolbox_demo\agent.py”, line 96, in
asyncio.run(run_agent(message=“”))
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py”, line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File “C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py”, line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File “C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py”, line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File “E:\workshop\example\agno\cookbook\tools\mcp\mcp_toolbox_demo\agent.py”, line 21, in run_agent
async with MCPToolbox(
~~~~~~~~~~^
url=url, toolsets=[“hotel-management”, “booking-system”]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
) as db_tools:
^
File “E:\workshop\example\agno\libs\agno\agno\tools\mcp_toolbox.py”, line 276, in aenter
await self.connect()
File “E:\workshop\example\agno\libs\agno\agno\tools\mcp_toolbox.py”, line 79, in connect
await self._connect_toolbox_client()
File “E:\workshop\example\agno\libs\agno\agno\tools\mcp_toolbox.py”, line 101, in _connect_toolbox_client
raise RuntimeError(f"Failed to connect to ToolboxClient: {e}") from e
RuntimeError: Failed to connect to ToolboxClient: API request failed with status 404 (Not Found). Server response: 404 page not found
And the mcp server (installed on my machine) output the following log:
I accessed the URL : http://127.0.0.1:5001/api/toolset/hotel-management , the response is right:
{"serverVersion":"0.17.0+binary.windows.amd64.de19d52","tools":{"find-hotels-by-tier-and-location":{"description":"\nFind hotels based on location. and price tier. Returns hotels that match the criteria\r","parameters":[{"name":"location","type":"string","required":true,"description":"The location to search for hotels (city or region).","authSources":[]},{"name":"tier","type":"string","required":true,"description":"The hotel tier/category (Luxury, Economy, Boutique, Extended-Stay).","authSources":[]}],"authRequired":[]},"search-hotels-by-location":{"description":"Search for hotels based on location.","parameters":[{"name":"location","type":"string","required":true,"description":"The location of the hotel.","authSources":[]}],"authRequired":[]},"search-hotels-by-name":{"description":"Search for hotels based on name.","parameters":[{"name":"name","type":"string","required":true,"description":"The name of the hotel.","authSources":[]}],"authRequired":[]}}}
But the URL "http://127.0.0.1:5001/mcp/api/toolset/hotel-management" return 404.
What's wrong with the code?
It seems that the prefix "/mcp" is redundant.
