SerpAPI Google Trends MCP Server

SerpAPI Google Trends MCP Server

Provides access to Google Trends data via SerpAPI for analyzing regional search interest patterns, comparing services across locations, and discovering related queries to support data-driven advertising and service decisions.

Category
Visit Server

README

SerpAPI Google Trends MCP Server

A Model Context Protocol (MCP) server that provides access to Google Trends data via SerpAPI. Perfect for analyzing regional search interest patterns to make data-driven decisions about advertising and service offerings.

Built with FastMCP.

Use Case: Regional Service Marketing

This MCP server is designed to help service-based businesses answer questions like:

  • Which cities in Alabama and Missouri show the most interest in our HVAC services?
  • Should we advertise furnace repair or heat pump services in Huntsville this winter?
  • When does demand for heating services peak in St. Louis?
  • What related services are customers searching for in our target markets?

Features

  • πŸ—ΊοΈ Interest by Region: See which geographic areas have highest search interest
  • πŸ“ˆ Interest Over Time: Understand seasonal trends and timing patterns
  • βš–οΈ Service Comparison: Compare multiple services across multiple locations
  • πŸ” Related Queries: Discover new keyword opportunities
  • πŸ“Š Data-Driven Insights: All data from Google Trends with 0-100 interest scale

Installation

Prerequisites

  • Python 3.10 or higher
  • SerpAPI account with API key (Sign up here)
  • Claude Desktop or Claude Code CLI

Setup

  1. Create the directory structure:

    cd serpapi-trends-mcp
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Configure API credentials:

    cp .env.example .env
    

    Edit .env and add your SerpAPI key:

    SERPAPI_KEY=your-api-key-here
    

    Get your API key from: https://serpapi.com/manage-api-key

Usage

Claude Desktop Integration

Add to your Claude Desktop configuration:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "serpapi-trends": {
      "command": "python",
      "args": [
        "-m",
        "serpapi_trends_mcp.server"
      ],
      "cwd": "/absolute/path/to/serpapi-trends-mcp",
      "env": {
        "SERPAPI_KEY": "your-api-key-here"
      }
    }
  }
}

Claude Code Integration

Add to your project's .mcp.json:

{
  "mcpServers": {
    "serpapi-trends": {
      "command": "python",
      "args": [
        "-m",
        "serpapi_trends_mcp.server"
      ],
      "cwd": "/absolute/path/to/serpapi-trends-mcp",
      "env": {
        "SERPAPI_KEY": "your-api-key-here"
      }
    }
  }
}

Or use command line arguments:

{
  "mcpServers": {
    "serpapi-trends": {
      "command": "python",
      "args": [
        "-m",
        "serpapi_trends_mcp.server",
        "--api-key",
        "your-api-key-here"
      ],
      "cwd": "/absolute/path/to/serpapi-trends-mcp"
    }
  }
}

After adding the configuration, restart Claude Desktop or reconnect Claude Code.

Available Tools

get_interest_by_region

Find which geographic areas show the most interest in your services.

Parameters:

  • query (required): Search term(s), comma-separated for comparison
  • date: Time range (default: "today 3-m" for 3 months)
  • resolution: "COUNTRY", "REGION", "CITY" (default), or "DMA"
  • geo: Location code (e.g., "US", "US-AL", "US-MO")

Example:

Find which cities in Alabama search most for HVAC services:

get_interest_by_region(
  query="hvac repair,furnace repair,ac repair,heat pump repair",
  date="today 3-m",
  resolution="CITY",
  geo="US-AL"
)

get_interest_over_time

Analyze how search interest changes over time to identify seasonal patterns.

Parameters:

  • query (required): Search term(s), comma-separated for comparison
  • date: Time range (default: "today 3-m")
  • geo: Location code (e.g., "US-MO")

Example:

Compare heating vs cooling demand in Missouri over the past year:

get_interest_over_time(
  query="furnace repair,heating repair,ac repair",
  date="today 12-m",
  geo="US-MO"
)

compare_services_in_cities

Compare multiple services across multiple regions to find the best opportunities.

Parameters:

  • services (required): Comma-separated service keywords
  • cities (required): Comma-separated region codes
  • date: Time range (default: "today 3-m")

Example:

Compare HVAC services in Alabama and Missouri:

compare_services_in_cities(
  services="hvac repair,furnace repair,ac repair,heat pump repair",
  cities="US-AL,US-MO",
  date="today 3-m"
)

get_related_queries

Discover related search queries to expand keyword targeting.

Parameters:

  • query (required): Search term to analyze
  • date: Time range (default: "today 3-m")
  • geo: Location code

Example:

Find related HVAC searches in Alabama:

get_related_queries(
  query="hvac repair",
  date="today 3-m",
  geo="US-AL"
)

Available Resources

Browse reference data using MCP resources:

  • serpapi://us-states: List of US state codes for the geo parameter
  • serpapi://time-ranges: Available time range options with recommendations

