WebSearch (Google) MCP server

Provides real-time web search capabilities via a dedicated crawler service with configurable result limits, language filtering, and domain rules
Back to servers
Setup instructions
Provider
Manh La
Release date
Mar 25, 2025
Language
TypeScript
Package
Stats
859 downloads
13 stars

This MCP server provides web search functionality for AI assistants supporting the Model Context Protocol (MCP). It connects to a WebSearch Crawler API to retrieve up-to-date search results directly through a standardized interface.

Installation

You can install the WebSearch MCP server using npm:

npm install -g websearch-mcp

Or use it without installation:

npx websearch-mcp

For automatic installation via Smithery (recommended for Claude Desktop users):

npx -y @smithery/cli install @mnhlt/WebSearch-MCP --client claude

Configuration

Configure the server using environment variables:

# Configure API URL
API_URL=https://crawler.example.com npx websearch-mcp

# Configure maximum search results
MAX_SEARCH_RESULT=10 npx websearch-mcp

# Configure both
API_URL=https://crawler.example.com MAX_SEARCH_RESULT=10 npx websearch-mcp

Available environment variables:

  • API_URL: URL of the WebSearch Crawler API (default: http://localhost:3001)
  • MAX_SEARCH_RESULT: Maximum number of search results to return (default: 5)

Setting Up the Crawler Service

The WebSearch MCP server requires a crawler service to perform web searches.

Prerequisites

  • Docker and Docker Compose

Starting the Crawler Service

  1. Create a file named docker-compose.yml with the following content:
version: '3.8'

services:
  crawler:
    image: laituanmanh/websearch-crawler:latest
    container_name: websearch-api
    restart: unless-stopped
    ports:
      - "3001:3001"
    environment:
      - NODE_ENV=production
      - PORT=3001
      - LOG_LEVEL=info
      - FLARESOLVERR_URL=http://flaresolverr:8191/v1
    depends_on:
      - flaresolverr
    volumes:
      - crawler_storage:/app/storage

  flaresolverr:
    image: 21hsmw/flaresolverr:nodriver
    container_name: flaresolverr
    restart: unless-stopped
    environment:
      - LOG_LEVEL=info
      - TZ=UTC

volumes:
  crawler_storage:

For Mac Apple Silicon, use:

version: '3.8'

services:
  crawler:
    image: laituanmanh/websearch-crawler:latest
    container_name: websearch-api
    platform: "linux/amd64"
    restart: unless-stopped
    ports:
      - "3001:3001"
    environment:
      - NODE_ENV=production
      - PORT=3001
      - LOG_LEVEL=info
      - FLARESOLVERR_URL=http://flaresolverr:8191/v1
    depends_on:
      - flaresolverr
    volumes:
      - crawler_storage:/app/storage

  flaresolverr:
    image: 21hsmw/flaresolverr:nodriver
    platform: "linux/arm64"
    container_name: flaresolverr
    restart: unless-stopped
    environment:
      - LOG_LEVEL=info
      - TZ=UTC

volumes:
  crawler_storage:
  1. Start the services:
docker-compose up -d
  1. Verify the services are running:
docker-compose ps
  1. Test the crawler API health endpoint:
curl http://localhost:3001/health

Expected response:

{
  "status": "ok",
  "details": {
    "status": "ok",
    "flaresolverr": true,
    "google": true,
    "message": null
  }
}

Testing the Crawler API

Test the crawler API directly:

curl -X POST http://localhost:3001/crawl \
  -H "Content-Type: application/json" \
  -d '{
    "query": "typescript best practices",
    "numResults": 2,
    "language": "en",
    "filters": {
      "excludeDomains": ["youtube.com"],
      "resultType": "all" 
    }
  }'

Integrating with MCP Clients

MCP Configuration Reference

Use this configuration for your MCP clients:

{
    "mcpServers": {
        "websearch": {
            "command": "npx",
            "args": [
                "websearch-mcp"
            ],
            "environment": {
                "API_URL": "http://localhost:3001",
                "MAX_SEARCH_RESULT": "5"
            }
        }
    }
}

For Windows, use this workaround:

{
    "mcpServers": {
        "websearch": {
            "command": "cmd",
            "args": [
                "/c",
                "npx",
                "websearch-mcp"
            ],
            "environment": {
                "API_URL": "http://localhost:3001",
                "MAX_SEARCH_RESULT": "1"
            }
        }
    }
}

Usage

Search Parameters

The web_search tool accepts these parameters:

  • query (required): The search query to look up
  • numResults (optional): Number of results to return (default: 5)
  • language (optional): Language code for search results (e.g., 'en')
  • region (optional): Region code for search results (e.g., 'us')
  • excludeDomains (optional): Domains to exclude from results
  • includeDomains (optional): Only include these domains in results
  • excludeTerms (optional): Terms to exclude from results
  • resultType (optional): Type of results to return ('all', 'news', or 'blogs')

Example Search Response

{
  "query": "machine learning trends",
  "results": [
    {
      "title": "Top Machine Learning Trends in 2025",
      "snippet": "The key machine learning trends for 2025 include multimodal AI, generative models, and quantum machine learning applications in enterprise...",
      "url": "https://example.com/machine-learning-trends-2025",
      "siteName": "AI Research Today",
      "byline": "Dr. Jane Smith"
    },
    {
      "title": "The Evolution of Machine Learning: 2020-2025",
      "snippet": "Over the past five years, machine learning has evolved from primarily supervised learning approaches to more sophisticated self-supervised and reinforcement learning paradigms...",
      "url": "https://example.com/ml-evolution",
      "siteName": "Tech Insights",
      "byline": "John Doe"
    }
  ]
}

Testing Locally

Test the WebSearch MCP server with the included test client:

npm run test-client

Configure the API_URL for the test client:

API_URL=https://crawler.example.com npm run test-client

Using as a Library

import { createMCPClient } from '@modelcontextprotocol/sdk';

// Create an MCP client
const client = createMCPClient({
  transport: { type: 'subprocess', command: 'npx websearch-mcp' }
});

// Execute a web search
const response = await client.request({
  method: 'call_tool',
  params: {
    name: 'web_search',
    arguments: {
      query: 'your search query',
      numResults: 5,
      language: 'en'
    }
  }
});

console.log(response.result);

Troubleshooting

Crawler Service Issues

  • API Unreachable: Ensure the crawler service is running and accessible at the configured API_URL.
  • Search Results Not Available: Check the crawler service logs:
    docker-compose logs crawler
    
  • FlareSolverr Issues: Check if FlareSolverr is working:
    docker-compose logs flaresolverr
    

MCP Server Issues

  • Import Errors: Ensure you have the latest version of the MCP SDK:
    npm install -g @modelcontextprotocol/sdk@latest
    
  • Connection Issues: Make sure the stdio transport is properly configured for your client.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "websearch" '{"command":"npx","args":["websearch-mcp"],"environment":{"API_URL":"http://localhost:3001","MAX_SEARCH_RESULT":"5"}}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "websearch": {
            "command": "npx",
            "args": [
                "websearch-mcp"
            ],
            "environment": {
                "API_URL": "http://localhost:3001",
                "MAX_SEARCH_RESULT": "5"
            }
        }
    }
}

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

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "websearch": {
            "command": "npx",
            "args": [
                "websearch-mcp"
            ],
            "environment": {
                "API_URL": "http://localhost:3001",
                "MAX_SEARCH_RESULT": "5"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

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