SE

Serper MCP Server for Google Searches

Perform fast Google searches with Serper using this MCP server to retrieve real-time results via API.

Quick Install
npx -y @garylab/serper-mcp-server

Overview

Serper MCP Server for Google Searches is a lightweight Model Context Protocol (MCP) server that exposes Google search functionality via Serper as a tool that models and agents can call. It acts as a small API shim between an LLM or agent runtime that supports MCP and the Serper search API, returning structured, real-time web search results that can be used to ground model responses or fetch up-to-date information.

This server is useful when you want to provide search-as-a-tool to an LLM without embedding API keys or search logic inside the model runtime. By implementing the MCP interface, the Serper MCP Server makes it straightforward for agent frameworks to discover and invoke a “google-search” tool, receive results in a predictable format, and stream or cache results as needed.

Features

  • MCP-compatible tool endpoint exposing Google search via Serper
  • Simple configuration with environment variables
  • JSON-based request/response payloads suitable for LLM tool calls
  • Example curl and language client usage for quick integration
  • Minimal, dependency-light server that is easy to self-host
  • Supports specifying search queries, result limits, and basic options

Installation / Configuration

  1. Clone the repository and install dependencies:
git clone https://github.com/garylab/serper-mcp-server.git
cd serper-mcp-server
npm install
  1. Create a .env file or export environment variables. Required variables:
  • SERPER_API_KEY — your Serper API key
  • PORT — port to run the MCP server (defaults to 3000)

Example .env:

SERPER_API_KEY=sk-xxxxxx
PORT=3000
  1. Start the server:
npm start
# or
node server.js

The server will listen on the configured port and expose MCP endpoints described below.

Available Resources

The server exposes a small set of HTTP endpoints that follow the MCP tool-discovery and invocation patterns. Typical endpoints:

PathMethodDescription
/mcpGETReturns MCP manifest / tool descriptions (tool discovery)
/invokePOSTInvoke a tool (e.g., google-search) with parameters
/healthGETHealth check for the server

Example discovery response (simplified):

{
  "tool_id": "google-search",
  "name": "Google Search (Serper)",
  "description": "Perform a real-time Google search using Serper and return structured results.",
  "inputs": {
    "query": "string",
    "num_results": "integer (optional, default 5)"
  }
}

API: Invoke a Search (Example)

Invoke the search tool with a POST request:

curl -X POST "http://localhost:3000/invoke" \
  -H "Content-Type: application/json" \
  -d '{
    "tool_id": "google-search",
    "inputs": {
      "query": "latest GPT model release notes",
      "num_results": 3
    }
  }'

Example success response (simplified):

{
  "tool_id": "google-search",
  "outputs": {
    "results": [
      {
        "title": "GPT-4o Release Notes",
        "snippet": "OpenAI announces GPT-4o with improved latency...",
        "link": "https://example.com/gpt-4o-release"
      },
      ...
    ]
  }
}

Use Cases

  • Augmenting LLMs with up-to-date web evidence: Use the MCP server as a callable tool so agents can fetch current facts, news, or documentation citations before answering.
  • Retrieval-augmented generation (RAG): Retrieve relevant web pages or snippets to build context for downstream embedding or summarization pipelines.
  • Chatbots and assistants: Allow conversational agents to perform targeted web lookups (product specs, release notes, news) without granting direct Serper keys to the model runtime.
  • Automation scripts: Integrate the MCP server in automated workflows that need periodic checks on web content or monitoring search queries programmatically.

Concrete example — Python client calling the MCP server:

import requests

url = "http://localhost:3000/invoke"
payload = {
    "tool_id": "google-search",
    "inputs": {
        "query": "how to configure Serper MCP Server",
        "num_results": 2
    }
}
resp = requests.post(url, json=payload)
print(resp.json())

Another example — integrating with an agent loop:

  • During planning, the agent issues a tool call with tool_id “google-search” and a query.
  • The MCP server returns ranked results.
  • The agent consumes the snippets and links to generate a response with citations.

Tips and Next Steps

  • Secure the server in production: restrict access, add authentication, and rate-limit calls to protect your Serper API key.
  • Add caching for repeated queries (e.g., in-memory or Redis) to reduce Serper usage and speed up responses.
  • Extend the tool manifest with more options (e.g., country or language parameters) if needed by your agents.

Repository and source code: https://github.com/garylab/serper-mcp-server

Tags:search