You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got a working agent with notion mcp, it runs without a problem in teminal but getting error running in adk web, the error show up when starting to chat with the agent
here's is the log for error
2025-05-23 20:28:33,851 - INFO - envs.py:47 - Loaded .env file for main_agent at D:\Documents\Python\git\agent system\agent_notion_tool\main_agent\.env 2025-05-23 20:28:33,866 - ERROR - fast_api.py:637 - Error in event_generator: Traceback (most recent call last): File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\cli\fast_api.py", line 625, in event_generator runner = await _get_runner_async(req.app_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\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 "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\cli\fast_api.py", line 773, in _get_root_agent_async agent_module = importlib.import_module(app_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\importlib\__init__.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1387, in _gcd_import File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 935, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 995, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "D:\Documents\Python\git\agent system\agent_notion_tool\main_agent\__init__.py", line 1, in <module> from . import agent File "D:\Documents\Python\git\agent system\agent_notion_tool\main_agent\agent.py", line 51, in <module> root_agent = asyncio.run(build_agent())[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\nest_asyncio.py", line 30, in run return loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\nest_asyncio.py", line 98, in run_until_complete return f.result() ^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\futures.py", line 203, in result raise self._exception.with_traceback(self._exception_tb) File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\tasks.py", line 314, in __step_run_and_handle_result result = coro.send(None) ^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\main_agent\agent.py", line 27, in build_agent notion_tools, stack = await MCPToolset.from_server( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\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\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\contextlib.py", line 659, in enter_async_context result = await _enter(cm) ^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 258, in __aenter__ raise e File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 255, in __aenter__ await self._initialize() File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 229, in _initialize self.session = await self.session_manager.create_session() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_session_manager.py", line 132, in create_session return await MCPSessionManager.initialize_session( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\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\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\contextlib.py", line 659, in enter_async_context result = await _enter(cm) ^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\contextlib.py", line 210, in __aenter__ return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\mcp\client\stdio.py", line 104, in stdio_client process = await anyio.open_process( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\anyio\_core\_subprocesses.py", line 190, in open_process return await get_async_backend().open_process( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2561, in open_process process = await asyncio.create_subprocess_exec( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\subprocess.py", line 224, in create_subprocess_exec transport, protocol = await loop.subprocess_exec( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\base_events.py", line 1743, in subprocess_exec transport = await self._make_subprocess_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\base_events.py", line 524, in _make_subprocess_transport raise NotImplementedError NotImplementedError
here is also my code
`
from dotenv import load_dotenv
import nest_asyncio
import os, json, asyncio
from contextlib import AsyncExitStack
from google.adk.agents.llm_agent import LlmAgent
from google.adk.tools.mcp_tool.mcp_toolset import (
MCPToolset, StdioServerParameters, SseServerParams
)
MODEL = "gemini-2.5-flash-preview-04-17" # Or "gemini-1.5-pro-latest" for more power
I got a working agent with notion mcp, it runs without a problem in teminal but getting error running in adk web, the error show up when starting to chat with the agent
here's is the log for error
2025-05-23 20:28:33,851 - INFO - envs.py:47 - Loaded .env file for main_agent at D:\Documents\Python\git\agent system\agent_notion_tool\main_agent\.env 2025-05-23 20:28:33,866 - ERROR - fast_api.py:637 - Error in event_generator: Traceback (most recent call last): File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\cli\fast_api.py", line 625, in event_generator runner = await _get_runner_async(req.app_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\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 "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\cli\fast_api.py", line 773, in _get_root_agent_async agent_module = importlib.import_module(app_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\importlib\__init__.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1387, in _gcd_import File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 935, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 995, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "D:\Documents\Python\git\agent system\agent_notion_tool\main_agent\__init__.py", line 1, in <module> from . import agent File "D:\Documents\Python\git\agent system\agent_notion_tool\main_agent\agent.py", line 51, in <module> root_agent = asyncio.run(build_agent())[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\nest_asyncio.py", line 30, in run return loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\nest_asyncio.py", line 98, in run_until_complete return f.result() ^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\futures.py", line 203, in result raise self._exception.with_traceback(self._exception_tb) File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\tasks.py", line 314, in __step_run_and_handle_result result = coro.send(None) ^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\main_agent\agent.py", line 27, in build_agent notion_tools, stack = await MCPToolset.from_server( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\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\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\contextlib.py", line 659, in enter_async_context result = await _enter(cm) ^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 258, in __aenter__ raise e File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 255, in __aenter__ await self._initialize() File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 229, in _initialize self.session = await self.session_manager.create_session() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_session_manager.py", line 132, in create_session return await MCPSessionManager.initialize_session( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\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\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\contextlib.py", line 659, in enter_async_context result = await _enter(cm) ^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\contextlib.py", line 210, in __aenter__ return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\mcp\client\stdio.py", line 104, in stdio_client process = await anyio.open_process( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\anyio\_core\_subprocesses.py", line 190, in open_process return await get_async_backend().open_process( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Documents\Python\git\agent system\agent_notion_tool\.venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2561, in open_process process = await asyncio.create_subprocess_exec( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\subprocess.py", line 224, in create_subprocess_exec transport, protocol = await loop.subprocess_exec( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\base_events.py", line 1743, in subprocess_exec transport = await self._make_subprocess_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\base_events.py", line 524, in _make_subprocess_transport raise NotImplementedError NotImplementedError
here is also my code
`
from dotenv import load_dotenv
import nest_asyncio
import os, json, asyncio
from contextlib import AsyncExitStack
from google.adk.agents.llm_agent import LlmAgent
from google.adk.tools.mcp_tool.mcp_toolset import (
MCPToolset, StdioServerParameters, SseServerParams
)
MODEL = "gemini-2.5-flash-preview-04-17" # Or "gemini-1.5-pro-latest" for more power
nest_asyncio.apply()
load_dotenv()
NOTION_API_KEY = os.getenv("NOTION_API_KEY")
NOTION_HEADERS = json.dumps({
"Authorization": f"Bearer {NOTION_API_KEY}",
"Notion-Version": "2022-06-28"
})
async def build_agent():
notion_tools, stack = await MCPToolset.from_server(
connection_params=StdioServerParameters(
command="npx.cmd",
args=["-y", "@notionhq/notion-mcp-server"],
env={"OPENAPI_MCP_HEADERS": NOTION_HEADERS},
)
)
root_agent = asyncio.run(build_agent())[0]
`
The text was updated successfully, but these errors were encountered: