web-search MCP Server

repository·main·Indexed 19 days ago

https://github.com/pskill9/web-search

A Model Context Protocol (MCP) server that enables free web searching using Google search results without requiring API keys. It provides a `search` tool that accepts a query and an optional limit (1-10), returning a list of results containing titles, URLs, and descriptions.

Tokens
1.1K
Snippets
6
Records
7
Agent score
16%

What's inside web-search

  1. Install and build the Web Search MCP Server

    main

    To use the Web Search MCP Server, you must first clone or download the repository, install the necessary dependencies, and build the project using npm.

    Follow these steps:

    1. Clone or download the repository.
    2. Run npm install to install dependencies.
    3. Run npm run build to compile the server.
    npm install
    npm run build
  2. Configure the Web Search MCP Server in VSCode or Claude Desktop

    main

    After building the server, add it to your MCP configuration file. You must provide the absolute path to the build/index.js file in the args array.

    Both VSCode (Claude Dev Extension) and Claude Desktop use the same configuration format.

    {
      "mcpServers": {
        "web-search": {
          "command": "node",
          "args": ["/path/to/web-search/build/index.js"]
        }
      }
    }
  3. Avoid rate limiting and issues with Web Search

    main

    Because this server uses web scraping of Google search results, be aware of the following limitations:

    Rate Limiting

    Google may temporarily block requests if searches are performed too frequently. To mitigate this:

    • Keep searches to a reasonable frequency.
    • Use the limit parameter judiciously.
    • Implement delays between searches if necessary.

    Accuracy and Reliability

    • The tool depends on Google's HTML structure; changes to Google's layout may break functionality.
    • Some results may lack descriptions or metadata.
    • Complex search operators may not function as expected.
    • This tool is intended for personal use. Always respect Google's terms of service.
  4. Use the `search` tool

    main

    The server exposes a single tool named search. This tool allows you to perform web searches using Google results without requiring an API key.

    Parameters

    • query (string): The search query you want to execute.
    • limit (number, optional): The number of results to return. The default is 5, and the maximum allowed is 10.
    use_mcp_tool({
      server_name: "web-search",
      tool_name: "search",
      arguments: {
        query: "your search query",
        limit: 3
      }
    })
  5. Understand the `search` tool response format

    main

    The search tool returns an array of objects representing the search results. Each object contains the following fields:

    • title: The title of the search result.
    • url: The web address of the result.
    • description: A brief description or snippet from the page.
    [
      {
        "title": "Example Search Result",
        "url": "https://example.com",
        "description": "Description of the search result..."
      }
    ]
  6. Run the Web Search MCP Server via stdio

    main

    The WebSearchServer class is designed to run using the StdioServerTransport. This allows it to communicate with MCP clients (like Claude Desktop) via standard input/output.

    To start the server, the run() method must be called. The server logs its status to stderr to avoid interfering with the stdout communication channel used by the MCP protocol.

    const server = new WebSearchServer();
    await server.run();
  7. Use the 'search' tool in Web Search MCP Server

    main

    The web-search MCP server provides a search tool that allows users to perform web searches using Google without requiring an API key. The tool returns a JSON array of search results containing titles, URLs, and descriptions.

    Tool Definition

    • Name: search
    • Description: Search the web using Google (no API key required)
    • Input Schema:
      • query (string, required): The search query to execute.
      • limit (number, optional): The maximum number of results to return.
        • Constraints: Minimum 1, Maximum 10.
        • Default: 5.

    Output Format

    The tool returns a JSON stringified array of SearchResult objects:

    [
      {
        "title": "Result Title",
        "url": "https://example.com",
        "description": "Result snippet or description"
      }
    ]
    {
      "name": "search",
      "arguments": {
        "query": "how to use MCP",
        "limit": 3
      }
    }