Skip to main content
Glama

Google Search MCP Server

Google Search MCP Server

A Model Context Protocol (MCP) server that provides Google Search functionality with automatic API key rotation and intelligent quota management.

Features

  • Official Google Custom Search API integration
  • Automatic API key rotation for increased daily limits
  • Persistent quota tracking across sessions and directories
  • Multi-language and geolocation support
  • Advanced search filters (date, file type, site-specific)
  • SafeSearch content filtering
  • Global configuration - works from anywhere
  • Compatible with Claude Desktop and other MCP clients

Installation

# 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

Complete Removal

# 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 always 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 (survives restarts)
  • ✅ Automatic daily reset at midnight UTC
  • ✅ Cross-directory usage (works from anywhere)

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 (~/.google-search-mcp.json), 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. You can immediately use it:

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

{ "query": "artificial intelligence news" }
{ "query": "machine learning", "num": 10, "lr": "lang_en", "gl": "us", "dateRestrict": "m1", "fileType": "pdf" }
{ "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

Development

Prerequisites

  • Node.js 18+
  • TypeScript
  • Google Cloud account

Scripts

# Development mode with auto-reload npm run dev # Build for production npm run build # Start server npm start # Setup configuration npm run setup

Project Structure

google-search-mcp/ ├── src/ │ ├── index.ts # Entry point │ ├── server.ts # MCP server setup │ ├── config.ts # Configuration wrapper │ ├── global-config.ts # Global config manager │ └── tools/ │ └── search.ts # Search implementation ├── build/ # Compiled JavaScript ├── setup.js # Interactive setup tool └── package.json

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Support

For issues, questions, or contributions, please visit: https://github.com/Fabien-desablens/google-search-mcp

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

An MCP server that provides Google Search functionality with automatic API key rotation and intelligent quota management, enabling natural language search queries with advanced filtering options.

  1. Features
    1. Installation
      1. Quick Setup (Recommended)
      2. Advanced Installation
    2. Uninstallation
      1. Complete Removal
    3. Configuration
      1. Example Configuration
    4. Getting Google API Credentials
      1. 1. Create a Google Cloud Project
      2. 2. Generate API Key
      3. 3. Create Custom Search Engine
      4. 4. Scale with Multiple Keys
    5. Usage with Claude Code
      1. Required Parameters
      2. Optional Parameters
    6. Examples
      1. Basic Search
      2. Advanced Search
      3. Site-Specific Search
    7. Quota Management
      1. Quota Features
    8. Error Handling
      1. Development
        1. Prerequisites
        2. Scripts
        3. Project Structure
      2. Contributing
        1. License
          1. Support

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              A powerful MCP server that enables parallel Google searching with multiple keywords simultaneously, providing structured results while handling CAPTCHAs and simulating user browsing patterns.
              Last updated -
              1
              645
              186
              TypeScript
              MIT License
              • Apple
            • -
              security
              F
              license
              -
              quality
              An MCP server that provides access to Google's API Discovery Service, allowing agents to discover and interact with Google APIs through natural language commands.
              Last updated -
              Python
              • Linux
              • Apple
            • -
              security
              F
              license
              -
              quality
              An MCP server that enables interacting with Google's Indexing API, allowing agents to submit URLs to Google for indexing or removal from search results through natural language commands.
              Last updated -
              Python
            • -
              security
              F
              license
              -
              quality
              An MCP Server that provides access to Google's Search Console API, allowing users to interact with website search performance data and manage search presence through natural language.
              Last updated -
              Python

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/Fabien-desablens/google-search-mcp'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server