Description
Describe the bug
-
On Connecting MCP server, I saw this issue
pydantic_core._pydantic_core.ValidationError: 2 validation errors for LlmAgent tools.0.callable -
sometimes below one
Input should be callable [type=callable_type, input_value=<google.adk.tools.mcp_too...t object at 0x11d6469d0>, input_type=MCPToolset]
For further information visit https://errors.pydantic.dev/2.11/v/callable_type
tools.0.is-instance[BaseTool]
Also seeing below error more promienantly
3. {"error": "Function playwright_agent is not found in the tools_dict."}
To Reproduce
Steps to reproduce the behavior:
- Install '...'
google-adk==1.2.1
litellm==1.72.2
openai==1.75.0
python-dotenv==1.1.0
python 3.11
and below is my agent.py file, rest is same as per the tutorial of google-adk
import os
from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParameters
from contextlib import AsyncExitStack
import logging
from dotenv import load_dotenv
load_dotenv()
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def create_playwright_agent():
"""Creates the agent responsible for executing browser tests via MCP."""
# In a real implementation, you would fetch tools from the MCP server here.
logging.info("--- Playwright Into Action ---")
tool = MCPToolset(
connection_params=StdioServerParameters(
command='npx',
args=[
"@playwright/mcp@latest",
],
),
# You can filter for specific Maps tools if needed:
# tool_filter=['get_directions', 'find_place_by_id']
)
return LlmAgent(
name="playwright_agent",
model=os.getenv("GEMINI_AGENT_MODEL_NAME"), # A model good for tool use
description="Executes a structured JSON test plan using Playwright tools from an MCP server.",
instruction=(
"You are a browser automation expert. You will receive a JSON object with a test plan. "
"Execute each step in the plan sequentially using the provided Playwright tools. "
"Log the outcome of each step and return a list of result dictionaries."
),
tools=[
MCPToolset(
connection_params=StdioServerParameters(
command='npx',
args=[
"-y",
"@modelcontextprotocol/server-google-maps",
],
# Pass the API key as an environment variable to the npx process
# This is how the MCP server for Google Maps expects the key.
env={
"GOOGLE_MAPS_API_KEY": *****''
}
),
# You can filter for specific Maps tools if needed:
# tool_filter=['get_directions', 'find_place_by_id']
)
],
)
root-agents.py file
import os
from dotenv import load_dotenv
from google.adk.agents import Agent
from automation_web_agent.agents.playwright.agent import create_playwright_agent
from automation_web_agent.models.llm.llm_model import get_llm_model
from automation_web_agent.config.logging_config import setup_logging
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, SseServerParams
from contextlib import AsyncExitStack
import logging
# Setup logging configuration
setup_logging()
# --- Configure Logging ---
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
load_dotenv()
# Gemini API Key (Get from Google AI Studio: https://aistudio.google.com/app/apikey)
os.environ["GOOGLE_API_KEY"] = os.getenv("GEMINI_KEY")
# 1. Create the specialized agents that will form the team.
tester = create_playwright_agent()
def create_root_agent():
"""
Creates and configures the main RootAgent and its team of sub-agents.
"""
logging.info("--- Building the Agent Team ---")
# 2. Create the RootAgent, passing the other agents as sub-agents.
root_agent_v1 = Agent(
name="test_orchestrator_root_agent",
model=get_llm_model(), # A powerful model for orchestration
description="A master agent that orchestrates a team of specialized testing agents to fulfill a user's request.",
instruction=(
"You are the project manager of a testing team. Your goal is to completely fulfill the user's test request. "
"1. To understand and plan the request, delegate to the 'refine_prompt_agent'. "
"2. To execute the plan in a browser, delegate the plan to the 'playwright_agent'. "
"3. To summarize the execution results, delegate the results to the 'report_generator_agent'. "
"Follow this workflow: Plan -> Execute -> Report. Do not respond to the user until the final report is ready."
),
sub_agents=[tester]
)
logging.info("--- Agent Team Assembled Successfully ---")
return root_agent_v1
root_agent = create_root_agent()
- Run 'adk web'
- Open 'terminal to see this error'
Expected behavior
To run MCP server and see the agent working
Desktop (please complete the following information):
- OS: [e.g. iOS] MacOs 15.1.1
- Python version(python -V): python 3.11
- ADK version(pip show google-adk): 1.2.1
Additional context
I tried with many other MCP's but still seeing same issue
Any help would be really appreciated