| name | google-adk-mcp-tool |
| description | Integrate MCP (Model Context Protocol) tools into ADK agents. Use when connecting agents to MCP servers — stdio transport, SSE transport, MCPToolset configuration, and tool filtering. |
Google ADK — MCP Tool Integration
Import
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
from mcp import StdioServerParameters
Install MCP Extension
pip install google-adk[mcp]
pip install google-adk[extensions]
Stdio Transport (Local MCP Server)
from google.adk.agents import Agent
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
from mcp import StdioServerParameters
notion_toolset = MCPToolset(
connection_params=StdioServerParameters(
command="npx",
args=["-y", "@notionhq/notion-mcp-server"],
env={"NOTION_API_KEY": "your-key-here"},
),
)
root_agent = Agent(
name="notion_agent",
model="gemini-2.5-flash",
instruction="Help users manage their Notion workspace.",
tools=[notion_toolset],
)
SSE Transport (Remote MCP Server)
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, SseServerParams
remote_toolset = MCPToolset(
connection_params=SseServerParams(
url="http://localhost:8080/sse",
headers={"Authorization": "Bearer token"},
),
)
root_agent = Agent(
name="remote_agent",
model="gemini-2.5-flash",
instruction="Use the remote tools to complete tasks.",
tools=[remote_toolset],
)
Tool Filtering
Only expose specific tools from the MCP server:
toolset = MCPToolset(
connection_params=StdioServerParameters(
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem"],
),
tool_filter=["read_file", "write_file", "list_directory"],
)
Tool Filter with Callable
def my_filter(tool) -> bool:
"""Only allow read operations."""
return tool.name.startswith("read_") or tool.name.startswith("list_")
toolset = MCPToolset(
connection_params=StdioServerParameters(
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem"],
),
tool_filter=my_filter,
)
Multiple MCP Servers
filesystem_tools = MCPToolset(
connection_params=StdioServerParameters(
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem"],
),
)
github_tools = MCPToolset(
connection_params=StdioServerParameters(
command="npx",
args=["-y", "@modelcontextprotocol/server-github"],
env={"GITHUB_TOKEN": "your-token"},
),
)
root_agent = Agent(
name="dev_agent",
model="gemini-2.5-flash",
instruction="Help with development tasks using filesystem and GitHub.",
tools=[filesystem_tools, github_tools],
)
MCP with Agent Instructions
Use McpInstructionProvider to fetch agent instructions from an MCP server's prompts:
from google.adk.agents import Agent
from google.adk.agents.mcp_instruction_provider import McpInstructionProvider
from mcp import StdioServerParameters
mcp_instructions = McpInstructionProvider(
connection_params=StdioServerParameters(
command="npx",
args=["-y", "@my-org/my-mcp-server"],
),
prompt_name="agent_instructions",
)
root_agent = Agent(
name="my_agent",
model="gemini-2.5-flash",
instruction=mcp_instructions,
tools=[notion_toolset],
)
Common MCP Servers
| Server | Command | Use Case |
|---|
| Filesystem | @modelcontextprotocol/server-filesystem | File read/write |
| GitHub | @modelcontextprotocol/server-github | Repos, PRs, issues |
| Notion | @notionhq/notion-mcp-server | Workspace management |
| Slack | @anthropics/mcp-server-slack | Channel messaging |
| PostgreSQL | @modelcontextprotocol/server-postgres | Database queries |
| Puppeteer | @anthropics/mcp-server-puppeteer | Browser automation |
Key Rules
- MCP tools require
pip install google-adk[mcp]
- Stdio transport starts a local process — ensure the binary/npx package exists
- SSE transport connects to a running remote server
- Tool filtering prevents agents from accessing dangerous tools
- MCPToolset is async — works with
adk web, adk run, and Runner.run_async()
- Environment variables in
StdioServerParameters.env are passed to the MCP process
Related Skills
google-adk-function-tool — Custom function tools
google-adk-openapi-tool — REST API tools from OpenAPI specs