Serper MCP Server for Google Searches
Perform fast Google searches with Serper using this MCP server to retrieve real-time results via API.
npx -y @garylab/serper-mcp-serverOverview
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
- Clone the repository and install dependencies:
- 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
- Start the server:
# or
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:
| Path | Method | Description |
|---|---|---|
| /mcp | GET | Returns MCP manifest / tool descriptions (tool discovery) |
| /invoke | POST | Invoke a tool (e.g., google-search) with parameters |
| /health | GET | Health check for the server |
Example discovery response (simplified):
API: Invoke a Search (Example)
Invoke the search tool with a POST request:
Example success response (simplified):
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:
=
=
=
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