-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ADK web not working, but runs in terminal #893
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
Comments
looks like you are using old adk versions. we have changed he MCPToolset interface in 1.0.0 + could you try the new version ? something like below : agent = LlmAgent( |
When using MCPToolset I am getting the below error. Can you please help me on this. I am using google-adk 1.0.0 2025-05-25 12:31:22,303 - ERROR - fast_api.py:817 - Error in event_generator: |
I tried using 1.0.0 but wont work , it starts the web thought, you can chat normal but when it start using tool it will ge error this is the log when it start using the tool `
|
When I use adk web call Agent, I get the same error as @Anusha2015 , I am using google-adk 1.0.0,my Agent code is as follows: TARGET_FOLDER_PATH = os.path.join(os.path.dirname(os.path.abspath(file)), "/path/to/your/folder") root_agent = LlmAgent( |
still no update? I got another agent using google map working in temirnal but not in web here is the current code
|
@dominicdev refer to 378#(#387 have solved the problem. with the --no-reload option, the agent can be run in the terminal or on the web. |
The issue should have been fixed in the latest codes. Let's verify the user's agent codes on HEAD |
I verified locally with https://github.com/google/adk-python/blob/main/contributing/samples/mcp_stdio_server_agent/agent.py and latest ADK, and it worked well. |
Feel free to reopen if you can still reproduce on latest source. Thanks! |
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: