Skip to main content
Glama
jain-eshan

Google Trends MCP

by jain-eshan

Google Trends MCP

A local MCP server that lets Claude (or any MCP client) query Google Trends directly — search interest over time, related queries and topics, regional breakdowns, and real-time trending searches — so you can do market research inside a conversation instead of tab-switching to trends.google.com and pasting screenshots back in.

Built for personal/self-use market research. No API key required — Google Trends has no official public API, so this wraps pytrends, the standard unofficial Python client, in an MCP server.

工具

所有工具默认使用 geo="IN"(印度),除非另有说明 —— 传入 geo="" 表示全球范围,或任意一个 ISO 国家/地区代码(如 "US""GB" 等)。timeframe 接受 pytrends 的格式,例如 "today 12-m""today 5-y""now 7-d",或一个明确的区间,如 "2024-01-01 2024-06-01"

interest_over_time(keywords, timeframe="today 12-m", geo="IN")

相对搜索兴趣(0–100)随时间的变化,最多支持 5 个关键词并排对比。第 6 个及之后的关键词会被静默丢弃。每条记录都包含 isPartial —— 最近一个数据点上的 true 表示该周期尚未完成,其值是临时值;不要把该点的下降解读为真实的趋势变化。

单关键词的热门和相关查询。返回 {"top": [...], "rising": [...]},每个字段都是 {"query": ..., "value": ...} 记录的列表。top 的值是 0–100 的相对兴趣。rising 的值是百分比增长 —— 但是,当值为 5000% 时是 Google 的 Breakout 标记,表示从近乎为零的基数上爆发的增长,而不是字面意义的百分比。

related_queries 相同,但返回的是主题分组(Google 自己的主题聚类),而不是原始查询字符串 —— 记录中除了 value 之外,还包含 topic_titletopic_typerising 同样适用 Breakout 约定。

interest_by_region(keyword, timeframe="today 12-m", geo="IN")

在给定的 geo 范围内,按州/地区细分关键词的搜索兴趣。返回一个由 {"geoName": ..., "<keyword>": 0-100} 组成的列表,每个地区一条记录。

某个国家的今日热门搜索。请注意,这里的 geo 格式不同 —— 它是完整的小写国家名称("india""united_states"),不是像其他四个工具那样的 ISO 代码。这是 Google 自身端点的真实不一致,而不是 bug。

已知限制: 截至撰写本文时,trending_now 遇到 HTTP 404 而失败。Google 似乎已弃用了 pytrends 的 trending-search 方法所依赖的旧端点(hottrends/dailytrends/realtimetrends)——这一结论已通过测试 pytrends 提供的全部三种变体得到确认。这是上游问题,无法在此代码库中修复;它以干净的、可读的错误字符串失败,而不是崩溃。其他 4 个工具使用另一组仍然可用的不同端点,因此不受影响。如果 Google 恢复该端点、或 pytrends 提供补丁,这里无需任何改动即可恢复工作。

所有工具都会捕获失败情况(接口限流、网络错误、上述情况)并返回普通的错误字符串而不是崩溃 —— Google Trends 是一个被爬取的公网端点,不是稳定的 API,因此这是预期行为,不是例外情况。

Related MCP server: Google Trends MCP Server

设置

需要 Python 3.10+ 和 uv

git clone https://github.com/jain-eshan/google-trends-mcp.git
cd google-trends-mcp
uv sync

注册到 Claude Code

claude mcp add google-trends -- uv run --directory /absolute/path/to/google-trends-mcp server.py

验证连接:

claude mcp list

你应该会看到 google-trends 被列为 ✔ Connected。在注册后新的 Claude Code 对话中开始使用 —— 已经运行的会话不会检测到新添加的服务器。

使用

注册后,只需让 Claude 使用它即可 —— 例如:

“使用 google-trends MCP 对比印度过去 12 个月中 ‘lab grown diamonds’ 与 ‘diamond jewellery’ 的装机兴趣,并展示相关查询。”

可选:/trends 技能

本仓库包含一个位于 .claude/skills/trends/SKILL.md 的 Claude Code 技能,它会将原始工具包装成一个研究、总结工作流 —— 该技能决定哪些工具与你的主题相关,并写出一份通俗易懂的总结,而不是输出原始 JSON。如果你在使用 Claude Code,该技能会自动从本仓库加载;只需运行:

/trends <your topic>

设计说明

  • 只提供数据,服务器内不做总结。 每个工具只返回原始的、结构化数据 —— 如何解读(这个趋势是否真实、这里的 Breakout 标记意味着什么、什么值得标记)发生在调用它的对话中,而不是内建在服务器里。这让服务器保持简单,并让任何调用者在里面做出自己的判断。

  • 依赖只有 mcp[cli]pytrends 没有数据库、没有配置文件、没有 API 密钥。

  • 没有正式的测试套件。 它封装的是一个被爬取的第三方端点;只有测试套件大多只是测试 pytrends 和 Google 当前的响应结构,并不是测试这段代码。开发期间,每个工具都在真实的 Google Trends 数据上验证过。

许可证

MIT —— 见 LICENSE

Available Tools

5 tools
interest_by_regionA

Search interest for a keyword broken down by state/region within the given geo.

Args: keyword: a single search term. timeframe: pytrends timeframe string, e.g. "today 12-m". geo: ISO country code (e.g. "IN"), or "" for worldwide.

