Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

serpapi-mcp-server

MCP.Pizza Chef: ilyazub

The serpapi-mcp-server is an MCP server that integrates with SerpApi to retrieve parsed search engine results quickly and efficiently. It supports live and archived search data from multiple search engines, exposing structured search results as tools and resources for MCP clients and hosts. This server enables seamless real-time search context feeding into LLMs, enhancing their ability to perform web-based queries and reasoning.

Use This MCP server To

Retrieve live search engine results for real-time queries Access archived search results for historical data analysis Integrate search results into LLM workflows for enhanced context Enable MCP clients to perform multi-engine search queries Provide structured search data for automated report generation Support AI agents in web research and fact-checking tasks Combine search results with other data sources in MCP clients

README

SerpApi MCP Server

Build

Build an MCP server that:

  • Get parsed search engines results pages via SerpApi using an API key, fast

This MCP (Model Context Protocol) server integrates with SerpApi to perform searches across various search engines and retrieve both live and archived results. It exposes tools and resources for seamless interaction with MCP clients or hosts, such as Grok or Claude for Desktop.


Installation

To set up the SerpApi MCP server, install the required Python libraries:

pip install mcp serpapi python-dotenv

You’ll also need a SerpApi API key. Sign up at SerpApi to get one.

Quick Start

  1. Save the Server Code: Place the server code in a file, e.g., server.py.

  2. Configure the API Key: Create a .env file in the same directory with your SerpApi API key:

SERPAPI_API_KEY=your_api_key_here
  1. Run the Server: Start the server with:
python server.py
  1. Integrate with an MCP Client: Connect the server to an MCP client or host (e.g., Claude for Desktop). For Claude, update Claude_desktop_config.json:
{
  "mcpServers": {
    "serpapi": {
      "command": "python",
      "args": ["path/to/server.py"]
    }
  }
}

Restart the client to load the server.

Features

  • Supported Engines: Google, Google Light, Bing, Walmart, Yahoo, eBay, YouTube, DuckDuckGo, Yandex, Baidu

  • Tools:

  • search: Perform a search on a specified engine with a query and optional parameters.
  • Resources:
  • locations: Find Google Locations.

Usage Examples

These examples assume an MCP client (e.g., written in Python using the MCP client SDK) is connected to the server. Listing Supported Engines Retrieve the list of supported search engines:

engines = await session.read_resource("locations")
print(engines)

Performing a Search Search for "coffee" on Google with a location filter:

result = await session.call_tool("search", {
    "query": "coffee",
    "engine": "google",
    "location": "Austin, TX"
})

print(result)

Configuration

API Key: Set your SerpApi API key in the .env file as SERPAPI_API_KEY.

Running the Server

Production Mode: Launch the server with:

python server.py

Development Mode: Use the MCP Inspector for debugging:

mcp dev server.py

Testing

Test the server using the MCP Inspector or an MCP client. For Claude for Desktop, configure the server in Claude_desktop_config.json, restart the app, and use the hammer icon to explore and test available tools.

serpapi-mcp-server FAQ

How do I install the serpapi-mcp-server?
Install via pip with 'pip install mcp serpapi python-dotenv' and configure your SerpApi API key.
What API key is required to use this server?
A SerpApi API key is needed, which you can obtain by signing up at serpapi.com.
Can this server handle multiple search engines?
Yes, it supports various search engines through the SerpApi platform.
How does this server expose search results to MCP clients?
It provides parsed, structured search engine results as MCP tools and resources.
Is the serpapi-mcp-server compatible with different MCP hosts?
Yes, it works with MCP clients and hosts like Grok and Claude for Desktop.
Does this server support both live and archived search results?
Yes, it can retrieve both live and archived search engine data.
What programming language is used for this server?
The server is implemented in Python.
How can I configure the API key securely?
Use environment variables or a .env file with python-dotenv to manage your API key.