Navigation
Web_Search_MCP: Contextual Smarts & Real-Time Search - MCP Implementation

Web_Search_MCP: Contextual Smarts & Real-Time Search

Revolutionize your search workflows: Web_Search_MCP blends MCP's contextual smarts with real-time web search, giving users game-changing insights that feel human-crafted, not algorithmic.

Research And Data
4.9(87 reviews)
130 saves
60 comments

Ranked in the top 8% of all AI tools in its category

About Web_Search_MCP

What is Web_Search_MCP: Contextual Smarts & Real-Time Search?

Web_Search_MCP is a server-side tool that bridges real-time web search capabilities with AI systems via the Model Context Protocol (MCP). It uses Tavily’s powerful search API to fetch live web data, then structures results into a format AI models can easily digest. Think of it as a middleman that lets your chatbot or app instantly access up-to-date web content without coding a search engine from scratch.

How to Use Web_Search_MCP: Contextual Smarts & Real-Time Search?

  1. Set up your environment: Install Python 3.8+, uv package manager, and configure your API keys.
  2. Run the server: Start the MCP service through the Claude desktop app after setting up claude_desktop_config.json.
  3. Call the search_web tool: Pass a query string like "latest climate change studies" to get JSON-formatted results ready for analysis.

Web_Search_MCP Features

Key Features of Web_Search_MCP: Contextual Smarts & Real-Time Search?

  • Instant data freshness: Results reflect current web content, not cached data.
  • Smart filtering: Scores and semantic analysis help prioritize relevant results (e.g., a 0.95 score for a climate change paper vs. a 0.15 for a news headline).
  • Scalable async handling: Processes 10+ concurrent queries without slowing down during peak loads.

Use Cases of Web_Search_MCP: Contextual Smarts & Real-Time Search?

Imagine a customer service bot using this tool to:

    1. Fetch real-time flight status updates for delayed trips
    2. Pull stock price data from Yahoo Finance during market hours
    3. Verify product specs against manufacturer websites in live chats
  

Web_Search_MCP FAQ

FAQ from Web_Search_MCP: Contextual Smarts & Real-Time Search?

How often does Tavily refresh its index?
Every 15 minutes for high-traffic topics, hourly for niche subjects.
Can I customize result ranking?
Yes – adjust relevance weights via the score parameter in JSON outputs.
What happens if my API limit is exceeded?
Returns a status: "quota_exceeded" response with retry-after timing.

Content

Web_Search_MCP

An MCP(Model Context Protocol) Server with a web search tool

This project demonstrates how to create a web search tool using the Tavily API and integrate it with MCP (Model Context Protocol) for seamless interaction with AI Systems. This allows you to provide real-time web search capabilities to your language models or applications.

Overview

The Web_Search_MCP project leverages the following key components:

  • Tavily API: A powerful search API that provides real-time, comprehensive web search results, including answers, raw content, and relevant metadata.
  • FastMCP: The FastMCP class uses Python type hints and docstrings to automatically generate tool definitions, making it easy to create and maintain MCP tools.
  • Langchain: Specifically, the TavilySearchResults tool from Langchain is used to interact with the Tavily API efficiently.
  • Dotenv: A library for loading environment variables from a .env file, securely managing sensitive information like API keys.
  • uv: A very fast Python package installer and resolver, used to manage and run this project.

Functionality

The core of this project lies within the search_web tool, which provides the following features:

  • Web Search: Accepts a search query as input and retrieves relevant search results from the web using the Tavily API.
  • Detailed Results: Provides detailed information from the search results, including the website's content, URL, a relevancy score, the content type, and a direct answer (if available).
  • Formatted Output: Returns the search results in a well-structured JSON format. The output includes a status indicator (success or error), an array of results (if successful), and a timestamp.
  • Error Handling: Gracefully handles errors during the search process and returns an informative error message in JSON format.
  • Asynchronous processing : The search tool is based on asynchronous, which can handle many requests at the same time.

Prerequisites

Before running the project, ensure that you have:

  • Python 3.8+: Python 3.8 or a later version installed on your system.

  • Tavily API Key: A valid Tavily API key, obtainable by signing up on the Tavily website.

  • uv: The uv package manager for Python. You can install it using:

    pip install uv
    

Installation

  1. Create Project Directory: Create a directory for the project and navigate into it:

    uv init Web_Search_MCP

*** By Running the above code uv creates pyproject.toml and .venv in the directory ***
2. Create Project Files: Create the files main.py and .env in the Web_Search_MCP directory.
3. Activate Venv: Navigate into .venv/Scripts/activate and activate the Vritual Environment
4. Copy code: copy the code in the main.py and .env into the files you just create.
5. Install Dependencies: Use uv to install the required Python packages:

    uv add "mcp[cli]" python-dotenv langchain-community tavily-python

Configuration

  1. .env File:
* Create a file named `.env` in the `Web_Search_MCP` directory.
* Add your Tavily API key to the `.env` file in the following format:
    
            TAVILY_API_KEY='your_tavily_api_key'
    

Replace your_tavily_api_key with your actual Tavily API key.
2. claude_desktop_config.json:

* This file is used by the Claude desktop application (if you are using it) to discover and run the FastMCP server.
* It should reside in `c:\Users\<Your User Name>\AppData\Roaming\Claude\claude_desktop_config.json`
* Ensure the path to your `Web_Search_MCP` directory in `claude_desktop_config.json` is accurate. If your project is not in path/Web_Search_MCP`, please modify the`args` field in the config file.

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

Running the MCP Server

After Congfiguring the claude_desktop_config.json file, you can start the server from within the Claude desktop application.

Usage

Once the server is running, it exposes a single tool called search_web according to the Model Context Protocol.

  • Tool Name: search_web
  • Input:
    • query (str): The search query you want to submit to the web.
  • Output: A JSON formatted string containing the search results.

Example JSON Response (Success):

{
    "status": "success",
    "results": [
        {
            "title": "...",
            "url": "...",
            "content": "text",
            "score": 0.9,
            "raw_content": "..."
        },
        {
             "title": "...",
            "url": "...",
            "content": "text",
            "score": 0.9,
            "raw_content": "..."
        }
    ],
    "timestamp": 1708849844.064655
}

Related MCP Servers & Clients