Web_Search_MCP

Web_Search_MCP

3.4

Web_Search_MCP is a Model Context Protocol server that integrates a web search tool using the Tavily API for real-time search capabilities.

The Web_Search_MCP project is designed to integrate a web search tool using the Tavily API with the Model Context Protocol (MCP) for seamless interaction with AI systems. It utilizes the FastMCP class to automatically generate tool definitions, making it easy to create and maintain MCP tools. The project also leverages Langchain's TavilySearchResults tool for efficient API interaction and uses Dotenv for secure management of environment variables. The core functionality is provided by the search_web tool, which accepts a search query and retrieves detailed web search results, including content, URLs, relevancy scores, and more. The results are returned in a structured JSON format, with robust error handling and asynchronous processing to handle multiple requests simultaneously.

Features

  • {'name': 'Web Search', 'description': 'Accepts a search query and retrieves relevant web search results using the Tavily API.'}
  • {'name': 'Detailed Results', 'description': 'Provides comprehensive information from search results, including content, URL, relevancy score, and more.'}
  • {'name': 'Formatted Output', 'description': 'Returns search results in a well-structured JSON format with status indicators and timestamps.'}
  • {'name': 'Error Handling', 'description': 'Handles errors gracefully during the search process and returns informative error messages.'}
  • {'name': 'Asynchronous Processing', 'description': 'Supports asynchronous processing to handle multiple requests simultaneously.'}

MCP Tools

  • search_web: A tool that accepts a search query and returns web search results in JSON format.

Usage with Different Platforms

claude_desktop


{
  "mcpServers": {
    "Mcp_Demo": {
      "command": "uv",
      "args": [
        "--directory",
        "path/Web_Search_MCP",
        "run",
        "main.py"
      ]
    }
  }
}

Frequently Asked Questions

What is the Tavily API?

The Tavily API is a powerful search API that provides real-time, comprehensive web search results, including answers, raw content, and relevant metadata.

How do I manage environment variables securely?

The project uses the Dotenv library to load environment variables from a .env file, securely managing sensitive information like API keys.

What is the role of FastMCP in this project?

FastMCP uses Python type hints and docstrings to automatically generate tool definitions, simplifying the creation and maintenance of MCP tools.