Enables web search capabilities using Google Custom Search API, allowing queries to retrieve real-time information from the internet with configurable result counts.
google-search-mcp
A Model Context Protocol (MCP) server that utilizes Google Custom Search (CSE) to retrieve information from the internet. By leveraging this MCP, the Large Language Model (LLM) is enabled to perform real-time Web searches.
Prerequisites
A Google Custom Search API key and Custom Search Engine ID are required:
Get a Google API Key from the Google Cloud Console
Create a Custom Search Engine at Programmable Search Engine
Installation
Or install from source:
Configuration
Create a .env file in the project root directory:
Then edit the .env file and add your credentials:
Alternatively, you can set environment variables directly:
Usage
As a CLI
With Claude Desktop
Add the following to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
For macOS/Linux:
For Windows:
If python is in your PATH (check with where python), you can use the same configuration as macOS/Linux:
If you need to use a specific Python installation, find the full path with:
Then use the full path in the configuration:
Note: Environment variables must be set in the Claude Desktop config env section for the server to access them.
Tools
search
Search the web using Google Custom Search.
Parameters:
query(string, required): The search query stringnum_results(integer, optional): Number of results to return (1-10, default 10)
Development
Running Tests
Install development dependencies:
Run the test suite:
Run tests with verbose output:
Run tests with coverage:
Test Coverage
The test suite includes comprehensive tests for:
Successful search requests
Environment variable validation
API error handling
JSON parsing errors
Empty search results
Input parameter validation (num_results clamping)
Result formatting
Request parameter verification
License
MIT License - see LICENSE for details.