Workflow Example: Winter Service Planning

Scenario: You run an HVAC company and want to decide which services to advertise in Huntsville, AL and St. Louis, MO for the upcoming winter season.

Step 1: Compare Services by Region

compare_services_in_cities(
  services="furnace repair,heat pump repair,heating system,boiler repair",
  cities="US-AL,US-MO",
  date="today 3-m"
)

Result: See which cities in each state have the highest search interest.

Step 2: Analyze Seasonal Timing

get_interest_over_time(
  query="furnace repair,heat pump repair",
  date="today 12-m",
  geo="US-AL"
)

Result: Identify when demand peaks (typically early winter).

Step 3: Find Related Keywords

get_related_queries(
  query="furnace repair",
  date="today 3-m",
  geo="US-AL"
)

Result: Discover additional keywords like "emergency heating repair", "furnace maintenance", etc.

Step 4: City-Level Targeting

get_interest_by_region(
  query="furnace repair",
  date="today 3-m",
  resolution="CITY",
  geo="US-AL"
)

Result: Get specific cities in Alabama ranked by search interest.

Step 5: Make Data-Driven Decisions

Based on the data:

  • Budget Allocation: Spend more on cities with higher interest scores
  • Service Focus: Prioritize services with highest regional demand
  • Campaign Timing: Launch ads when seasonal interest peaks
  • Keyword Expansion: Include related queries in your targeting

Understanding the Data

Interest Scores (0-100 Scale)

  • 100: Peak popularity for the selected time period and location
  • 50: Half as popular as the peak
  • 0: Less than 1% of peak popularity

Interpreting Results

  • High interest (70-100): Strong demand, prime target for advertising
  • Medium interest (40-69): Moderate opportunity, consider if competition is low
  • Low interest (0-39): Limited demand, may not be cost-effective

Time Ranges Recommendations

Use Case Recommended Range Code
Current market conditions Past 3 months today 3-m
Full seasonal patterns Past year today 12-m
Long-term planning Past 5 years today 5-y
Recent spike analysis Past week now 7-d

Pricing

SerpAPI pricing is based on API calls:

  • Free tier: 100 searches/month
  • Paid plans: Start at $50/month for 5,000 searches
  • Each tool call = 1 API search

View pricing: https://serpapi.com/pricing

Project Structure

serpapi-trends-mcp/
β”œβ”€β”€ src/
β”‚   └── serpapi_trends_mcp/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ server.py              # FastMCP server with tools & resources
β”‚       └── client.py              # Async SerpAPI wrapper
β”œβ”€β”€ requirements.txt               # Python dependencies
β”œβ”€β”€ .env.example                   # Credential template
β”œβ”€β”€ .env                          # Your credentials (gitignored)
β”œβ”€β”€ .gitignore
└── README.md

Development

Testing Locally

# Run the server directly
python -m serpapi_trends_mcp.server

# Or with command line argument
python -m serpapi_trends_mcp.server --api-key YOUR_KEY

# Test with FastMCP dev mode
fastmcp dev src/serpapi_trends_mcp/server.py

Adding New Tools

Edit src/serpapi_trends_mcp/server.py and add new @mcp.tool decorated functions.

Adding New Endpoints

Edit src/serpapi_trends_mcp/client.py to add new SerpAPI endpoint methods.

Troubleshooting

"Missing SERPAPI_KEY"

  • Ensure .env file exists with SERPAPI_KEY=your-key
  • Or set environment variable in your shell
  • Or use --api-key command line argument

"401 Unauthorized"

  • Verify your API key is correct
  • Check you haven't exceeded your monthly quota
  • Visit https://serpapi.com/manage-api-key

"No data returned"

  • Try a broader time range (e.g., "today 12-m")
  • Try a less specific query term
  • Some locations may have insufficient search volume

Server not appearing in Claude Desktop

  • Check the cwd path is absolute, not relative
  • Verify Python is in your PATH
  • Restart Claude Desktop after config changes
  • Check Claude Desktop logs for errors

Example Queries for HVAC Business

Research Phase

"What cities in Alabama have the highest demand for HVAC services?"

"Show me search trends for heating services in Missouri over the past year"

"What related services do people search for when looking for furnace repair?"

Analysis Phase

"Compare interest in 'heat pump repair' vs 'furnace repair' in Huntsville and St. Louis"

"When does demand for heating services peak in Alabama?"

"Which cities in Missouri show the strongest interest in emergency HVAC services?"

Decision Phase

"Based on Google Trends, where should we focus our winter HVAC advertising budget?"

"Create a priority list of cities for our heating service marketing campaign"

Resources

License

MIT License

Support

  • SerpAPI Support: https://serpapi.com/contact
  • File issues: Create an issue in this repository
  • MCP Documentation: https://modelcontextprotocol.io

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured