mcp-tavily
by: RamXX
An MCP server for Tavily's search API
📌Overview
Purpose: To provide AI-powered web search capabilities through a Model Context Protocol server utilizing Tavily's search API.
Overview: The Tavily MCP Server enhances the capability of language models to perform advanced web searches, retrieve direct answers, and access recent news content with relevant AI-extracted data. It serves as a bridge between AI models and comprehensive web search functionalities.
Key Features:
-
tavily_web_search: Enables comprehensive web searches, extracting AI-powered content to provide relevant information based on user queries.
-
tavily_answer_search: Performs searches and generates direct answers supported by evidence, effectively addressing user inquiries for precise information.
-
tavily_news_search: Facilitates the retrieval of recent news articles, allowing users to stay updated on current events by searching through a specified time frame.
Tavily MCP Server
A Model Context Protocol server that provides AI-powered web search capabilities using Tavily's search API. This server enables LLMs to perform sophisticated web searches, get direct answers to questions, and search recent news articles with AI-extracted relevant content.
Features
Available Tools
-
tavily_web_search
: Performs comprehensive web searches with AI-powered content extraction.query
(string, required): Search querymax_results
(integer, optional): Maximum number of results to return (default: 5, max: 20)search_depth
(string, optional): "basic" or "advanced" search depth (default: "basic")include_domains
(list or string, optional): List of domains to includeexclude_domains
(list or string, optional): List of domains to exclude
-
tavily_answer_search
: Performs web searches and generates direct answers with supporting evidence.query
(string, required): Search querymax_results
(integer, optional): Maximum number of results to return (default: 5, max: 20)search_depth
(string, optional): "basic" or "advanced" search depth (default: "advanced")include_domains
(list or string, optional): List of domains to includeexclude_domains
(list or string, optional): List of domains to exclude
-
tavily_news_search
: Searches recent news articles with publication dates.query
(string, required): Search querymax_results
(integer, optional): Maximum number of results to return (default: 5, max: 20)days
(integer, optional): Number of days back to search (default: 3)include_domains
(list or string, optional): List of domains to includeexclude_domains
(list or string, optional): List of domains to exclude
Prompts
- tavily_web_search: Search the web using Tavily's AI-powered search engine
- tavily_answer_search: Search the web and get an AI-generated answer with supporting evidence
- tavily_news_search: Search recent news articles
Prerequisites
- Python 3.11 or later
- A Tavily API key
uv
Python package manager (recommended)
Installation
Option 1: Using pip or uv
pip install mcp-tavily
# Or with uv (recommended)
uv add mcp-tavily
Option 2: From source
git clone <repository-url>
cd mcp-tavily
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv sync # Or: pip install -r requirements.txt
uv build # Or: pip install -e .
Configuration
API Key Setup
The server requires a Tavily API key, which can be provided in three ways:
- Through a
.env
file:TAVILY_API_KEY=your_api_key_here
- As an environment variable:
export TAVILY_API_KEY=your_api_key_here
- As a command-line argument:
python -m mcp_server_tavily --api-key=your_api_key_here
Usage Examples
- Regular web search:
Tell me about Anthropic's newly released MCP protocol
- Report with domain filtering:
Tell me about redwood trees. Exclude Wikipedia sources.
- Answer search mode:
What is the average lifespan of redwood trees?
- News search:
Give me the top 10 AI-related news in the last 5 days
Testing
To run the tests:
-
Install test dependencies:
source .venv/bin/activate # If using a virtual environment uv sync --dev # Or: pip install -r requirements-dev.txt
-
Run the tests:
./tests/run_tests.sh
Debugging
Use the MCP inspector to debug the server:
npx @modelcontextprotocol/inspector python -m mcp_server_tavily
Contributing
To contribute:
- Fork the repository
- Create a feature branch
- Make changes
- Run tests
- Commit changes
- Push to the branch
- Open a Pull Request
License
mcp-tavily is licensed under the MIT License. See the LICENSE file for details.