Deep Research with MCP (Interactions)

Give the Deep Research agent access to external tools via remote MCP servers. Pass server configs through mcp_servers; the type: "mcp_server" field is added automatically.

Only url is required. name, headers, and allowed_tools are optional. Custom Function Calling tools are not supported by Deep Research, but remote MCP servers are.

Code

1from kern.agent import Agent
2from kern.models.google import GeminiInteractions
3
4agent = Agent(
5 model=GeminiInteractions(
6 agent="deep-research-preview-04-2026",
7 thinking_summaries="auto",
8 mcp_servers=[
9 {
10 "name": "Deployment Tracker",
11 "url": "https://mcp.example.com/mcp",
12 "headers": {"Authorization": "Bearer my-token"},
13 # "allowed_tools": ["get_status"], # optionally restrict
14 }
15 ],
16 ),
17 markdown=True,
18)
19
20if __name__ == "__main__":
21 agent.print_response(
22 "Check the status of my last server deployment and summarize any issues."
23 )

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export GOOGLE_API_KEY=xxx

Install dependencies

1uv pip install -U "google-genai>=2.0" kern-ai

Run Agent

1python cookbook/90_models/google/gemini_interactions/deep_research_mcp.py