Install
Connect
import asyncio
from google.adk.tools.mcp_tool import MCPToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
MEWCP_API_KEY = "API_KEY"
async def main():
toolset = MCPToolset(
connection_params=StreamableHTTPConnectionParams(
url="https://gateway.mewcp.com/personal/mcp",
headers={"Authorization": f"Bearer {MEWCP_API_KEY}"},
)
)
tools = await toolset.get_tools()
print("Available tools:", [t.name for t in tools])
# -> ["search", "get_schema", "list_accounts", "call_tool"]
await toolset.close()
asyncio.run(main())
You get four tools rather than the tools of each app. Your agent uses them to reach every app you have connected. See How MewCP works.
Call a tool directly
call_tool = next(t for t in tools if t.name == "call_tool")
result = await call_tool.run_async(
args={
"server_maskedId": "google-calendar",
"tool_name": "list_events",
"args": {
"calendar_id": "primary",
"time_min": "2026-01-15T00:00:00Z",
"time_max": "2026-01-16T00:00:00Z",
},
},
tool_context=None,
)
print(result)
If you have connected more than one account for the same app, add "alias": "work" to select one.
Use with an LLM agent
Pass the toolset to an LlmAgent and ADK calls tools automatically based on the model's decisions:
from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool import MCPToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
toolset = MCPToolset(
connection_params=StreamableHTTPConnectionParams(
url="https://gateway.mewcp.com/personal/mcp",
headers={"Authorization": f"Bearer {MEWCP_API_KEY}"},
)
)
agent = LlmAgent(
model="gemini-2.0-flash",
name="assistant",
instruction="You are a helpful assistant with access to the user's connected apps.",
tools=[toolset],
)
B2B: per-user credential routing
To route calls for different audience members, use a header_provider callable instead of static headers:
MCPToolset(
connection_params=StreamableHTTPConnectionParams(
url="https://gateway.mewcp.com/personal/mcp",
),
header_provider=lambda ctx: {
"Authorization": f"Bearer {MEWCP_API_KEY}",
"x-mewcp-enduser-id": ctx.session.state["user_id"],
},
)
Where to find your values
| Value | Where to get it |
|---|
API_KEY | Dashboard -> API Keys |
| Connected apps | Dashboard -> Servers |
Last modified on