Tavily Search MCP server

Search and retrieve AI-enhanced web results via Tavily.
Back to servers
Setup instructions
Provider
RamXX
Release date
Dec 01, 2024
Language
Python
Package
Stats
14.1K downloads
68 stars

The Tavily MCP Server provides AI-powered web search capabilities through the Model Context Protocol, enabling large language models to perform sophisticated web searches, get direct answers to questions, and search recent news articles with AI-extracted content.

Installation

Prerequisites

  • Python 3.11 or later
  • A Tavily API key (obtain from Tavily's website)
  • uv Python package manager (recommended)

Installing the Package

Option 1: Using pip or uv

# With pip
pip install mcp-tavily

# Or with uv (recommended)
uv add mcp-tavily

Option 2: From source

# Clone the repository
git clone https://github.com/RamXX/mcp-tavily.git
cd mcp-tavily

# Create a virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies and build
uv sync  # Or: pip install -r requirements.txt
uv build  # Or: pip install -e .

VS Code Installation

For quick installation in VS Code, add the following configuration to your User Settings (JSON) file:

{
  "mcp": {
    "inputs": [
      {
        "type": "promptString",
        "id": "apiKey",
        "description": "Tavily API Key",
        "password": true
      }
    ],
    "servers": {
      "tavily": {
        "command": "uvx",
        "args": ["mcp-tavily"],
        "env": {
          "TAVILY_API_KEY": "${input:apiKey}"
        }
      }
    }
  }
}

Configuration

API Key Setup

The server requires a Tavily API key, which can be provided in three ways:

  1. Through a .env file in your project directory:

    TAVILY_API_KEY=your_api_key_here
    
  2. As an environment variable:

    export TAVILY_API_KEY=your_api_key_here
    
  3. As a command-line argument:

    python -m mcp_server_tavily --api-key=your_api_key_here
    

Configure for Claude.app

Add to your Claude settings:

"mcpServers": {
  "tavily": {
    "command": "python",
    "args": ["-m", "mcp_server_tavily"]
  },
  "env": {
    "TAVILY_API_KEY": "your_api_key_here"
  }
}

Features and Usage

Available Tools

Web Search

  • Tool name: tavily_web_search
  • Description: Performs comprehensive web searches with AI-powered content extraction
  • Parameters:
    • query (string, required): Search query
    • max_results (integer, optional): Maximum number of results (default: 5, max: 20)
    • search_depth (string, optional): "basic" or "advanced" (default: "basic")
    • include_domains (list or string, optional): Domains to include
    • exclude_domains (list or string, optional): Domains to exclude

Answer Search

  • Tool name: tavily_answer_search
  • Description: Performs web searches and generates direct answers with supporting evidence
  • Parameters:
    • query (string, required): Search query
    • max_results (integer, optional): Maximum number of results (default: 5, max: 20)
    • search_depth (string, optional): "basic" or "advanced" (default: "advanced")
    • include_domains (list or string, optional): Domains to include
    • exclude_domains (list or string, optional): Domains to exclude

News Search

  • Tool name: tavily_news_search
  • Description: Searches recent news articles with publication dates
  • Parameters:
    • query (string, required): Search query
    • max_results (integer, optional): Maximum number of results (default: 5, max: 20)
    • days (integer, optional): Number of days back to search (default: 3)
    • include_domains (list or string, optional): Domains to include
    • exclude_domains (list or string, optional): Domains to exclude

Usage Examples

Regular web search:

Tell me about Anthropic's newly released MCP protocol

Generate a report with domain filtering:

Tell me about redwood trees. Please use MLA format in markdown syntax and include the URLs in the citations. Exclude Wikipedia sources.

Direct answer search:

I want a concrete answer backed by current web sources: What is the average lifespan of redwood trees?

News search:

Give me the top 10 AI-related news in the last 5 days

Docker Deployment

Building and Running with Docker

Build the Docker image:

docker build -t mcp_tavily .

Run a container:

docker run -d --name mcp_tavily_container \
  -e TAVILY_API_KEY=your_api_key_here \
  -p 8000:8000 mcp_tavily

Stop and remove the container:

docker stop mcp_tavily_container
docker rm mcp_tavily_container

Debugging

Use the MCP inspector to debug the server:

# Using npx
npx @modelcontextprotocol/inspector python -m mcp_server_tavily

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "tavily" '{"command":"uvx","args":["mcp-tavily"],"env":{"TAVILY_API_KEY":"${input:apiKey}"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "tavily": {
            "command": "uvx",
            "args": [
                "mcp-tavily"
            ],
            "env": {
                "TAVILY_API_KEY": "${input:apiKey}"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "tavily": {
            "command": "uvx",
            "args": [
                "mcp-tavily"
            ],
            "env": {
                "TAVILY_API_KEY": "${input:apiKey}"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later