Returns: A list of records, one per state/region within the specified geo, each containing: - "geoName": the name of the state or region (e.g. "Maharashtra", "Delhi", "Karnataka" for India) - A column with the keyword name as the key: relative search interest (0-100 scale) for that region. Higher values indicate higher relative interest in that region compared to others in the same country. This is Google Trends' standard region-relative scale.

ParametersJSON Schema
NameRequiredDescriptionDefault
geoNoIN
keywordYes
timeframeNotoday 12-m

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full behavioral burden. It discloses the return shape (list of records with geoName and keyword column), explains the 0-100 relative scale, and notes that values are region-relative. This gives an agent a concrete expectation of the output's meaning. It does not mention side effects, but as a 'search' operation it is implicitly non-mutating. This level of disclosure is solid for a read-only retrieval tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a well-organized docstring with a purpose line, Args section, and Returns section. It avoids fluff, and the key scoping constraint is front-loaded. It is slightly longer than strictly necessary (e.g., repeating the 0-100 scale), but every sentence adds useful information, so it earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 parameters, no output schema, and no annotations, this description is quite complete. It covers parameter formats, return structure, and the meaning of the interest scale. One minor gap is that for a worldwide geo, it is not explicitly clarified that records will be per country rather than per state/region, but this is a minor ambiguity given the phrase 'state/region within the specified geo.'

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, and the description fully compensates. It defines 'keyword' as a single search term, 'timeframe' with an example format, and 'geo' with ISO code and 'worldwide' option, plus a default. All three parameters are explained beyond the schema, which only lists names and types. This is exemplary.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence clearly states the action ('Search interest for a keyword') and the resource/scope ('broken down by state/region within the given geo'). This distinguishes it from siblings like interest_over_time (time series) and related_queries/topics (associations). The purpose is unambiguous and actionable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies a use case (regional breakdown of interest) and provides parameter constraints, but it does not explicitly mention when not to use this tool or name alternative tools. It says 'within the given geo' which hints at context, but there is no direct comparison to siblings. Thus, usage guidance is implied rather than explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

interest_over_timeA

Relative Google search interest (0-100) over time for up to 5 keywords, compared side by side.

Args: keywords: 1-5 search terms to compare. Only the first 5 are used; additional keywords are silently dropped. timeframe: pytrends timeframe string, e.g. "today 12-m", "today 5-y", "now 7-d", or "YYYY-MM-DD YYYY-MM-DD". geo: ISO country code (e.g. "IN", "US"), or "" for worldwide.

Returns: A list of records, one per date, each containing: - "date": ISO date string - "isPartial": boolean indicating if the time period is incomplete (True for the most recent period) - One numeric key per keyword (0-100 relative interest value)

ParametersJSON Schema
NameRequiredDescriptionDefault
geoNoIN
keywordsYes
timeframeNotoday 12-m

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses important behaviors: it notes that only the first 5 keywords are used and additional ones are silently dropped, and it explains the 'isPartial' field indicating incomplete time periods. Since no annotations are provided, the description carries the full burden and adequately covers these behavioral nuances. It does not address rate limits or authentication, but for a read-only tool this is acceptable.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear Args and Returns sections, front-loads the core purpose, and uses concise bullet points. Every sentence adds information, such as the maximum keyword count and return fields, without unnecessary filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given there is no output schema and no annotations, the description compensates by fully specifying the return format (date, isPartial, numeric per-keyword values) and parameter constraints. It provides everything an agent needs to call the tool correctly, including examples and edge cases, making it contextually complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has minimal descriptions (0% coverage), but the description adds extensive semantic detail: keyword limit and silent drop behavior, example timeframe formats, and the meaning of an empty geo string. This far exceeds the bare schema, making parameter semantics highly clear.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns relative Google search interest (0-100) over time for up to 5 keywords compared side by side. This is distinct from siblings like related_queries or interest_by_region, which focus on different dimensions. The specific verb and resource make the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description presents a clear context (temporal interest comparison) but does not explicitly state when to use it over sibling tools. It provides parameter details but no guidance on selecting this tool versus related_queries or interest_by_region. The intended use is implied by the description, not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv0.1.0
    • First observedinterest_by_region
    • First observedinterest_over_time
    • First observedrelated_queries
    • First observedrelated_topics
    • First observedtrending_now

TDQS

A4.2/5.0

Scored across 5 tools

Disambiguation5/5

Each tool targets a distinct aspect of Google Trends data: time series, related queries, related topics, regional breakdown, and trending now. Even the two 'related' tools are clearly separated by query strings vs topic clusters, so there's no ambiguity in selecting the right tool.

Naming Consistency4/5

All tool names use snake_case and are descriptive, but they don't follow a unified verb-noun pattern. 'interest_over_time' and 'interest_by_region' are noun phrases, 'related_queries' and 'related_topics' are adjective-noun, and 'trending_now' is verb-adverb. Despite this slight mix, the naming is intuitive and predictable.

Tool Count5/5

Five tools is well-scoped for a Google Trends server, covering the core data endpoints without redundancy. Each tool serves a clear purpose, and the count is within the ideal range for a focused integration.

Completeness4/5

The toolkit covers the essential Google Trends operations: time series, related queries/topics, regional interest, and trending searches. Minor gaps exist, such as no multi-keyword comparison for related data or a dedicated city-level breakdown, but the core workflows are fully supported.

Maintenance

ActivityMaintained
ResponsivenessResponsive

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers