The Tavily MCP Server connects your ADK agent to Tavily’s AI-focused search, extraction, and crawling platform. This gives your agent the ability to perform real-time web searches, intelligently extract specific data from web pages, and crawl or create structured maps of websites.
Edit the my_agent/agent.py file to integrate Tavily. Choose either Remote MCP Server or Local MCP Server:
from google.adk.agents import Agentfrom google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPServerParamsfrom google.adk.tools.mcp_tool.mcp_toolset import MCPToolsetimport os# Get API key from environmentTAVILY_API_KEY = os.getenv("TAVILY_API_KEY")root_agent = Agent( model="gemini-2.5-pro", name="tavily_agent", instruction="You are a helpful assistant that uses Tavily to search the web, extract content, and explore websites. Use Tavily's tools to provide up-to-date information to users.", tools=[ MCPToolset( connection_params=StreamableHTTPServerParams( url="https://mcp.tavily.com/mcp/", headers={ "Authorization": f"Bearer {TAVILY_API_KEY}", }, ), ) ],)
Start the ADK web interface for a visual testing experience:
adk web --port 8000
Note: Run this command from the parent directory that contains your my_agent/ folder. For example, if your agent is inside agents/my_agent/, run adk web from the agents/ directory.This starts a web server with a chat interface. Access it at http://localhost:8000, select your agent from the dropdown, and start chatting.
Once your agent is set up and running, you can interact with it through the command-line interface or web interface. Here’s a simple example:User Query:
Find all documentation pages on tavily.com and provide instructions on how to get started with Tavily
The agent automatically combines multiple Tavily tools to provide comprehensive answers, making it easy to explore websites and gather information without manual navigation.