MCP HubMCP Hub
kshern

mcp-tavily

by: kshern

mcp server of tavily

3created 23/02/2025
Visit
tavily

📌Overview

Purpose: To implement a Model Context Protocol (MCP) server for the Tavily API, enabling advanced search and content extraction functionalities.

Overview: The MCP Tavily server enhances the capabilities of the Tavily API by offering diverse search tools and robust content extraction options. It is designed to provide users with relevant information quickly and efficiently, especially in various content contexts.

Key Features:

  • Multiple Search Tools:

    • search: Offers basic search functionality with customizable options for various needs.
    • searchContext: Facilitates context-aware searches that enhance relevance based on user queries.
    • searchQNA: Specialized tool for question-and-answer searches, providing direct responses to user inquiries.
  • Content Extraction: Allows for the extraction of content from URLs with flexible configurability, making it ideal for gathering information from different sources.

  • Rich Configuration Options: Provides extensive settings for search depth, filtering, and inclusion criteria, enhancing user control over search results and extracted content.


MCP Tavily

A Model Context Protocol (MCP) server implementation for the Tavily API, providing advanced search and content extraction capabilities.

Features

  • Multiple Search Tools:
    • search: Basic search functionality with customizable options.
    • searchContext: Context-aware search for better relevance.
    • searchQNA: Question and answer focused search.
  • Content Extraction: Extract content from URLs with configurable options.
  • Rich Configuration Options: Extensive options for search depth, filtering, and content inclusion.

Usage with MCP

Add the Tavily MCP server to your MCP configuration:

{
  "mcpServers": {
    "tavily": {
      "command": "npx",
      "args": ["-y", "@mcptools/mcp-tavily"],
      "env": {
        "TAVILY_API_KEY": "your-api-key"
      }
    }
  }
}

Make sure to replace your-api-key with your actual Tavily API key, or set the environment variable TAVILY_API_KEY before running the server.

API Reference

Search Tools

The server provides three search tools accessible via MCP:

1. Basic Search (search)

{
  query: "artificial intelligence",
  options: {
    searchDepth: "advanced",
    topic: "news",
    maxResults: 10
  }
}

2. Context Search (searchContext)

{
  query: "latest developments in AI",
  options: {
    topic: "news",
    timeRange: "week"
  }
}

3. Q&A Search (searchQNA)

{
  query: "What is quantum computing?",
  options: {
    includeAnswer: true,
    maxResults: 5
  }
}

Extract Tool (extract)

{
  urls: ["https://example.com/article1", "https://example.com/article2"],
  options: {
    extractDepth: "advanced",
    includeImages: true
  }
}

Search Options

All search tools share these options:

interface SearchOptions {
  searchDepth?: "basic" | "advanced";
  topic?: "general" | "news" | "finance";
  days?: number;
  maxResults?: number;
  includeImages?: boolean;
  includeImageDescriptions?: boolean;
  includeAnswer?: boolean;
  includeRawContent?: boolean;
  includeDomains?: string[];
  excludeDomains?: string[];
  maxTokens?: number;
  timeRange?: "year" | "month" | "week" | "day" | "y" | "m" | "w" | "d";
}

Extract Options

interface ExtractOptions {
  extractDepth?: "basic" | "advanced";
  includeImages?: boolean;
}

Response Format

All tools return responses in the following format:

{
  content: Array<{
    type: "text",
    text: string
  }>
}
  • Search results items include: Title, Content, URL.
  • Extracted content items include: URL, Raw content, and a list of failed URLs (if any).

Error Handling

All tools include proper error handling and will throw descriptive error messages if an error occurs.

Installation

Installing via Smithery

Automatically install Tavily API Server for Claude Desktop:

npx -y @smithery/cli install @kshern/mcp-tavily --client claude

Manual Installation

npm install @mcptools/mcp-tavily

Or use it directly with npx:

npx @mcptools/mcp-tavily

Prerequisites

  • Node.js 16 or higher
  • npm or yarn
  • Tavily API key (get one from Tavily)

Setup

  1. Clone the repository.
  2. Install dependencies:
npm install
  1. Set your Tavily API key:
export TAVILY_API_KEY=your_api_key

Building

npm run build

Debugging with MCP Inspector

We recommend using MCP Inspector for development and debugging MCP servers. It provides a user interface for:

  • Testing tool calls.
  • Viewing server responses.
  • Debugging tool execution.
  • Monitoring server state.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

License

This project is licensed under the MIT License.

Support

For questions or issues: