Skip to content

MCP Tool Call failing with Voice Agent but not with Text #1966

@guru-desh

Description

@guru-desh

Describe the bug
I'm running into an issue where my agent is able to call my MCP Server using text, but not using audio.

To Reproduce
Steps to reproduce the behavior:

  1. pip install mcp-server-time
  2. Define an ADK agent in agent.py as the following:
MCP_TIME_SERVER = MCPToolset(
    connection_params=StdioServerParameters(
        command="python", args=["-m", "mcp_server_time"]
    )
)

root_agent = LlmAgent(
    model='gemini-2.0-flash-exp',
    name="time_agent",
    instruction="You are a helpful assistant.",
    tools=[MCP_TIME_SERVER],
)
  1. Run adk web and use the microphone to communicate with the agent.
  2. Ask the agent a question that doesn't require a tool call like "How are you doing today?" --> this works
  3. Ask the agent that will require a tool call like "What is the time in America/New_York?" --> this causes the following error:
2025-07-11 20:47:56,462 - ERROR - fast_api.py:924 - Error during live websocket communication: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'
Traceback (most recent call last):
  File ".venv/lib/python3.12/site-packages/google/genai/live.py", line 1046, in connect
    yield AsyncSession(api_client=self._api_client, websocket=ws)
  File ".venv/lib/python3.12/site-packages/google/adk/models/google_llm.py", line 244, in connect
    yield GeminiLlmConnection(live_session)
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 115, in run_live
    async for event in self._receive_from_model(
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 246, in _receive_from_model
    async for event in self._postprocess_live(
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 439, in _postprocess_live
    function_response_event = await functions.handle_function_calls_live(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 288, in handle_function_calls_live
    trace_tool_call(
TypeError: trace_tool_call() got an unexpected keyword argument 'response_event_id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".venv/lib/python3.12/site-packages/google/adk/cli/fast_api.py", line 920, in agent_live_run
    task.result()
  File ".venv/lib/python3.12/site-packages/google/adk/cli/fast_api.py", line 893, in forward_events
    async for event in runner.run_live(
  File ".venv/lib/python3.12/site-packages/google/adk/runners.py", line 326, in run_live
    async for event in invocation_context.agent.run_live(invocation_context):
  File ".venv/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 174, in run_live
    async for event in self._run_live_impl(ctx):
  File ".venv/lib/python3.12/site-packages/google/adk/agents/llm_agent.py", line 281, in _run_live_impl
    async for event in self._llm_flow.run_live(ctx):
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 87, in run_live
    async with llm.connect(llm_request) as llm_connection:
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/contextlib.py", line 231, in __aexit__
    await self.gen.athrow(value)
  File ".venv/lib/python3.12/site-packages/google/adk/models/google_llm.py", line 241, in connect
    async with self._live_api_client.aio.live.connect(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/contextlib.py", line 231, in __aexit__
    await self.gen.athrow(value)
  File ".venv/lib/python3.12/site-packages/google/genai/live.py", line 1049, in connect
    async with ws_connect(uri, extra_headers=headers) as ws:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/websockets/asyncio/client.py", line 587, in __aenter__
    return await self
           ^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/websockets/asyncio/client.py", line 541, in __await_impl__
    self.connection = await self.create_connection()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/websockets/asyncio/client.py", line 467, in create_connection
    _, connection = await loop.create_connection(factory, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'
Traceback (most recent call last):
  File ".venv/lib/python3.12/site-packages/google/genai/live.py", line 1046, in connect
    yield AsyncSession(api_client=self._api_client, websocket=ws)
  File ".venv/lib/python3.12/site-packages/google/adk/models/google_llm.py", line 244, in connect
    yield GeminiLlmConnection(live_session)
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 115, in run_live
    async for event in self._receive_from_model(
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 246, in _receive_from_model
    async for event in self._postprocess_live(
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 439, in _postprocess_live
    function_response_event = await functions.handle_function_calls_live(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 288, in handle_function_calls_live
    trace_tool_call(
TypeError: trace_tool_call() got an unexpected keyword argument 'response_event_id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".venv/lib/python3.12/site-packages/google/adk/cli/fast_api.py", line 920, in agent_live_run
    task.result()
  File ".venv/lib/python3.12/site-packages/google/adk/cli/fast_api.py", line 893, in forward_events
    async for event in runner.run_live(
  File ".venv/lib/python3.12/site-packages/google/adk/runners.py", line 326, in run_live
    async for event in invocation_context.agent.run_live(invocation_context):
  File ".venv/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 174, in run_live
    async for event in self._run_live_impl(ctx):
  File ".venv/lib/python3.12/site-packages/google/adk/agents/llm_agent.py", line 281, in _run_live_impl
    async for event in self._llm_flow.run_live(ctx):
  File ".venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 87, in run_live
    async with llm.connect(llm_request) as llm_connection:
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/contextlib.py", line 231, in __aexit__
    await self.gen.athrow(value)
  File ".venv/lib/python3.12/site-packages/google/adk/models/google_llm.py", line 241, in connect
    async with self._live_api_client.aio.live.connect(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/contextlib.py", line 231, in __aexit__
    await self.gen.athrow(value)
  File ".venv/lib/python3.12/site-packages/google/genai/live.py", line 1049, in connect
    async with ws_connect(uri, extra_headers=headers) as ws:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/websockets/asyncio/client.py", line 587, in __aenter__
    return await self
           ^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/websockets/asyncio/client.py", line 541, in __await_impl__
    self.connection = await self.create_connection()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/websockets/asyncio/client.py", line 467, in create_connection
    _, connection = await loop.create_connection(factory, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'

Expected behavior
What should happen is that the tool should be called without error, and the response should be from the agent "The time is ..."

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Linux
  • Python version(python -V): 3.12.9
  • ADK version(pip show google-adk): 1.3.0

Model Information:
gemini-2.0-flash-exp

Additional context
N/A

Metadata

Metadata

Assignees

Labels

bot triaged[Bot] This issue is triaged by ADK botlive[Component] This issue is related to live, voice and video chatmcp[Component] Issues about MCP support

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions