8000 MCPToolset Timeout Error · Issue #1086 · google/adk-python · GitHub
[go: up one dir, main page]

Skip to content
MCPToolset Timeout Error #1086
Open
Open
@nikogamulin

Description

@nikogamulin

Description:

I am encountering a recurring timeout error when using MCPToolset with playwright-mcp to browse the web within an ADK web environment. Specifically, certain web Browse actions take longer than 5 seconds, resulting in the following error:

{"error": "Timed out while waiting for response to ClientRequest. Waited 5.0 seconds."}

This error prevents the agent from completing its task when the web interaction is particularly slow. I have attempted to configure PLAYWRIGHT_TIMEOUT and PLAYWRIGHT_NAVIGATION_TIMEOUT environment variables, but these appear to be specific to Playwright's internal timeouts and do not seem to extend the overall ClientRequest timeout originating from the ADK framework or MCPToolset's interaction with it.

Example Code:

import os

from dotenv import load_dotenv
load_dotenv()

from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParameters, SseServerParams

from .prompt import WEB_PROMPT
from accommodation_search_agent.shared_lib.callbacks import before_search_term_browser_agent_callback

# ---- MCP Library ----
# https://github.com/modelcontextprotocol/servers
# https://smithery.ai/

# Microsoft Playwright MCP server
args_playwrightmcp = [
    "-y",
    "playwright-mcp@latest"
]

# Backup: simple browser MCP (not currently in use, but shows an alternative)
args_browsermcp = [
    "-y",
    "@browsermcp/mcp@latest"
]

search_term_browser_agent = LlmAgent(
    model='gemini-2.0-flash',
    # model=LiteLlm(model="openai/gpt-4o"),
    name='search_term_browser_agent',
    instruction=WEB_PROMPT,
    tools=[
        MCPToolset(
            connection_params=StdioServerParameters(
                command='npx',
                args=args_playwrightmcp,
                env={
                    # Fast operation settings - These seem to only affect Playwright's internal waits,
                    # not the overarching ClientRequest timeout from ADK/MCPToolset.
                    "PLAYWRIGHT_TIMEOUT": "4000",
                    "PLAYWRIGHT_NAVIGATION_TIMEOUT": "3000",
                }
            )
        )
    ],
    output_key="search_results",
    
    before_agent_callback=before_search_term_browser_agent_callback,
)

Steps to Reproduce:

  1. Integrate MCPToolset with playwright-mcp into an LlmAgent within an ADK project.
  2. Deploy or run the agent in an ADK web testing environment (e.g., ADK web UI).
  3. Execute a web Browse task that involves interactions known to be potentially slow (e.g., navigating to a complex page, waiting for dynamic content to load, or performing multiple actions sequentially).
  4. Observe the Timed out while waiting for response to ClientRequest. Waited 5.0 seconds. error after certain actions.

Expected Behavior:

I would expect to be able to configure a longer timeout for the ClientRequest when using MCPToolset, allowing for more time for complex or slow web Browse operations to complete without error.

Actual Behavior:

The ClientRequest consistently times out after 5 seconds, despite attempts to configure Playwright-specific timeouts.

Proposed Solutions/Questions:

  • Is there a way to configure the ClientRequest timeout directly within MCPToolset or the StdioServerParameters?
  • Are there any ADK framework-level configurations that control this client request timeout?
  • Is there a recommended approach for handling long-running web interactions with MCPToolset to avoid these timeouts? For example, can we implement a retry mechanism or a custom timeout setting at a higher level?
  • Could this be related to how the ADK web environment handles long-running tool executions? (A similar issue was observed with BrowserMCP in a LoopAgent context, as seen in MCPToolset (BrowserMCP) Times Out When Used Inside LoopAgent #1078, suggesting it might be an ADK-level timeout).

Any guidance or suggestions on how to address this timeout issue would be greatly appreciated.

Metadata

Metadata

Assignees

Labels

toolsIssues related to tools

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0