Connecting MCP Tool Servers to ADK Agents
Connect Google ADK agents to Model Context Protocol (MCP) tool servers to seamlessly access pre-built integrations like SQLite, GitHub, Slack, and Google Drive without writing custom wrappers.
Published on • 2026-07-30
AI Assistant

The Model Context Protocol (MCP) is an open standard designed to decouple AI tool providers from AI framework consumers. Instead of writing custom Python adapters or function wrappers for every third-party service—such as databases, GitHub APIs, or cloud storage—you can instantly connect your Google ADK agent to any standardized MCP tool server via stdio, HTTP, or WebSockets.
In this guide, we will explore why MCP is transforming tool ecosystems and step through a complete Python code example connecting an ADK agent to an MCP SQLite server.
Why MCP Matters: Standardized vs. Custom Wrappers
Before MCP, extending an agent with external capabilities required writing service-specific wrapper code:
- Want your agent to execute SQL queries on PostgreSQL? Write a custom
FunctionTool. - Want to read files from Google Drive? Write another
FunctionTool. - Want to post messages to Slack? Write yet another wrapper.
This approach creates fragile, high-maintenance codebases. MCP solves this fragmentation by establishing a standard protocol: tool servers expose available functions and schemas dynamically, and agent harnesses consume them generically without service-specific glue code.
flowchart LR
A["ADK Agent Harness"]
subgraph MCP["MCP Servers"]
direction TB
B["SQLite MCP Server"]
C["GitHub MCP Server"]
D["Slack MCP Server"]
end
A <-->|"Standardized MCP Protocol"| B
A <-->|"Standardized MCP Protocol"| C
A <-->|"Standardized MCP Protocol"| D
classDef orchestrator fill:#e0f2fe,stroke:#0284c7,stroke-width:2px,color:#0f172a;
classDef server fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#0f172a;
class A orchestrator;
class B,C,D server;
style MCP fill:#f9fafb,stroke:#94a3b8,stroke-width:1.5px,stroke-dasharray:5 5;
Connecting an MCP Server via Stdio in Google ADK
In Google ADK, the MCPTool class manages connection lifecycles, handles tool discovery, and exposes distant MCP tools natively to the agent core.
Below is a complete recipe connecting an ADK agent to a SQLite database using the official @modelcontextprotocol/server-sqlite package via subprocess stdio:
import asyncio
from google.adk.agents import Agent
from google.adk.tools.mcp_tool import MCPTool
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
async def main():
# 1. Initialize MCP Stdio Connection Subprocess
mcp_tool_provider = MCPTool(
command="npx",
args=["-y", "@modelcontextprotocol/server-sqlite", "--db-path", "test.db"]
)
# Connect to server and dynamically load exposed tool schemas
await mcp_tool_provider.connect()
try:
# 2. Attach MCP Tools directly to the ADK Agent
agent = Agent(
name="database_analyst_agent",
model="gemini-2.5-flash",
instruction=(
"You are a database analyst assistant. "
"Use the provided SQLite MCP tools to inspect schemas and run queries."
),
tools=[mcp_tool_provider]
)
session_service = InMemorySessionService()
runner = Runner(agent=agent, session_service=session_service)
# 3. Prompt the agent to utilize MCP tools
response = await runner.run_async(
session_id="mcp-demo-session",
message="List all user tables in the SQLite database."
)
print("\n--- Agent Response ---")
print(response.text)
finally:
# 4. Gracefully close the MCP subprocess connection
await mcp_tool_provider.close()
if __name__ == "__main__":
asyncio.run(main())
Step-by-Step Mechanics
Here is what happens during execution:
- Subprocess Spawning:
MCPToollaunches the target MCP server command (npx -y @modelcontextprotocol/server-sqlite --db-path test.db). - Protocol Discovery (
connect()): ADK queries the MCP server’s capability endpoint. The server returns JSON schemas for functions likeread_query,write_query, anddescribe_table. - Seamless Function Registration: ADK registers these dynamic functions into the
Agent’s tool definitions. From Gemini’s perspective, these tools look identical to nativeFunctionToolobjects. - Execution & Cleanup: Tool call payloads are serialized into JSON-RPC messages sent across stdio. Upon turn completion,
mcp_tool_provider.close()cleanly terminates the child process.
The Open-Source MCP Ecosystem
By adopting MCP in your ADK harness, you unlock access to an ever-growing ecosystem of production-ready tool servers:
| MCP Server | Exposed Capabilities |
|---|---|
| SQLite / Postgres | Database schema discovery, SQL execution, table inspection |
| GitHub | Repository search, pull request creation, issue management |
| Slack | Channel messaging, thread replies, user lookup |
| Google Drive | Document listing, file search, content extraction |
| Filesystem | Secure local file operations with path restriction sandboxes |
| Puppeteer / Playwright | Web scraping, visual screenshot rendering, DOM interaction |
When to Use FunctionTool vs. MCPTool
| Integration Need | Recommended Approach | Rationale |
|---|---|---|
| Custom in-memory logic or local state | FunctionTool | Simple Python functions without external binary overhead. |
| Proprietary internal business logic | FunctionTool | Keeps confidential business logic tightly integrated in codebase. |
| Third-party SaaS or database access | MCPTool | Leverages maintained, community-standard integrations. |
| Multi-language agent architectures | MCPTool | Allows Python agents to consume tool servers written in Node.js, Go, or Rust. |
Key Takeaway
Integrating Model Context Protocol (MCPTool) into your Google ADK harness frees your team from writing custom tool wrappers for standard infrastructure. Connect once via stdio or HTTP, dynamically discover tools, and allow your Gemini-powered agents to operate across existing enterprise software ecosystems effortlessly.