Tavily Search MCP server

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

The Tavily MCP server provides AI-powered web search capabilities through a Model Context Protocol (MCP) interface. It enables language models to perform sophisticated web searches, get direct answers to questions, and search recent news articles with AI-extracted relevant content.

Installation Options

Using Package Managers

You can quickly install the MCP Tavily server using pip or uv:

# With pip
pip install mcp-tavily

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

Installing 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 .

Docker Installation

# 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

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
    

VS Code Configuration

For manual installation, add the following JSON block to your User Settings in VS Code:

{
  "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}"
        }
      }
    }
  }
}

Claude.app Configuration

Add to your Claude settings:

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

Available Tools

Web Search

The tavily_web_search tool performs comprehensive web searches with AI-powered content extraction:

  • query (string, required): Search query
  • max_results (integer, optional): Maximum number of results to return (default: 5, max: 20)
  • search_depth (string, optional): Either "basic" or "advanced" search depth (default: "basic")
  • include_domains (list or string, optional): List of domains to specifically include in results
  • exclude_domains (list or string, optional): List of domains to exclude from results

Answer Search

The tavily_answer_search tool performs web searches and generates direct answers with supporting evidence:

  • query (string, required): Search query
  • max_results (integer, optional): Maximum number of results to return (default: 5, max: 20)
  • search_depth (string, optional): Either "basic" or "advanced" search depth (default: "advanced")
  • include_domains (list or string, optional): List of domains to specifically include in results
  • exclude_domains (list or string, optional): List of domains to exclude from results

News Search

The tavily_news_search tool searches recent news articles with publication dates:

  • query (string, required): Search query
  • max_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 specifically include in results
  • exclude_domains (list or string, optional): List of domains to exclude from results

Usage Examples

Regular Web Search

Tell me about Anthropic's newly released MCP protocol

Domain-Filtered Report

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

Direct Answer with Evidence

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

Recent News Search

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

Debugging

You can use the MCP inspector to debug the server:

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

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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