Mcp Tavily
Groq + Tavily MCP: Real-Time Search
This notebook is designed for Python developers who want to empower Groq inference with real-time web access, enabling Groq models to utilize up-to-date information as context via Tavily's Model Context Protocol (MCP) server that will give models access to various tools. Live web information is critical for AI agents tasked with performing research, monitoring trends, or generating context-aware responses.
We will achieve this through three simple steps:
- Set up Groq MCP client for fast inference.
- Set up Tavily MCP server for web search, web scraping, and web crawling.
- Seemlessly connect the client to the server through the Responses API.
Getting Started
Follow these steps to set up:
- Sign up for Tavily at app.tavily.com to get your free API key.
- Sign up for Groq at console.groq.com to get your free API key.
- Copy your API keys from your Tavily and Groq account dashboards.
- Paste your API keys into the cell below and run the cell.
Groq API key configured successfully! Tavily API key configured successfully!
Select the foundation model to power inference. Let's try OpenAI's flagship open-weight MoE model, gpt-oss-120b, available via Groq for fast inference.
Step 1: Set up the Groq client
Step 2: Set up Tavily's remote MCP server
Step 3: Connect Groq to the Tavily MCP through Groq's OpenAI-compatible Responses API
Let's implement a helper function to display MCP tool calls and their results. This will provide transparency into which tools were called, their arguments, and outputs.
Examples
Note: Some queries may consume more tokens than others depending on the amount of tool calls the model makes. Please be aware of various rate limits that are tied to your API keys if you happen to run into any rate limit errors.
Demo 1: AI startup funding announcements
Let's display the agent's response in markdown format.
Let's examine the agent's intermediate steps, including how it calls different tools and configures tool arguments such as search_depth, time_range, max_results, and more.
TAVILY MCP CALLS: Found 2 tool call(s):
--------------------------------------------------
Tool Call #1
Type: mcp
Tool Name: tavily_search
Server: tavily
Arguments: {'max_results': 10, 'query': 'AI startup funding announcements September 2025', 'search_depth': 'advanced', 'time_range': 'month'}
Output: {'query': 'AI startup funding announcements September 2025', 'follow_up_questions': None, 'answer': None, 'images': [], 'results': [{'url': 'https://intellizence.com/insights/startup-funding/weekly-to...
Tool Call #2
Type: mcp
Tool Name: tavily_extract
Server: tavily
Arguments: {'format': 'markdown', 'urls': ['https://theaiworld.org/news/ai-startups-secure-major-funding-in-september-2025-signaling-global-innovation-surge', 'https://www.crescendo.ai/news/latest-vc-investment-deals-in-ai-startups', 'https://news.crunchbase.com/venture/big-dollar-ai-investors-2025-softbank/', 'https://www.reuters.com/business/robotics-startup-figure-valued-39-billion-latest-funding-round-2025-09-16/']}
Output: {'results': [{'url': 'https://theaiworld.org/news/ai-startups-secure-major-funding-in-september-2025-signaling-global-innovation-surge', 'raw_content': '[## The AI World](/)\n\n# AI Startups Secure Ma...
Total time: 13.48 seconds
Tavily MCP calls: 2
Demo 2: Product Search
Let's display the agent's response in markdown format.
Let's examine the agent's intermediate steps.
TAVILY MCP CALLS: Found 3 tool call(s):
--------------------------------------------------
Tool Call #1
Type: mcp
Tool Name: tavily_search
Server: tavily
Arguments: {'max_results': 10, 'query': 'iPhone models currently available on apple.com', 'search_depth': 'basic', 'top_k': 10, 'topic': 'general'}
Could not parse tool data: Expecting value: line 1 column 1 (char 0)
Tool Call #2
Type: mcp
Tool Name: tavily_search
Server: tavily
Arguments: {'max_results': 10, 'query': 'iPhone models currently available on apple.com', 'search_depth': 'basic', 'topic': 'general'}
Output: {'query': 'iPhone models currently available on apple.com', 'follow_up_questions': None, 'answer': None, 'images': [], 'results': [{'url': 'https://www.apple.com/in/iphone/compare/', 'title': 'Compare...
Tool Call #3
Type: mcp
Tool Name: tavily_extract
Server: tavily
Arguments: {'extract_depth': 'basic', 'format': 'markdown', 'urls': ['https://www.apple.com/in/iphone/compare/']}
Output: {'results': [{'url': 'https://www.apple.com/in/iphone/compare/', 'raw_content': 'Get iPhone 16 from just ₹12483.00/mo. for up to 6 mo.[‡](#footnote*-1) with No Cost EMI and instant cashback. [Buy](/in...
Total time: 11.66 seconds
Tavily MCP calls: 3
Demo 3: Try it Yourself
Now it's your turn! Replace the query with some real time information you want to discover.