Provides access to Google Trends data, allowing retrieval of relative search interest over the last 12 months for specific terms with optional geographic and category filtering.
Search Trends Explorer
This project combines a Google Trends visualizer built with Next.js and a Model Context Protocol (MCP) server that exposes the same data as a tool you can connect to OpenAI or any MCP-compatible client. Both experiences call SearchAPI.io to retrieve the last 12 months of relative interest for a search term.
Prerequisites
Node.js 18.18+ (recommended to avoid engine warnings)
A
SEARCH_API_KEY
from SearchAPI.io
Create a .env
file with:
Running the Next.js UI
Visit http://localhost:3000
to use the web interface.
Running the MCP Server
The MCP server exposes a single tool named fetch_google_trends
over streamable HTTP.
The server listens on http://localhost:3000/mcp
(honors the PORT
env variable) and also serves GET /healthz
for Render health checks.
Connecting from an MCP client
MCP Inspector:
npx @modelcontextprotocol/inspector --server http://localhost:3000/mcp
OpenAI / other agents: add an HTTP MCP tool pointing to the same
/mcp
endpoint.
When invoked, fetch_google_trends
expects a JSON payload:
The tool responds with structured JSON containing the normalized timeline points.
Deploying the MCP server to Render.com
Create a new Web Service from this repository.
Set the start command to:
npm run mcp:startAdd the environment variable
SEARCH_API_KEY
.(Optional) Configure Render health checks to hit
/healthz
.
Render will inject PORT
, which the server automatically respects.
Testing & Linting
Project Structure Highlights
app/
– Next.js app router with UI and/api/trends
endpoint.lib/trends.ts
– Shared SearchAPI client used by both the API route and MCP tool.mcp/server.ts
– Express + MCP server exposing thefetch_google_trends
tool.
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables retrieval and analysis of Google Trends data for any search term over the last 12 months. Provides structured timeline data with relative interest scores that can be filtered by geography and category.