Google Search MCP server

Integrates with Google's Custom Search API using automatic key rotation and quota management to provide high-volume web search capabilities with advanced filtering options including language targeting, geolocation, date restrictions, and site-specific queries.
Back to servers
Setup instructions
Provider
Fabien Desablens
Release date
Jul 31, 2025
Language
Go
Stats
1 star

The Google Search MCP server integrates Google Search functionality into Claude Desktop and other MCP clients with automatic API key rotation and intelligent quota management. It allows you to perform web searches directly through Claude, with features like multi-language support, advanced filters, and SafeSearch content filtering.

Installation

Quick Setup (Recommended)

# Install the package globally
npm install -g @kyaniiii/google-search-mcp

# Run interactive setup
google-search-setup

This will:

  • Configure your Google API keys interactively
  • Set up global configuration file
  • Automatically integrate with Claude Code
  • Enable 100+ free searches per day per API key

Advanced Installation

git clone https://github.com/Fabien-desablens/google-search-mcp.git
cd google-search-mcp
npm install
npm run build
npm run setup

Uninstallation

# Remove the package
npm uninstall -g @kyaniiii/google-search-mcp

# Remove from Claude Code
claude mcp remove google-search

# Remove configuration file (if desired)
npm run clean

Note: Configuration file (~/.google-search-mcp.json) is preserved during updates and uninstallation to protect your API keys. Use npm run clean only if you want to completely remove your configuration.

Configuration

The setup tool creates a global configuration file at:

  • Windows: %USERPROFILE%\.google-search-mcp.json
  • Linux/macOS: ~/.google-search-mcp.json

This file contains:

  • Your API keys and search engine IDs
  • Persistent quota tracking
  • Automatic daily reset at midnight UTC
  • Cross-directory usage

Example Configuration

{
  "keys": [
    {
      "id": "key_1",
      "apiKey": "AIzaSy...",
      "searchEngineId": "abc123...",
      "dailyUsage": 45,
      "dailyLimit": 100,
      "lastReset": "2024-07-30",
      "isActive": true
    }
  ],
  "lastUpdated": "2024-07-30T15:30:00Z",
  "version": "1.0.0"
}

⚠️ Important: If you manually edit the configuration file, you must restart Claude Desktop for the changes to take effect.

Getting Google API Credentials

1. Create a Google Cloud Project

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable the "Custom Search API"

2. Generate API Key

  1. Navigate to "APIs & Services" > "Credentials"
  2. Click "Create Credentials" > "API Key"
  3. Copy the generated key

3. Create Custom Search Engine

  1. Visit Google Programmable Search Engine
  2. Click "Get started" or "Add"
  3. For "Sites to search", enter * to search the entire web
  4. Copy the Search Engine ID

4. Scale with Multiple Keys

  • Each Google Cloud project provides 100 free searches/day
  • Create multiple projects for more quota (e.g., 3 projects = 300 searches/day)
  • The server automatically rotates between available keys

Usage with Claude Code

After running the setup, the server is automatically configured in Claude Code:

User: "Search for latest AI news from this week"
Claude: I'll search for the latest AI news using Google Search...

The server exposes a google_search tool with these parameters:

Required Parameters

  • query (string): Search query

Optional Parameters

  • num (number): Number of results (1-10, default: 5)
  • start (number): Starting index for results
  • safe (string): SafeSearch level ('off', 'active')
  • lr (string): Language restriction (e.g., 'lang_en', 'lang_fr')
  • gl (string): Geolocation (country code: 'us', 'fr', 'uk')
  • dateRestrict (string): Time period ('d1', 'w1', 'm1', 'y1')
  • fileType (string): File type filter ('pdf', 'doc', 'ppt')
  • siteSearch (string): Search specific site
  • siteSearchFilter (string): Include ('i') or exclude ('e') site
  • cr (string): Country restriction ('countryUS', 'countryFR')
  • exactTerms (string): Exact phrase to include
  • excludeTerms (string): Terms to exclude
  • orTerms (string): Alternative terms (OR search)
  • sort (string): Sort by date ('date')
  • searchType (string): Search type ('image' for image search)

Examples

Basic Search

{
  "query": "artificial intelligence news"
}

Advanced Search

{
  "query": "machine learning",
  "num": 10,
  "lr": "lang_en",
  "gl": "us",
  "dateRestrict": "m1",
  "fileType": "pdf"
}

Site-Specific Search

{
  "query": "typescript tutorial",
  "siteSearch": "stackoverflow.com",
  "siteSearchFilter": "i"
}

Quota Management

The server provides real-time quota information in each response:

{
  "results": [...],
  "metadata": {
    "quotaStatus": {
      "totalUsed": 15,
      "totalLimit": 300,
      "keysStatus": [
        {
          "id": "key_1",
          "used": 15,
          "limit": 100,
          "remaining": 85,
          "active": true
        }
      ]
    }
  }
}

Quota Features

  • Automatic daily reset at midnight UTC
  • Intelligent key rotation when limits are reached
  • Disabled keys automatically reactivate after reset
  • Persistent tracking across server restarts
  • No charges - stops at free tier limits

Error Handling

The server gracefully handles various error scenarios:

  • Quota Exceeded: Automatically rotates to next available key
  • All Keys Exhausted: Returns clear error message with quota status
  • Invalid API Key: Disables the key and continues with others
  • Network Errors: Returns detailed error information

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 "google-search" '{"command":"npx","args":["-y","@kyaniiii/google-search-mcp"]}'

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": {
        "google-search": {
            "command": "npx",
            "args": [
                "-y",
                "@kyaniiii/google-search-mcp"
            ]
        }
    }
}

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": {
        "google-search": {
            "command": "npx",
            "args": [
                "-y",
                "@kyaniiii/google-search-mcp"
            ]
        }
    }
}

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