Skip to main content
Glama

Google Search MCP Server

by jspv

Google Search MCP Server

A Model Context Protocol (MCP) server that provides Google Custom Search functionality.

Configuration

This server uses Dynaconf for configuration management, supporting both .env files and environment variables.

Setup

  1. Copy the example environment file:

    cp .env.example .env
  2. Edit .env and add your Google API credentials:

    GOOGLE_API_KEY=your_actual_api_key_here GOOGLE_CX=your_custom_search_engine_id_here

Environment Variable Override

Environment variables will override .env file values when both are present. This allows for flexible deployment scenarios:

  • Development: Use .env file for local development

  • Production: Use environment variables for production deployment

  • CI/CD: Environment variables can override defaults for testing

Example:

If your .env file contains:

GOOGLE_API_KEY=dev_key_from_file

And you set an environment variable:

export GOOGLE_API_KEY=prod_key_from_env

The server will use prod_key_from_env (environment variable takes precedence).

Required Configuration

  • GOOGLE_API_KEY: Your Google Custom Search API key

  • GOOGLE_CX: Your Custom Search Engine ID

Get these from:

Optional Configuration

  • ALLOW_DOMAINS (GOOGLE_ALLOW_DOMAINS env var): Comma-separated list of allowed domains (e.g., example.com, docs.python.org). When set, results outside these domains are filtered out.

Usage

Run the server:

python server.py

Quick start

This project uses httpx with HTTP/2 support enabled for better performance. The dependency is declared as httpx[http2] and will install the h2 package automatically when you sync the environment.

Using uv (recommended)

# Install deps from pyproject/lockfile uv sync # Create and fill in your configuration cp .env.example .env $EDITOR .env # Run tests (optional sanity check) uv run pytest -q # Start the MCP server uv run python server.py

Try it quickly (no MCP client required)

You can also call the tool function directly for a quick smoke test (uses your env vars):

uv run python -c 'import asyncio, server; print(asyncio.run(server.search("site:python.org httpx", num=2, safe="off")))'

Note: When using the MCP server with a client, the search tool parameters follow Google CSE semantics. In particular, safe must be one of off or active, and num is clamped to the CSE maximum of 10.

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Enables users to perform Google Custom Search queries through the Model Context Protocol. Requires Google API credentials and Custom Search Engine configuration for web search functionality.

  1. Configuration
    1. Setup
    2. Environment Variable Override
    3. Required Configuration
    4. Optional Configuration
  2. Usage
    1. Quick start
      1. Using uv (recommended)
      2. Try it quickly (no MCP client required)

    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/jspv/google_search_mcp'

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