Google Search MCP server

Provides Google web and image search capabilities through the Custom Search API, enabling access to current internet information with pagination and filtering options.
Back to servers
Provider
Hunter Arton
Release date
Apr 20, 2025
Language
TypeScript
Stats
1 star

The Google Search MCP Server provides web and image search capabilities for AI assistants through Google's Custom Search API. This server integrates with Claude and other AI assistants by implementing the Model Context Protocol (MCP), enabling them to search the web for current information.

Prerequisites

Before installing the server, you'll need:

  • Node.js (v18 or higher) and npm
  • Google Cloud Platform account
  • Google Custom Search API key and Search Engine ID
  • An MCP-compatible client (Claude for Desktop, Cursor, VSCode with Claude, etc.)

Installation

Quick Start (Using the Repository)

# Clone the repository
git clone https://github.com/yourusername/google-search-mcp-server.git
cd google-search-mcp-server

# Install dependencies
npm install

# Set up your environment variables
# On macOS/Linux
touch .env

# On Windows
new-item .env

# Edit .env file to add your Google API credentials
# Add these lines to your .env file:
# GOOGLE_API_KEY=your_api_key_here
# GOOGLE_CSE_ID=your_search_engine_id_here

# Build the server
npm run build

Google API Setup

Follow these steps to set up the required Google services:

  1. Google Cloud Platform Setup:

    • Go to Google Cloud Console
    • Create a new project
    • Enable the Custom Search API:
      • Navigate to "APIs & Services" → "Library"
      • Search for "Custom Search API"
      • Click on "Custom Search API" → "Enable"
    • Create API credentials:
      • Navigate to "APIs & Services" → "Credentials"
      • Click "Create Credentials" → "API key"
      • Copy your API key
  2. Custom Search Engine Setup:

    • Go to Programmable Search Engine
    • Click "Add" to create a new search engine
    • Select "Search the entire web" and name your search engine
    • Get your Search Engine ID (cx value) from the Control Panel

Connecting to MCP Clients

Claude for Desktop

macOS/Linux

  1. Open your configuration file:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
  1. Add the server configuration:
{
  "mcpServers": {
    "google_search": {
      "command": "node",
      "args": [
        "/absolute/path/to/google-search-mcp/dist/index.js"
      ],
      "env": {
        "GOOGLE_API_KEY": "your_api_key_here",
        "GOOGLE_CSE_ID": "your_search_engine_id_here"
      }
    }
  }
}

Windows

  1. Open your configuration file:
code $env:AppData\Claude\claude_desktop_config.json
  1. Add the server configuration:
{
  "mcpServers": {
    "google_search": {
      "command": "node",
      "args": [
        "C:\\absolute\\path\\to\\google-search-mcp\\dist\\index.js"
      ],
      "env": {
        "GOOGLE_API_KEY": "your_api_key_here",
        "GOOGLE_CSE_ID": "your_search_engine_id_here"
      }
    }
  }
}
  1. Restart Claude for Desktop
  2. Verify the tools appear by clicking the tool icon in the interface

VSCode with Claude

  1. Install the MCP Extension for VSCode
  2. Create or edit .vscode/settings.json in your workspace:

For macOS/Linux:

{
  "mcp.servers": {
    "google_search": {
      "command": "node",
      "args": [
        "/absolute/path/to/google-search-mcp/dist/index.js"
      ],
      "env": {
        "GOOGLE_API_KEY": "your_api_key_here",
        "GOOGLE_CSE_ID": "your_search_engine_id_here"
      }
    }
  }
}

For Windows:

{
  "mcp.servers": {
    "google_search": {
      "command": "node",
      "args": [
        "C:\\absolute\\path\\to\\google-search-mcp\\dist\\index.js"
      ],
      "env": {
        "GOOGLE_API_KEY": "your_api_key_here",
        "GOOGLE_CSE_ID": "your_search_engine_id_here"
      }
    }
  }
}
  1. Restart VSCode

Cursor

  1. Open Cursor settings (gear icon)
  2. Search for "MCP" and open MCP settings
  3. Click "Add new MCP server"
  4. Configure with similar settings as above

Usage

Using with Claude

Once connected, you can test the tools by asking Claude questions like:

  • "Search for the latest news about renewable energy"
  • "Find images of electric vehicles"
  • "What are the top tourist destinations in Japan?"

Claude will automatically use the appropriate search tool when needed.

Manual Testing

You can test your server directly:

# Test the server
# On macOS/Linux
echo '{"jsonrpc":"2.0","method":"listTools","id":1}' | node dist/index.js

# On Windows PowerShell
echo '{"jsonrpc":"2.0","method":"listTools","id":1}' | node dist/index.js

# On Windows CMD
echo {"jsonrpc":"2.0","method":"listTools","id":1} | node dist/index.js

# Test web search
echo '{
  "jsonrpc": "2.0",
  "method": "callTool",
  "params": {
    "name": "google_web_search",
    "arguments": {
      "query": "test query",
      "count": 2
    }
  },
  "id": 1
}' | node dist/index.js

API Reference

google_web_search

Performs a web search using Google's Custom Search API.

Parameters:

  • query (string, required): The search query
  • count (number, optional): Number of results (1-10, default 5)
  • start (number, optional): Pagination start index (default 1)
  • site (string, optional): Limit search to specific site (e.g., 'example.com')

google_image_search

Searches for images using Google's Custom Search API.

Parameters:

  • query (string, required): The image search query
  • count (number, optional): Number of results (1-10, default 5)
  • start (number, optional): Pagination start index (default 1)

Troubleshooting

Common Issues

Environment Variables

If you see Error: GOOGLE_API_KEY environment variable is required:

# Check your .env file
cat .env

# Try setting environment variables directly:
export GOOGLE_API_KEY=your_key_here
export GOOGLE_CSE_ID=your_id_here

API Errors

If you encounter API errors:

# Test your API credentials directly
curl "https://www.googleapis.com/customsearch/v1?key=YOUR_API_KEY&cx=YOUR_CX_ID&q=test"

Connection Issues

If your client can't connect to the server:

# Verify the server runs correctly on its own
node dist/index.js

# Check file permissions
chmod 755 dist/index.js

# Ensure you're using absolute paths in your configuration

Limitations

  • Free tier of Google Custom Search API: 100 queries per day
  • Server-enforced rate limit: 5 requests per second
  • Maximum 10 results per query (Google API limitation)

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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