"Building an MCP server with ADK tools" Example not working #3215
Closed
IAmNo1Special
started this conversation in
General
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The example for creating an MCP server in the docs (https://google.github.io/adk-docs/tools/mcp-tools/#2-building-an-mcp-server-with-adk-tools-mcp-server-exposing-adk) is not working for me.
I copied and pasted it, updated the "PATH_TO_YOUR_MCP_SERVER_SCRIPT" variable to point to the correct path, which in my case is F:\AI\RevomonAgent\test_agent\my_adk_mcp_server.py
I use the "adk web" command from the "RevomonAgent" directory and once i open the adk web ui i select "test_agent" from the dropdown.
I then send the message "Hello" to the chat and the code throws the following:
`
(revomonagent) PS F:\AI\RevomonAgent> adk web
F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\cli\fast_api.py:179: UserWarning: [EXPERIMENTAL] InMemoryCredentialService: This feature is experimental and may change or be removed in future versions without notice. It may introduce breaking changes at any time.
credential_service = InMemoryCredentialService()
F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\auth\credential_service\in_memory_credential_service.py:33: UserWarning: [EXPERIMENTAL] BaseCredentialService: This feature is experimental and may change or be removed in future versions without notice. It may introduce breaking changes at any time.
super().init()
INFO: Started server process [9420]
INFO: Waiting for application startup.
+-----------------------------------------------------------------------------+
| ADK Web Server started |
| |
| For local testing, access at http://127.0.0.1:8000. |
+-----------------------------------------------------------------------------+
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: 127.0.0.1:63698 - "GET / HTTP/1.1" 307 Temporary Redirect
INFO: 127.0.0.1:63698 - "GET /dev-ui/assets/config/runtime-config.json HTTP/1.1" 200 OK
INFO: 127.0.0.1:63698 - "GET /list-apps?relative_path=./ HTTP/1.1" 200 OK
INFO: 127.0.0.1:63698 - "POST /apps/test_agent/users/user/sessions HTTP/1.1" 200 OK
INFO: 127.0.0.1:63698 - "GET /apps/test_agent/eval_sets HTTP/1.1" 200 OK
INFO: 127.0.0.1:58759 - "GET /apps/test_agent/eval_results HTTP/1.1" 200 OK
INFO: 127.0.0.1:58759 - "GET /apps/test_agent/users/user/sessions HTTP/1.1" 200 OK
INFO: 127.0.0.1:58759 - "GET /apps/test_agent/users/user/sessions HTTP/1.1" 200 OK
INFO: 127.0.0.1:58759 - "POST /run_sse HTTP/1.1" 200 OK
2025-10-18 12:00:54,890 - INFO - envs.py:47 - Loaded .env file for test_agent at F:\AI\RevomonAgent\test_agent.env
2025-10-18 12:00:54,891 - INFO - envs.py:47 - Loaded .env file for test_agent at F:\AI\RevomonAgent\test_agent.env
2025-10-18 12:00:54,904 - INFO - agent_loader.py:126 - Found root_agent in test_agent.agent
F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\cli\adk_web_server.py:475: UserWarning: [EXPERIMENTAL] App: This feature is experimental and may change or be removed in future versions without notice. It may introduce breaking changes at any time.
agentic_app = App(
2025-10-18 12:01:02,796 - ERROR - init.py:157 - Failed to parse JSONRPC message from server
Traceback (most recent call last):
File "F:\AI\RevomonAgent.venv\Lib\site-packages\mcp\client\stdio_init_.py", line 155, in stdout_reader
message = types.JSONRPCMessage.model_validate_json(line)
File "F:\AI\RevomonAgent.venv\Lib\site-packages\pydantic\main.py", line 766, in model_validate_json
return cls.pydantic_validator.validate_json(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
json_data, strict=strict, extra=extra, context=context, by_alias=by_alias, by_name=by_name
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
pydantic_core._pydantic_core.ValidationError: 1 validation error for JSONRPCMessage
Invalid JSON: expected ident at line 1 column 3 [type=json_invalid, input_value='Initializing ADK load_web_page tool...\r', input_type=str]
For further information visit https://errors.pydantic.dev/2.12/v/json_invalid
2025-10-18 12:01:03,896 - ERROR - adk_web_server.py:1404 - Error in event_generator: unhandled errors in a TaskGroup (1 sub-exception)
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\cli\adk_web_server.py", line 1394, in event_generator
| async for event in agen:
| ...<7 lines>...
| yield f"data: {sse_event}\n\n"
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\runners.py", line 428, in run_async
| async for event in agen:
| yield event
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\runners.py", line 412, in _run_with_trace
| async for event in agen:
| yield event
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\runners.py", line 498, in _exec_with_plugin
| async for event in agen:
| ...<9 lines>...
| yield (modified_event if modified_event else event)
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\runners.py", line 401, in execute
| async for event in agen:
| yield event
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\agents\base_agent.py", line 307, in run_async
| async for event in agen:
| yield event
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\agents\base_agent.py", line 297, in _run_with_trace
| async for event in agen:
| yield event
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\agents\llm_agent.py", line 395, in _run_async_impl
| async for event in agen:
| ...<3 lines>...
| return
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\flows\llm_flows\base_llm_flow.py", line 356, in run_async
| async for event in agen:
| last_event = event
| yield event
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\flows\llm_flows\base_llm_flow.py", line 375, in _run_one_step_async
| async for event in agen:
| yield event
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\flows\llm_flows\base_llm_flow.py", line 463, in _preprocess_async
| tools = await _convert_tool_union_to_tools(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ...<4 lines>...
| )
| ^
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\agents\llm_agent.py", line 157, in _convert_tool_union_to_tools
| return await tool_union.get_tools_with_prefix(ctx)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\tools\base_toolset.py", line 114, in get_tools_with_prefix
| tools = await self.get_tools(readonly_context)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_session_manager.py", line 128, in wrapper
| return await func(self, *args, **kwargs)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py", line 159, in get_tools
| session = await self.mcp_session_manager.create_session()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_session_manager.py", line 372, in create_session
| await exit_stack.aclose()
| File "C:\Users\ivmno\AppData\Local\Programs\Python\Python313\Lib\contextlib.py", line 705, in aclose
| await self.aexit(None, None, None)
| File "C:\Users\ivmno\AppData\Local\Programs\Python\Python313\Lib\contextlib.py", line 768, in aexit
| raise exc
| File "C:\Users\ivmno\AppData\Local\Programs\Python\Python313\Lib\contextlib.py", line 751, in aexit
| cb_suppress = await cb(*exc_details)
| ^^^^^^^^^^^^^^^^^^^^^^
| File "C:\Users\ivmno\AppData\Local\Programs\Python\Python313\Lib\contextlib.py", line 221, in aexit
| await anext(self.gen)
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\mcp\client\stdio_init.py", line 183, in stdio_client
| anyio.create_task_group() as tg,
| ~~~~~~~~~~~~~~~~~~~~~~~^^
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\anyio_backends_asyncio.py", line 781, in aexit
| raise BaseExceptionGroup(
| "unhandled errors in a TaskGroup", self.exceptions
| ) from None
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\mcp\client\stdio_init.py", line 155, in stdout_reader
| message = types.JSONRPCMessage.model_validate_json(line)
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\pydantic\main.py", line 766, in model_validate_json
| return cls.pydantic_validator.validate_json(
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
| json_data, strict=strict, extra=extra, context=context, by_alias=by_alias, by_name=by_name
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| )
| ^
| pydantic_core.pydantic_core.ValidationError: 1 validation error for JSONRPCMessage
| Invalid JSON: expected ident at line 1 column 3 [type=json_invalid, input_value='Initializing ADK load_web_page tool...\r', input_type=str]
| For further information visit https://errors.pydantic.dev/2.12/v/json_invalid
|
| During handling of the above exception, another exception occurred:
|
| Traceback (most recent call last):
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\mcp\client\stdio_init.py", line 158, in stdout_reader
| await read_stream_writer.send(exc)
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\anyio\streams\memory.py", line 243, in send
| self.send_nowait(item)
| ~~~~~~~~~~~~~~~~^^^^^^
| File "F:\AI\RevomonAgent.venv\Lib\site-packages\anyio\streams\memory.py", line 214, in send_nowait
| raise BrokenResourceError
| anyio.BrokenResourceError
+------------------------------------
INFO: 127.0.0.1:58759 - "GET /apps/test_agent/users/user/sessions/f6e75d79-e340-4f4e-aba5-f88ddac20a61 HTTP/1.1" 200 OK
INFO: 127.0.0.1:61264 - "GET /debug/trace/session/f6e75d79-e340-4f4e-aba5-f88ddac20a61 HTTP/1.1" 200 OK
`
Beta Was this translation helpful? Give feedback.
All reactions