Google Search MCP Server
by hasinduudara
README.md
<div align="center">
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&customColorList=6,11,20&height=200§ion=header&text=Google%20Search%20MCP%20Server&fontSize=42&fontColor=ffffff&animation=fadeIn&fontAlignY=38&desc=Web%20Search%20for%20AI%20Agents%20via%20MCP&descAlignY=58&descSize=18" width="100%"/>
<br/>
[](https://nodejs.org/)
[](https://www.typescriptlang.org/)
[](https://modelcontextprotocol.io/)
[](https://programmablesearchengine.google.com/)
[]()
<br/>
### ๐ 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.
</div>
---
## ๐งญ Table of Contents
- [๐งญ Table of Contents](#-table-of-contents)
- [โจ Overview](#-overview)
- [โ๏ธ Requirements](#๏ธ-requirements)
- [๐ง Google Custom Search Setup](#-google-custom-search-setup)
- [๐ฆ Installation](#-installation)
- [โถ๏ธ Run](#๏ธ-run)
- [๐ MCP Client Configuration](#-mcp-client-configuration)
- [๐ ๏ธ Available Tool](#๏ธ-available-tool)
- [`search_google`](#search_google)
- [๐งช Test with MCP Inspector](#-test-with-mcp-inspector)
- [๐ Project Structure](#-project-structure)
- [๐ License](#-license)
- [๐ค Author](#-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
1. **Create a project** in the [Google Cloud Console](https://console.cloud.google.com/)
2. **Enable** the `Custom Search API` for that project
3. **Generate** an API key
4. **Create** a [Programmable Search Engine](https://programmablesearchengine.google.com/) and copy its **Search Engine ID**
---
## ๐ฆ Installation
```bash
npm install
```
Create a `.env` file in the project root:
```env
GOOGLE_API_KEY=your_google_api_key
SEARCH_ENGINE_ID=your_search_engine_id
```
> โ ๏ธ **Never commit `.env`** or expose your API key in source control.
---
## โถ๏ธ Run
**Development** (run TypeScript directly):
```bash
npm start
```
**Production** (build then run compiled output):
```bash
npm run build
node build/index.js
```
> โน๏ธ The server logs status and errors to `stderr`, keeping `stdout` clean for MCP protocol messages.
---
## ๐ MCP Client Configuration
After building the project, register the server with an MCP-compatible client using the compiled entry point:
```json
{
"mcpServers": {
"google-search": {
"command": "node",
"args": ["D:/My Learning Projects/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:
```json
{
"mcpServers": {
"google-search": {
"command": "node",
"args": ["D:/My Learning Projects/Google-Search-MCP/build/index.js"]
}
}
}
```
---
## ๐ ๏ธ Available Tool
### `search_google`
Searches Google Custom Search for the supplied query and returns the **top 3 results**.
**Input**
```json
{
"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
```bash
npm run build
npx @modelcontextprotocol/inspector node build/index.js
```
> Make sure your environment variables are set before launching the inspector.
---
## ๐ Project Structure
```text
๐ฆ Google-Search-MCP
โโโ ๐ src
โ โโโ index.ts # MCP server implementation
โโโ ๐ build # Compiled JavaScript and type declarations
โโโ .env # Local environment config (not committed)
โโโ README.md
```
---
## ๐ License
No license has been specified for this project yet.
---
## ๐ค Author
<div align="center">
**M. Hasindu Udara**
Full-Stack Developer
[](https://www.linkedin.com/in/hasindu-udara)
</div>
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&customColorList=6,11,20&height=100§ion=footer" width="100%"/>TDQS
A3.7/5.0
Scored across 1 tool
Disambiguation5/5
With only one tool, there is no possibility of confusion or overlap between tools. The single tool's purpose is clear and distinct by default.
Naming Consistency5/5
The tool name follows a clear verb_noun pattern (search_google), which is consistent and descriptive. There are no other tools to create inconsistencies.
Tool Count3/5
The server has only one tool, which feels thin for typical MCP servers. However, for a narrowly scoped Google Search service, a single focused search tool is defensible.
Completeness5/5
The tool fully covers the stated purpose of searching the web via Google Custom Search API. There are no obvious missing operations for a server dedicated solely to performing web searches.
Maintenance
ActivityMaintained
ResponsivenessNo issues