Google Search MCP
A lightweight Model Context Protocol (MCP) server that allows AI models to search the web using the Google Custom Search API.
Documentation
π An MCP server that lets any MCP-compatible AI client search the live web through Google's Custom Search JSON API β over stdio, plug-and-play.
π§ Table of Contents
- π§ Table of Contents
- β¨ Overview
- βοΈ Requirements
- π§ Google Custom Search Setup
- β οΈ Rate Limits & Quota
- π¦ Installation
- βΆοΈ Run
- π³ Run with Docker
- π MCP Client Configuration
- π§© Using This Server in Your Own Project
- π οΈ Available Tool
- π§ͺ Test with MCP Inspector
- π Project Structure
- π€ Contributing
- π License
- π€ Author
β¨ Overview
This server bridges the gap between AI agents and real-time web knowledge. It speaks the Model Context Protocol (MCP) over stdio, so any compatible client can call a single tool β
search_googleβ and get back clean, structured search results straight from Google.
βββββββββββββββββββ stdio (MCP) ββββββββββββββββββββββββ HTTPS βββββββββββββββββββββ
β MCP Client β ββββββββββββββββββββββββΆ β Google Search MCP β βββββββββββββββββββΆ β Google Custom β
β (Claude, etc.) β ββββββββββββββββββββββββ β Server β βββββββββββββββββββ β Search JSON API β
βββββββββββββββββββ results ββββββββββββββββββββββββ results βββββββββββββββββββββ
βοΈ Requirements
| Requirement | Details |
|---|---|
| π’ Node.js | v18 or newer |
| π Google API Key | With access to the Custom Search JSON API |
| π Search Engine ID | From a Google Programmable Search Engine (cx) |
π§ Google Custom Search Setup
- Create a project in the Google Cloud Console
- Enable the
Custom Search APIfor that project - Generate an API key
- Create a Programmable Search Engine and copy its Search Engine ID
β οΈ Rate Limits & Quota
The Google Custom Search JSON API's free tier allows 100 queries per day. Once that limit is hit, the API returns a 429 error and search_google will respond with an error message instead of results.
- Need more? You can enable billing on your Google Cloud project for up to 10,000 queries/day (paid, per-query pricing).
- Check your current usage in the Google Cloud Console under APIs & Services β Custom Search API β Quotas.
π¦ Installation
npm install
Create a .env file in the project root:
GOOGLE_API_KEY=your_google_api_key
SEARCH_ENGINE_ID=your_search_engine_id
β οΈ
Never commit
.envor expose your API key in source control.
βΆοΈ Run
Development (run TypeScript directly):
npm start
Production (build then run compiled output):
npm run build
node build/index.js
βΉοΈ The server logs status and errors to
stderr, keepingstdoutclean for MCP protocol messages.
π³ Run with Docker
Prefer containers? You can build and run this server without installing Node.js locally.
Build the image:
docker build -t google-search-mcp .
Run it (make sure your .env file is set up first β see Installation):
docker run -i --rm --env-file .env google-search-mcp
β οΈ
The
-iflag is required β this is a stdio-based MCP server and needs an interactive stream to communicate with the client.
Or use Docker Compose:
services:
google-search-mcp:
build: .
stdin_open: true
tty: true
env_file:
- .env
docker compose up --build
Point your MCP client to Docker
{
"mcpServers": {
"google-search": {
"command": "docker",
"args": ["run", "-i", "--rm", "--env-file", ".env", "google-search-mcp"]
}
}
}
π MCP Client Configuration
After building the project, register the server with an MCP-compatible client using the compiled entry point:
{
"mcpServers": {
"google-search": {
"command": "node",
"args": ["/absolute/path/to/Google-Search-MCP/build/index.js"],
"env": {
"GOOGLE_API_KEY": "your_google_api_key",
"SEARCH_ENGINE_ID": "your_search_engine_id"
}
}
}
}
Or keep credentials in the project's .env and launch from the project directory:
{
"mcpServers": {
"google-search": {
"command": "node",
"args": ["/absolute/path/to/Google-Search-MCP/build/index.js"]
}
}
}
π§© Using This Server in Your Own Project
This server isn't tied to any single client β any MCP-compatible host can spawn it and call search_google. To use it elsewhere:
- Clone and build this repo (or pull the Docker image β see Run with Docker).
- Point your MCP client's config at the built entry point (
build/index.js) or the Docker command, using the same JSON shown in MCP Client Configuration. - Supported clients β any tool that speaks MCP over stdio works, including:
- Calling it programmatically β if you're building your own MCP client/agent in code, connect an MCP
ClientoverStdioClientTransportpointed atbuild/index.js, then call thesearch_googletool like any other MCP tool. See the MCP TypeScript SDK docs for client-side examples.
Each client has its own config file location and format for
mcpServersβ check that client's docs for exactly where to paste the JSON block.
π οΈ Available Tool
search_google
Searches Google Custom Search for the supplied query and returns the top 3 results.
Input
{
"query": "latest TypeScript release"
}
Output
Each result includes:
- π
title - π
link - π
snippet
If nothing is found, the tool responds with No results found.
π§ͺ Test with MCP Inspector
npm run build
npx @modelcontextprotocol/inspector node build/index.js
Make sure your environment variables are set before launching the inspector.
π Project Structure
π¦ Google-Search-MCP
βββ π src
β βββ index.ts # MCP server implementation
βββ π build # Compiled JavaScript and type declarations
βββ .env # Local environment config (not committed)
βββ README.md
π€ Contributing
Contributions, bug reports, and feature requests are welcome!
- Found a bug or have an idea? Open an issue describing it.
- Want to contribute code?
- Fork the repo
2. Create a branch (
git checkout -b feature/your-feature) 3. Make your changes and test locally (npm startordocker compose up --build) 4. Commit and push, then open a Pull Request
- Fork the repo
2. Create a branch (
Please keep PRs focused β one feature or fix per PR makes review easier.
π License
This project is licensed under the MIT License.