Integrations

MCP server

Expose the SERP API to AI agents through the Model Context Protocol, so an agent can search Google as a tool.

Overview

The MCP server wraps the same /v1 REST surface and presents it to any MCP client (Claude Desktop, IDEs, custom agents) as callable tools. Point it at the hosted service or a local instance; it authenticates with a normal API key.

Install & run

The MCP server ships as an optional dependency group of the SERP API package. Install it, set the base URL and key, then launch the stdio server.

shell
pip install -e '.[mcp]'                 # optional dep group
export SERP_API_BASE_URL=https://serp-api.hoangha.shop
export SERP_API_KEY=sk_live_...

serp-api-mcp                            # stdio transport
# or: python -m serp_api.mcp_server

Tools

FieldTypeDescription
serp_searchtoolRun a Google SERP search for a keyword (location, gl, hl, uule, lat, lon, radius, device, stop_domain, capture_aio, google_domain, tbs, tbm, safe, nfpr, filter, lr, cr, ludocid, lsig, kgmid, si, ibp, uds, color_scheme, no_cache). Async by default; returns a job. The AI Overview is captured by default; pass capture_aio=false to skip it for a faster crawl. Supports all Google query knobs.
serp_get_resultstoolFetch a job by id with output = serpapi | json | html, plus start for the result offset. Poll while running.
serp_usagetoolReport the API key’s tier, monthly quota, usage this month, and remaining quota.

Typical agent loop

Call serp_search to submit, then serp_get_results(job_id) until the status is terminal. Use serp_usage to stay within quota.

Connect Claude Desktop

Add the server to your claude_desktop_config.json and restart Claude Desktop. The tools then appear to the model automatically.

claude_desktop_config.json
{
  "mcpServers": {
    "serp-api": {
      "command": "serp-api-mcp",
      "env": {
        "SERP_API_BASE_URL": "https://serp-api.hoangha.shop",
        "SERP_API_KEY": "sk_live_..."
      }
    }
  }
}

Keep the key private

The config file holds a live API key. Protect it like any other credential and use a dedicated key you can revoke independently.