hasdata-google-trends-mcp 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hasdata_google_trends_mcp-1.0.0/.github/ISSUE_TEMPLATE/inaccuracy.md +21 -0
- hasdata_google_trends_mcp-1.0.0/.github/workflows/contract.yml +31 -0
- hasdata_google_trends_mcp-1.0.0/.github/workflows/publish.yml +65 -0
- hasdata_google_trends_mcp-1.0.0/.gitignore +11 -0
- hasdata_google_trends_mcp-1.0.0/LICENSE +21 -0
- hasdata_google_trends_mcp-1.0.0/PKG-INFO +360 -0
- hasdata_google_trends_mcp-1.0.0/README.md +346 -0
- hasdata_google_trends_mcp-1.0.0/glama.json +7 -0
- hasdata_google_trends_mcp-1.0.0/hasdata_google_trends_mcp/__init__.py +28 -0
- hasdata_google_trends_mcp-1.0.0/index.mjs +24 -0
- hasdata_google_trends_mcp-1.0.0/package.json +16 -0
- hasdata_google_trends_mcp-1.0.0/pyproject.toml +24 -0
- hasdata_google_trends_mcp-1.0.0/server.json +44 -0
- hasdata_google_trends_mcp-1.0.0/test/tools.test.mjs +132 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Something in the README is wrong
|
|
3
|
+
about: A tool table, a response sample or a documented behaviour does not match reality
|
|
4
|
+
labels: documentation
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Where in the README**
|
|
8
|
+
|
|
9
|
+
Section or heading.
|
|
10
|
+
|
|
11
|
+
**What it says**
|
|
12
|
+
|
|
13
|
+
Quote the line.
|
|
14
|
+
|
|
15
|
+
**The call you made**
|
|
16
|
+
|
|
17
|
+
Tool name and arguments, or the equivalent REST URL with your key removed.
|
|
18
|
+
|
|
19
|
+
**What came back**
|
|
20
|
+
|
|
21
|
+
Trimmed response, with anything private removed.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# The tool contract is checked on a schedule as well as on push, because the upstream tool list
|
|
2
|
+
# can change without a single commit in this repository.
|
|
3
|
+
name: tool contract
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
pull_request:
|
|
9
|
+
schedule:
|
|
10
|
+
- cron: '0 6 * * 1'
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
contract:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
timeout-minutes: 5
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: '22'
|
|
25
|
+
# Forks cannot read repository secrets. The suite skips its live checks when the key is
|
|
26
|
+
# absent, so a pull request from a fork stays green instead of failing for a reason the
|
|
27
|
+
# contributor cannot fix.
|
|
28
|
+
- name: Assert the tool list still matches the README
|
|
29
|
+
env:
|
|
30
|
+
HASDATA_API_KEY: ${{ secrets.HASDATA_API_KEY }}
|
|
31
|
+
run: npm test
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Publishes the npm and PyPI wrapper packages on a version tag, using OIDC
|
|
2
|
+
# trusted publishing. No NPM_TOKEN or PYPI_TOKEN is stored anywhere: GitHub
|
|
3
|
+
# mints a short-lived OIDC token per run, and npmjs.org / pypi.org accept it
|
|
4
|
+
# because this repo + workflow are configured as trusted publishers.
|
|
5
|
+
#
|
|
6
|
+
# One-time setup, done once per package on the registries (not in this repo):
|
|
7
|
+
# npmjs.org -> package settings -> Trusted Publisher -> GitHub Actions,
|
|
8
|
+
# repo HasData/google-trends-mcp, workflow publish.yml
|
|
9
|
+
# pypi.org -> the hasdata org -> Publishing -> add a trusted publisher
|
|
10
|
+
# (pending publisher works before the first release),
|
|
11
|
+
# repo HasData/google-trends-mcp, workflow publish.yml
|
|
12
|
+
#
|
|
13
|
+
# The MCP registry entry (com.hasdata/google-trends) is NOT published here. It uses
|
|
14
|
+
# domain auth, which would need the namespace-wide Ed25519 key as a secret in
|
|
15
|
+
# every repo. That key stays off CI; the registry entry is published by hand
|
|
16
|
+
# when server.json changes, after the package versions below are live.
|
|
17
|
+
#
|
|
18
|
+
# Release: bump nothing by hand. Tag the commit `vX.Y.Z` and push the tag; the
|
|
19
|
+
# tag is the single source of the version and is written into both manifests.
|
|
20
|
+
|
|
21
|
+
name: publish
|
|
22
|
+
|
|
23
|
+
on:
|
|
24
|
+
push:
|
|
25
|
+
tags: ['v*.*.*']
|
|
26
|
+
|
|
27
|
+
permissions:
|
|
28
|
+
contents: read
|
|
29
|
+
id-token: write
|
|
30
|
+
|
|
31
|
+
jobs:
|
|
32
|
+
npm:
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- uses: actions/setup-node@v4
|
|
37
|
+
with:
|
|
38
|
+
node-version: '22'
|
|
39
|
+
registry-url: 'https://registry.npmjs.org'
|
|
40
|
+
- name: Set version from the tag
|
|
41
|
+
run: npm version "${GITHUB_REF_NAME#v}" --no-git-tag-version --allow-same-version
|
|
42
|
+
- name: Publish to npm (OIDC, no token)
|
|
43
|
+
run: npm publish --access public
|
|
44
|
+
|
|
45
|
+
pypi:
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
- uses: actions/setup-python@v5
|
|
50
|
+
with:
|
|
51
|
+
python-version: '3.12'
|
|
52
|
+
- name: Set version from the tag
|
|
53
|
+
run: |
|
|
54
|
+
python - "${GITHUB_REF_NAME#v}" <<'PY'
|
|
55
|
+
import re, sys
|
|
56
|
+
v = sys.argv[1]
|
|
57
|
+
p = "pyproject.toml"
|
|
58
|
+
t = open(p, encoding="utf-8").read()
|
|
59
|
+
t = re.sub(r'(?m)^version = ".*"$', f'version = "{v}"', t, count=1)
|
|
60
|
+
open(p, "w", encoding="utf-8", newline="\n").write(t)
|
|
61
|
+
PY
|
|
62
|
+
- name: Build the wheel and sdist
|
|
63
|
+
run: pipx run build
|
|
64
|
+
- name: Publish to PyPI (OIDC, no token)
|
|
65
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HasData
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: hasdata-google-trends-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: MCP server for Google Trends through HasData's hosted API. No Google account.
|
|
5
|
+
Project-URL: Homepage, https://hasdata.com/apis/google-trends-api
|
|
6
|
+
Project-URL: Repository, https://github.com/HasData/google-trends-mcp
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: google-trends,hasdata,mcp,model-context-protocol,seo,trends
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Requires-Dist: mcp-proxy>=0.12.0
|
|
12
|
+
Requires-Dist: mcp<2,>=1.17
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# Google Trends MCP Server
|
|
16
|
+
|
|
17
|
+
<!-- mcp-name: com.hasdata/google-trends -->
|
|
18
|
+
|
|
19
|
+
A hosted Model Context Protocol (MCP) server that gives Claude, Cursor, Windsurf and any other MCP client one Google Trends tool. Pull interest over time, interest by region, and the rising and top related queries and topics for any term, all as structured JSON, with no scraping library to keep alive and no Google account.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
https://mcp.hasdata.com/api/mcp?apis=google_trends
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
[](https://glama.ai/mcp/servers/HasData/google-trends-mcp)
|
|
26
|
+
[](https://github.com/HasData/google-trends-mcp/actions/workflows/contract.yml)
|
|
27
|
+
[](https://modelcontextprotocol.io)
|
|
28
|
+
[](#tools)
|
|
29
|
+
[](LICENSE)
|
|
30
|
+
|
|
31
|
+
## Contents
|
|
32
|
+
|
|
33
|
+
- [What you need](#what-you-need)
|
|
34
|
+
- [Quick start](#quick-start)
|
|
35
|
+
- [Example prompts](#example-prompts)
|
|
36
|
+
- [Tools](#tools)
|
|
37
|
+
- [Errors and failure paths](#errors-and-failure-paths)
|
|
38
|
+
- [Pricing, free tier and limits](#pricing-free-tier-and-limits)
|
|
39
|
+
- [Tool selection](#tool-selection)
|
|
40
|
+
- [How it compares](#how-it-compares)
|
|
41
|
+
- [FAQ](#faq)
|
|
42
|
+
- [HasData links](#hasdata-links)
|
|
43
|
+
- [Development](#development)
|
|
44
|
+
- [Contributing](#contributing)
|
|
45
|
+
- [License](#license)
|
|
46
|
+
|
|
47
|
+
## What you need
|
|
48
|
+
|
|
49
|
+
An MCP client and a HasData API key from the [dashboard](https://app.hasdata.com/sign-up?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp), free to create with no card, and the trial covers about 200 calls at the 5-credit rate. This is a remote server, so the simplest path is a URL and an `x-api-key` header, with no container to run and no Google account anywhere in the flow. A client that only speaks stdio reaches it through a thin launcher, published as `@hasdata/google-trends-mcp` on npm and `hasdata-google-trends-mcp` on PyPI, shown below.
|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
The server URL is the same for every client. We run it hands-on in Claude Code and Claude Desktop. The other blocks follow each client's own documented format for a remote server.
|
|
54
|
+
|
|
55
|
+
| Field | Value |
|
|
56
|
+
| :--- | :--- |
|
|
57
|
+
| URL | `https://mcp.hasdata.com/api/mcp?apis=google_trends` |
|
|
58
|
+
| Transport | HTTP, streamable |
|
|
59
|
+
| Auth header | `x-api-key: HASDATA_API_KEY` |
|
|
60
|
+
|
|
61
|
+
Clients with OAuth support can add the same URL as a connector and sign in without putting a key in a config file.
|
|
62
|
+
|
|
63
|
+
<details>
|
|
64
|
+
<summary><b>Claude Code</b></summary>
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
claude mcp add --transport http google-trends "https://mcp.hasdata.com/api/mcp?apis=google_trends" \
|
|
68
|
+
--header "x-api-key: HASDATA_API_KEY"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
</details>
|
|
72
|
+
|
|
73
|
+
<details>
|
|
74
|
+
<summary><b>Claude Desktop</b></summary>
|
|
75
|
+
|
|
76
|
+
Settings, then Connectors, then Add custom connector, then paste `https://mcp.hasdata.com/api/mcp?apis=google_trends` and sign in.
|
|
77
|
+
|
|
78
|
+
For the config-file route, Claude Desktop loads only local (stdio) servers, so it reaches a remote server through a stdio launcher. The `@hasdata/google-trends-mcp` package is that launcher, and it reads the key from the environment. Add this to `claude_desktop_config.json`:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"google-trends": {
|
|
84
|
+
"command": "npx",
|
|
85
|
+
"args": ["-y", "@hasdata/google-trends-mcp"],
|
|
86
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For Python instead of Node, swap the launcher for the PyPI package, which `uvx` runs without a manual install:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"mcpServers": {
|
|
97
|
+
"google-trends": {
|
|
98
|
+
"command": "uvx",
|
|
99
|
+
"args": ["hasdata-google-trends-mcp"],
|
|
100
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
</details>
|
|
107
|
+
|
|
108
|
+
<details>
|
|
109
|
+
<summary><b>Cursor</b></summary>
|
|
110
|
+
|
|
111
|
+
`~/.cursor/mcp.json` for every project, or `.cursor/mcp.json` for one:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"mcpServers": {
|
|
116
|
+
"google-trends": {
|
|
117
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_trends",
|
|
118
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
</details>
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary><b>Windsurf</b></summary>
|
|
128
|
+
|
|
129
|
+
`~/.codeium/windsurf/mcp_config.json`. Windsurf calls the field `serverUrl`, not `url`:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"google-trends": {
|
|
135
|
+
"serverUrl": "https://mcp.hasdata.com/api/mcp?apis=google_trends",
|
|
136
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
</details>
|
|
143
|
+
|
|
144
|
+
<details>
|
|
145
|
+
<summary><b>VS Code</b></summary>
|
|
146
|
+
|
|
147
|
+
`.vscode/mcp.json` in the workspace:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"servers": {
|
|
152
|
+
"google-trends": {
|
|
153
|
+
"type": "http",
|
|
154
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_trends",
|
|
155
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
</details>
|
|
162
|
+
|
|
163
|
+
## Example prompts
|
|
164
|
+
|
|
165
|
+
Prompts, not code. Paste one in and the agent picks the tool itself. Each is annotated with the calls it takes, because every successful call costs 5 credits.
|
|
166
|
+
|
|
167
|
+
> Chart interest in "cold brew coffee" in the US over the past 12 months and tell me which weeks it peaked.
|
|
168
|
+
|
|
169
|
+
*One call, 5 credits. The weekly series comes back in a single request.*
|
|
170
|
+
|
|
171
|
+
> For "cold brew coffee" in the US, give me the rising related queries and flag the ones marked Breakout.
|
|
172
|
+
|
|
173
|
+
*One call, 5 credits.*
|
|
174
|
+
|
|
175
|
+
> Compare interest in "cold brew" against "iced coffee" worldwide over five years and say which one is growing.
|
|
176
|
+
|
|
177
|
+
*One call, 5 credits. The tool takes several terms in one timeseries request.*
|
|
178
|
+
|
|
179
|
+
> Show me interest in "sunscreen" by US state over the past 90 days so I can see where demand is highest.
|
|
180
|
+
|
|
181
|
+
*One call, 5 credits. This is the interest-by-region view at state granularity.*
|
|
182
|
+
|
|
183
|
+
A comparison across terms rides in one `timeseries` call. Region breakdowns, related queries and related topics are each their own `dataType`, so a prompt that wants a chart plus its rising queries is two calls.
|
|
184
|
+
|
|
185
|
+
## Tools
|
|
186
|
+
|
|
187
|
+
One tool, read-only. The sample below is trimmed from a real call, and the numbers move as the trend moves. Read it as a shape. The tool name links to its endpoint reference, which carries the full parameter list.
|
|
188
|
+
|
|
189
|
+
The sample is the payload, not the whole response. A `tools/call` result carries one text block, and that text is itself JSON holding `url`, `status`, `text` and `json`, with the scraped data under `json`. From a raw JSON-RPC response the path is `result.content[0].text`, parsed, then `.json`. A chat client unwraps that for you and code talking to the endpoint directly does not.
|
|
190
|
+
|
|
191
|
+
### Get Google Trends data
|
|
192
|
+
|
|
193
|
+
[`hasdata_google_trends_search_getTrendsData`](https://docs.hasdata.com/apis/google-trends/search?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp)
|
|
194
|
+
|
|
195
|
+
Interest over time, by region, or the related queries and topics for a term.
|
|
196
|
+
|
|
197
|
+
| Parameter | Type | Required | Notes |
|
|
198
|
+
| :--- | :--- | :--- | :--- |
|
|
199
|
+
| `q` | string | yes | The search term. `timeseries` and `geoMap` take up to 5 comma-separated terms to compare, and a sixth is rejected with a 400 |
|
|
200
|
+
| `dataType` | string | | `timeseries` by default, plus `geoMap`, `relatedTopics` and `relatedQueries`. The two related types take a single term only |
|
|
201
|
+
| `date` | string | | A window such as `now 7-d`, `today 12-m`, `today 5-y` or `all`, or a custom `yyyy-mm-dd yyyy-mm-dd` range |
|
|
202
|
+
| `geo` | string | | A location code such as `US` or `US-CA`. Worldwide when empty |
|
|
203
|
+
| `region` | string | | Granularity for `geoMap` only: `country`, `region` (subregion), `dma` (metro) or `city`. The default depends on `geo`, `country` worldwide and finer once a `geo` is set |
|
|
204
|
+
| `cat` | string | | Category id to narrow the term. `0` is all categories |
|
|
205
|
+
| `gprop` | string | | The Google property: `images`, `news`, `froogle` (Shopping) or `youtube`. Web search when empty |
|
|
206
|
+
| `tz` | number | | Time-zone offset in minutes, default `420` (PDT). Shifts how hourly ranges are bucketed |
|
|
207
|
+
|
|
208
|
+
The response key depends on `dataType`. `timeseries` returns `interestOverTime.timelineData`, `geoMap` returns interest by region, and the related types return `relatedQueries` or `relatedTopics`, each split into `rising` and `top`. Read the key that matches the type you asked for.
|
|
209
|
+
|
|
210
|
+
`timeseries` (the default) returns a value from 0 to 100 for each point, both as a string and pre-parsed in `extractedValue`. The most recent point often carries `isPartial: true`, meaning the week is still filling in. Drop it before you compute a trend, or the last bar reads as a dip that is not real.
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"interestOverTime": {
|
|
215
|
+
"timelineData": [
|
|
216
|
+
{ "date": "Apr 12 – 18, 2026", "timestamp": "1775952000", "isPartial": false,
|
|
217
|
+
"values": [{ "query": "cold brew coffee", "value": "100", "extractedValue": 100, "hasData": true }] },
|
|
218
|
+
{ "date": "Aug 23 – 29, 2026", "timestamp": "1787443200", "isPartial": true,
|
|
219
|
+
"values": [{ "query": "cold brew coffee", "value": "44", "extractedValue": 44, "hasData": true }] }
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
`relatedQueries` splits into `rising` and `top`. A rising entry reads as a percentage like `+300%`, or `Breakout` for a jump too large to score, and `extractedValue` gives the number behind it. A `Breakout` comes back with a sentinel `extractedValue` well above any real percentage, so sort on the string label, not on the raw number.
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"relatedQueries": {
|
|
230
|
+
"rising": [
|
|
231
|
+
{ "query": "organic cold brew coffee", "value": "+300%", "extractedValue": 300, "link": "https://trends.google.com/trends/explore?q=organic+cold+brew+coffee&date=today+12-m&geo=US" }
|
|
232
|
+
],
|
|
233
|
+
"top": [
|
|
234
|
+
{ "query": "how to cold brew coffee", "value": "100", "extractedValue": 100, "link": "https://trends.google.com/trends/explore?q=how+to+cold+brew+coffee&date=today+12-m&geo=US" }
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The [endpoint reference](https://docs.hasdata.com/apis/google-trends/search?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) lists every `geo`, `cat` and date format the tool accepts.
|
|
241
|
+
|
|
242
|
+
## Errors and failure paths
|
|
243
|
+
|
|
244
|
+
Your client almost never sees an HTTP error code from a tool call. The MCP layer answers 200 and puts the failure inside the result, with `isError` set to `true` and the reason as text. The agent reads a message where you might expect a status line.
|
|
245
|
+
|
|
246
|
+
**A wrong key surfaces as tool output, not as a failed connection.** `tools/list` accepts any non-empty key and returns the tool, so the client completes its handshake and shows green. The first tool call then comes back with `isError: true` and the text `HasData API error: 401 Unauthorized`. Watch for that string, because nothing earlier in the flow reports the problem.
|
|
247
|
+
|
|
248
|
+
**A missing key is the one real HTTP error.** Authorization runs before any tool, and the connection itself fails with 401. CORS headers are present, and a browser client reads the status and not an opaque network failure.
|
|
249
|
+
|
|
250
|
+
**An argument that breaks the tool's schema is rejected before it becomes a scrape.** The server answers with `isError: true` and the text `MCP error -32602: Input validation error`, naming the offending field. Nothing is fetched and nothing is charged.
|
|
251
|
+
|
|
252
|
+
**A term with too little search volume returns a successful result with the data arrays empty**, not an error. Google Trends has nothing to show for a rare term, and `requestMetadata.status` still reads `ok`. Test for the points before you chart them.
|
|
253
|
+
|
|
254
|
+
**An identifier the platform rejects returns 400** with `requestMetadata.status` set to `error`. An unknown `geo` or `cat` value is the usual way to see this.
|
|
255
|
+
|
|
256
|
+
Results that carry data also carry a `requestMetadata.id` worth quoting in support.
|
|
257
|
+
|
|
258
|
+
## Pricing, free tier and limits
|
|
259
|
+
|
|
260
|
+
Every Google Trends call costs **5 credits per successful call**. Response size does not change the price. A five-year weekly series costs the same as a single week.
|
|
261
|
+
|
|
262
|
+
The free trial is **1,000 credits over 30 days with no card**, which is 200 Google Trends calls. After that an active account keeps getting 100 credits topped up each day whenever its balance drops below 100, so a low-volume agent runs on the free tier indefinitely.
|
|
263
|
+
|
|
264
|
+
Paid plans start at **$49 a month** for 200,000 credits, which is 40,000 calls. The unit price falls with volume, from **$1.23 per 1,000 calls** on the entry plan to **$0.50** on Business, **$0.42** on Growth and **$0.37** on the largest [high-volume plans](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp).
|
|
265
|
+
|
|
266
|
+
Your plan also sets concurrency. The free trial allows 1 request at a time, Startup 15, Business 30, Growth 50, and the high-volume plans run from 200 to 1,500. Handle the overflow case defensively in anything unattended.
|
|
267
|
+
|
|
268
|
+
A request that comes back non-200 is not billed. A successful call that finds nothing is still a call.
|
|
269
|
+
|
|
270
|
+
## Tool selection
|
|
271
|
+
|
|
272
|
+
The `apis` query parameter decides which tools your agent sees. Fewer tools means less context spent on tool definitions, and fewer chances for the model to reach for the wrong one.
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
?apis=google_trends the one tool in this repo
|
|
276
|
+
?apis=google_trends,google_serp add Google search
|
|
277
|
+
?apis=google_trends,youtube trends plus YouTube
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The parameter takes provider names like `google_trends` and individual API names. Misspelled names are ignored. If every name is wrong the request fails with 400, and the body lists both what it did not recognise and every valid value. Drop the parameter and the same endpoint exposes all 57 HasData tools.
|
|
281
|
+
|
|
282
|
+
## How it compares
|
|
283
|
+
|
|
284
|
+
Google does not publish a public Trends API. The two common routes are the unofficial `pytrends` library, which reverse-engineers the same internal endpoints and breaks when Google changes them or rate-limits the caller, and rolling your own scraper. This server does that work behind a stable schema.
|
|
285
|
+
|
|
286
|
+
| | pytrends / DIY | This server |
|
|
287
|
+
| :--- | :--- | :--- |
|
|
288
|
+
| Official support | None, Google ships no Trends API | Maintained schema over the same data |
|
|
289
|
+
| Rate limits and 429s | Frequent and yours to manage | Handled behind the endpoint |
|
|
290
|
+
| Output | Pandas frames or raw payloads to reshape | Structured JSON, values pre-parsed |
|
|
291
|
+
| Setup | A Python environment and upkeep as it breaks | One key and one URL |
|
|
292
|
+
| Cost | Free, when it works | Paid past the trial, 5 credits a call |
|
|
293
|
+
|
|
294
|
+
If you already run `pytrends` at low volume and do not mind fixing it when it breaks, that stays the free answer. This server is for agents and pipelines that need the data to arrive the same shape every time.
|
|
295
|
+
|
|
296
|
+
## FAQ
|
|
297
|
+
|
|
298
|
+
### Is there an official Google Trends API?
|
|
299
|
+
|
|
300
|
+
No. Google has never shipped a public Trends API. Every option reads the same internal endpoints that the trends.google.com site uses. This one is maintained by HasData and returns the result as structured JSON.
|
|
301
|
+
|
|
302
|
+
### What is a Google Trends MCP server?
|
|
303
|
+
|
|
304
|
+
A server that exposes Google Trends as a tool an AI client can call. The client sends a tool call over the Model Context Protocol, the server fetches the data and returns structured JSON, and the model works with the result. This one exposes a single tool and runs remotely, so the client connects to a URL and starts no local process.
|
|
305
|
+
|
|
306
|
+
### Do the numbers mean absolute search volume?
|
|
307
|
+
|
|
308
|
+
No, and neither does Google Trends itself. The values are relative interest scaled 0 to 100 within the query, window and region you asked for. Use them for shape and comparison, not as a count of searches.
|
|
309
|
+
|
|
310
|
+
### Why is the last data point lower than the rest?
|
|
311
|
+
|
|
312
|
+
The most recent bucket is usually still filling in and comes back with `isPartial: true`. Drop it before computing a trend.
|
|
313
|
+
|
|
314
|
+
### Can I compare several terms at once?
|
|
315
|
+
|
|
316
|
+
Yes, in `timeseries` and `geoMap`. Pass the terms comma-separated in `q`. The related-query and related-topic types take a single term.
|
|
317
|
+
|
|
318
|
+
### Can I use this together with other HasData APIs?
|
|
319
|
+
|
|
320
|
+
Yes. The `apis` parameter takes a list, and `?apis=google_trends,google_serp` gives your agent Trends plus Google search. [Drop the parameter](#tool-selection) and you get everything.
|
|
321
|
+
|
|
322
|
+
### Compliance and personal data
|
|
323
|
+
|
|
324
|
+
HasData accesses publicly available data only. A platform's terms may restrict automated access, and you are responsible for your own compliance.
|
|
325
|
+
|
|
326
|
+
## HasData links
|
|
327
|
+
|
|
328
|
+
| | |
|
|
329
|
+
| :--- | :--- |
|
|
330
|
+
| Product page and request builder | [Google Trends API](https://hasdata.com/apis/google-trends-api?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
331
|
+
| Server documentation | [MCP server docs](https://docs.hasdata.com/mcp-server?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
332
|
+
| All 57 tools in one server | [HasData/hasdata-mcp](https://github.com/HasData/hasdata-mcp) |
|
|
333
|
+
| Client walkthroughs | [MCP clients and integrations](https://hasdata.com/integrations/mcp?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
334
|
+
| Everything else we scrape | [Google Trends API and 54 more](https://hasdata.com/apis/?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
335
|
+
| Plans and credit costs | [Plans and credit costs](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
336
|
+
| Keys and usage | [HasData dashboard](https://app.hasdata.com?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
337
|
+
|
|
338
|
+
## Development
|
|
339
|
+
|
|
340
|
+
This repository is configuration and documentation for a remote server. There is no build step and nothing to containerize.
|
|
341
|
+
|
|
342
|
+
The tests in `test/` assert the tool contract, the part that can break without a commit here. They check that `?apis=google_trends` returns exactly one tool, that it still declares its required parameter, that the name has not changed, and that the key in use is actually accepted. That last check calls the tool for real and costs 5 credits, which is the price of a canary that can fail for the right reason.
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# macOS and Linux
|
|
346
|
+
HASDATA_API_KEY=your_key_here npm test
|
|
347
|
+
|
|
348
|
+
# Windows PowerShell
|
|
349
|
+
$env:HASDATA_API_KEY="your_key_here"; npm test
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
The same suite runs in CI on every push and once a week on a schedule, because the upstream tool list can change without anyone touching this repository. A failure means the tool list moved, the key stopped working, or the endpoint was unreachable, and the assertion message says which.
|
|
353
|
+
|
|
354
|
+
## Contributing
|
|
355
|
+
|
|
356
|
+
Corrections to the parameter table and the response sample are the most useful contribution, because those are the parts that drift. Include the call you made and the response you got. Pull requests from forks run the suite without a key, and the live checks skip instead of going red.
|
|
357
|
+
|
|
358
|
+
## License
|
|
359
|
+
|
|
360
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Google Trends MCP Server
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: com.hasdata/google-trends -->
|
|
4
|
+
|
|
5
|
+
A hosted Model Context Protocol (MCP) server that gives Claude, Cursor, Windsurf and any other MCP client one Google Trends tool. Pull interest over time, interest by region, and the rising and top related queries and topics for any term, all as structured JSON, with no scraping library to keep alive and no Google account.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
https://mcp.hasdata.com/api/mcp?apis=google_trends
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
[](https://glama.ai/mcp/servers/HasData/google-trends-mcp)
|
|
12
|
+
[](https://github.com/HasData/google-trends-mcp/actions/workflows/contract.yml)
|
|
13
|
+
[](https://modelcontextprotocol.io)
|
|
14
|
+
[](#tools)
|
|
15
|
+
[](LICENSE)
|
|
16
|
+
|
|
17
|
+
## Contents
|
|
18
|
+
|
|
19
|
+
- [What you need](#what-you-need)
|
|
20
|
+
- [Quick start](#quick-start)
|
|
21
|
+
- [Example prompts](#example-prompts)
|
|
22
|
+
- [Tools](#tools)
|
|
23
|
+
- [Errors and failure paths](#errors-and-failure-paths)
|
|
24
|
+
- [Pricing, free tier and limits](#pricing-free-tier-and-limits)
|
|
25
|
+
- [Tool selection](#tool-selection)
|
|
26
|
+
- [How it compares](#how-it-compares)
|
|
27
|
+
- [FAQ](#faq)
|
|
28
|
+
- [HasData links](#hasdata-links)
|
|
29
|
+
- [Development](#development)
|
|
30
|
+
- [Contributing](#contributing)
|
|
31
|
+
- [License](#license)
|
|
32
|
+
|
|
33
|
+
## What you need
|
|
34
|
+
|
|
35
|
+
An MCP client and a HasData API key from the [dashboard](https://app.hasdata.com/sign-up?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp), free to create with no card, and the trial covers about 200 calls at the 5-credit rate. This is a remote server, so the simplest path is a URL and an `x-api-key` header, with no container to run and no Google account anywhere in the flow. A client that only speaks stdio reaches it through a thin launcher, published as `@hasdata/google-trends-mcp` on npm and `hasdata-google-trends-mcp` on PyPI, shown below.
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
The server URL is the same for every client. We run it hands-on in Claude Code and Claude Desktop. The other blocks follow each client's own documented format for a remote server.
|
|
40
|
+
|
|
41
|
+
| Field | Value |
|
|
42
|
+
| :--- | :--- |
|
|
43
|
+
| URL | `https://mcp.hasdata.com/api/mcp?apis=google_trends` |
|
|
44
|
+
| Transport | HTTP, streamable |
|
|
45
|
+
| Auth header | `x-api-key: HASDATA_API_KEY` |
|
|
46
|
+
|
|
47
|
+
Clients with OAuth support can add the same URL as a connector and sign in without putting a key in a config file.
|
|
48
|
+
|
|
49
|
+
<details>
|
|
50
|
+
<summary><b>Claude Code</b></summary>
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
claude mcp add --transport http google-trends "https://mcp.hasdata.com/api/mcp?apis=google_trends" \
|
|
54
|
+
--header "x-api-key: HASDATA_API_KEY"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
<details>
|
|
60
|
+
<summary><b>Claude Desktop</b></summary>
|
|
61
|
+
|
|
62
|
+
Settings, then Connectors, then Add custom connector, then paste `https://mcp.hasdata.com/api/mcp?apis=google_trends` and sign in.
|
|
63
|
+
|
|
64
|
+
For the config-file route, Claude Desktop loads only local (stdio) servers, so it reaches a remote server through a stdio launcher. The `@hasdata/google-trends-mcp` package is that launcher, and it reads the key from the environment. Add this to `claude_desktop_config.json`:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"google-trends": {
|
|
70
|
+
"command": "npx",
|
|
71
|
+
"args": ["-y", "@hasdata/google-trends-mcp"],
|
|
72
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For Python instead of Node, swap the launcher for the PyPI package, which `uvx` runs without a manual install:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"google-trends": {
|
|
84
|
+
"command": "uvx",
|
|
85
|
+
"args": ["hasdata-google-trends-mcp"],
|
|
86
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
</details>
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
<summary><b>Cursor</b></summary>
|
|
96
|
+
|
|
97
|
+
`~/.cursor/mcp.json` for every project, or `.cursor/mcp.json` for one:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"mcpServers": {
|
|
102
|
+
"google-trends": {
|
|
103
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_trends",
|
|
104
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
</details>
|
|
111
|
+
|
|
112
|
+
<details>
|
|
113
|
+
<summary><b>Windsurf</b></summary>
|
|
114
|
+
|
|
115
|
+
`~/.codeium/windsurf/mcp_config.json`. Windsurf calls the field `serverUrl`, not `url`:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"google-trends": {
|
|
121
|
+
"serverUrl": "https://mcp.hasdata.com/api/mcp?apis=google_trends",
|
|
122
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
</details>
|
|
129
|
+
|
|
130
|
+
<details>
|
|
131
|
+
<summary><b>VS Code</b></summary>
|
|
132
|
+
|
|
133
|
+
`.vscode/mcp.json` in the workspace:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"servers": {
|
|
138
|
+
"google-trends": {
|
|
139
|
+
"type": "http",
|
|
140
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_trends",
|
|
141
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
</details>
|
|
148
|
+
|
|
149
|
+
## Example prompts
|
|
150
|
+
|
|
151
|
+
Prompts, not code. Paste one in and the agent picks the tool itself. Each is annotated with the calls it takes, because every successful call costs 5 credits.
|
|
152
|
+
|
|
153
|
+
> Chart interest in "cold brew coffee" in the US over the past 12 months and tell me which weeks it peaked.
|
|
154
|
+
|
|
155
|
+
*One call, 5 credits. The weekly series comes back in a single request.*
|
|
156
|
+
|
|
157
|
+
> For "cold brew coffee" in the US, give me the rising related queries and flag the ones marked Breakout.
|
|
158
|
+
|
|
159
|
+
*One call, 5 credits.*
|
|
160
|
+
|
|
161
|
+
> Compare interest in "cold brew" against "iced coffee" worldwide over five years and say which one is growing.
|
|
162
|
+
|
|
163
|
+
*One call, 5 credits. The tool takes several terms in one timeseries request.*
|
|
164
|
+
|
|
165
|
+
> Show me interest in "sunscreen" by US state over the past 90 days so I can see where demand is highest.
|
|
166
|
+
|
|
167
|
+
*One call, 5 credits. This is the interest-by-region view at state granularity.*
|
|
168
|
+
|
|
169
|
+
A comparison across terms rides in one `timeseries` call. Region breakdowns, related queries and related topics are each their own `dataType`, so a prompt that wants a chart plus its rising queries is two calls.
|
|
170
|
+
|
|
171
|
+
## Tools
|
|
172
|
+
|
|
173
|
+
One tool, read-only. The sample below is trimmed from a real call, and the numbers move as the trend moves. Read it as a shape. The tool name links to its endpoint reference, which carries the full parameter list.
|
|
174
|
+
|
|
175
|
+
The sample is the payload, not the whole response. A `tools/call` result carries one text block, and that text is itself JSON holding `url`, `status`, `text` and `json`, with the scraped data under `json`. From a raw JSON-RPC response the path is `result.content[0].text`, parsed, then `.json`. A chat client unwraps that for you and code talking to the endpoint directly does not.
|
|
176
|
+
|
|
177
|
+
### Get Google Trends data
|
|
178
|
+
|
|
179
|
+
[`hasdata_google_trends_search_getTrendsData`](https://docs.hasdata.com/apis/google-trends/search?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp)
|
|
180
|
+
|
|
181
|
+
Interest over time, by region, or the related queries and topics for a term.
|
|
182
|
+
|
|
183
|
+
| Parameter | Type | Required | Notes |
|
|
184
|
+
| :--- | :--- | :--- | :--- |
|
|
185
|
+
| `q` | string | yes | The search term. `timeseries` and `geoMap` take up to 5 comma-separated terms to compare, and a sixth is rejected with a 400 |
|
|
186
|
+
| `dataType` | string | | `timeseries` by default, plus `geoMap`, `relatedTopics` and `relatedQueries`. The two related types take a single term only |
|
|
187
|
+
| `date` | string | | A window such as `now 7-d`, `today 12-m`, `today 5-y` or `all`, or a custom `yyyy-mm-dd yyyy-mm-dd` range |
|
|
188
|
+
| `geo` | string | | A location code such as `US` or `US-CA`. Worldwide when empty |
|
|
189
|
+
| `region` | string | | Granularity for `geoMap` only: `country`, `region` (subregion), `dma` (metro) or `city`. The default depends on `geo`, `country` worldwide and finer once a `geo` is set |
|
|
190
|
+
| `cat` | string | | Category id to narrow the term. `0` is all categories |
|
|
191
|
+
| `gprop` | string | | The Google property: `images`, `news`, `froogle` (Shopping) or `youtube`. Web search when empty |
|
|
192
|
+
| `tz` | number | | Time-zone offset in minutes, default `420` (PDT). Shifts how hourly ranges are bucketed |
|
|
193
|
+
|
|
194
|
+
The response key depends on `dataType`. `timeseries` returns `interestOverTime.timelineData`, `geoMap` returns interest by region, and the related types return `relatedQueries` or `relatedTopics`, each split into `rising` and `top`. Read the key that matches the type you asked for.
|
|
195
|
+
|
|
196
|
+
`timeseries` (the default) returns a value from 0 to 100 for each point, both as a string and pre-parsed in `extractedValue`. The most recent point often carries `isPartial: true`, meaning the week is still filling in. Drop it before you compute a trend, or the last bar reads as a dip that is not real.
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"interestOverTime": {
|
|
201
|
+
"timelineData": [
|
|
202
|
+
{ "date": "Apr 12 – 18, 2026", "timestamp": "1775952000", "isPartial": false,
|
|
203
|
+
"values": [{ "query": "cold brew coffee", "value": "100", "extractedValue": 100, "hasData": true }] },
|
|
204
|
+
{ "date": "Aug 23 – 29, 2026", "timestamp": "1787443200", "isPartial": true,
|
|
205
|
+
"values": [{ "query": "cold brew coffee", "value": "44", "extractedValue": 44, "hasData": true }] }
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`relatedQueries` splits into `rising` and `top`. A rising entry reads as a percentage like `+300%`, or `Breakout` for a jump too large to score, and `extractedValue` gives the number behind it. A `Breakout` comes back with a sentinel `extractedValue` well above any real percentage, so sort on the string label, not on the raw number.
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"relatedQueries": {
|
|
216
|
+
"rising": [
|
|
217
|
+
{ "query": "organic cold brew coffee", "value": "+300%", "extractedValue": 300, "link": "https://trends.google.com/trends/explore?q=organic+cold+brew+coffee&date=today+12-m&geo=US" }
|
|
218
|
+
],
|
|
219
|
+
"top": [
|
|
220
|
+
{ "query": "how to cold brew coffee", "value": "100", "extractedValue": 100, "link": "https://trends.google.com/trends/explore?q=how+to+cold+brew+coffee&date=today+12-m&geo=US" }
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
The [endpoint reference](https://docs.hasdata.com/apis/google-trends/search?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) lists every `geo`, `cat` and date format the tool accepts.
|
|
227
|
+
|
|
228
|
+
## Errors and failure paths
|
|
229
|
+
|
|
230
|
+
Your client almost never sees an HTTP error code from a tool call. The MCP layer answers 200 and puts the failure inside the result, with `isError` set to `true` and the reason as text. The agent reads a message where you might expect a status line.
|
|
231
|
+
|
|
232
|
+
**A wrong key surfaces as tool output, not as a failed connection.** `tools/list` accepts any non-empty key and returns the tool, so the client completes its handshake and shows green. The first tool call then comes back with `isError: true` and the text `HasData API error: 401 Unauthorized`. Watch for that string, because nothing earlier in the flow reports the problem.
|
|
233
|
+
|
|
234
|
+
**A missing key is the one real HTTP error.** Authorization runs before any tool, and the connection itself fails with 401. CORS headers are present, and a browser client reads the status and not an opaque network failure.
|
|
235
|
+
|
|
236
|
+
**An argument that breaks the tool's schema is rejected before it becomes a scrape.** The server answers with `isError: true` and the text `MCP error -32602: Input validation error`, naming the offending field. Nothing is fetched and nothing is charged.
|
|
237
|
+
|
|
238
|
+
**A term with too little search volume returns a successful result with the data arrays empty**, not an error. Google Trends has nothing to show for a rare term, and `requestMetadata.status` still reads `ok`. Test for the points before you chart them.
|
|
239
|
+
|
|
240
|
+
**An identifier the platform rejects returns 400** with `requestMetadata.status` set to `error`. An unknown `geo` or `cat` value is the usual way to see this.
|
|
241
|
+
|
|
242
|
+
Results that carry data also carry a `requestMetadata.id` worth quoting in support.
|
|
243
|
+
|
|
244
|
+
## Pricing, free tier and limits
|
|
245
|
+
|
|
246
|
+
Every Google Trends call costs **5 credits per successful call**. Response size does not change the price. A five-year weekly series costs the same as a single week.
|
|
247
|
+
|
|
248
|
+
The free trial is **1,000 credits over 30 days with no card**, which is 200 Google Trends calls. After that an active account keeps getting 100 credits topped up each day whenever its balance drops below 100, so a low-volume agent runs on the free tier indefinitely.
|
|
249
|
+
|
|
250
|
+
Paid plans start at **$49 a month** for 200,000 credits, which is 40,000 calls. The unit price falls with volume, from **$1.23 per 1,000 calls** on the entry plan to **$0.50** on Business, **$0.42** on Growth and **$0.37** on the largest [high-volume plans](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp).
|
|
251
|
+
|
|
252
|
+
Your plan also sets concurrency. The free trial allows 1 request at a time, Startup 15, Business 30, Growth 50, and the high-volume plans run from 200 to 1,500. Handle the overflow case defensively in anything unattended.
|
|
253
|
+
|
|
254
|
+
A request that comes back non-200 is not billed. A successful call that finds nothing is still a call.
|
|
255
|
+
|
|
256
|
+
## Tool selection
|
|
257
|
+
|
|
258
|
+
The `apis` query parameter decides which tools your agent sees. Fewer tools means less context spent on tool definitions, and fewer chances for the model to reach for the wrong one.
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
?apis=google_trends the one tool in this repo
|
|
262
|
+
?apis=google_trends,google_serp add Google search
|
|
263
|
+
?apis=google_trends,youtube trends plus YouTube
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
The parameter takes provider names like `google_trends` and individual API names. Misspelled names are ignored. If every name is wrong the request fails with 400, and the body lists both what it did not recognise and every valid value. Drop the parameter and the same endpoint exposes all 57 HasData tools.
|
|
267
|
+
|
|
268
|
+
## How it compares
|
|
269
|
+
|
|
270
|
+
Google does not publish a public Trends API. The two common routes are the unofficial `pytrends` library, which reverse-engineers the same internal endpoints and breaks when Google changes them or rate-limits the caller, and rolling your own scraper. This server does that work behind a stable schema.
|
|
271
|
+
|
|
272
|
+
| | pytrends / DIY | This server |
|
|
273
|
+
| :--- | :--- | :--- |
|
|
274
|
+
| Official support | None, Google ships no Trends API | Maintained schema over the same data |
|
|
275
|
+
| Rate limits and 429s | Frequent and yours to manage | Handled behind the endpoint |
|
|
276
|
+
| Output | Pandas frames or raw payloads to reshape | Structured JSON, values pre-parsed |
|
|
277
|
+
| Setup | A Python environment and upkeep as it breaks | One key and one URL |
|
|
278
|
+
| Cost | Free, when it works | Paid past the trial, 5 credits a call |
|
|
279
|
+
|
|
280
|
+
If you already run `pytrends` at low volume and do not mind fixing it when it breaks, that stays the free answer. This server is for agents and pipelines that need the data to arrive the same shape every time.
|
|
281
|
+
|
|
282
|
+
## FAQ
|
|
283
|
+
|
|
284
|
+
### Is there an official Google Trends API?
|
|
285
|
+
|
|
286
|
+
No. Google has never shipped a public Trends API. Every option reads the same internal endpoints that the trends.google.com site uses. This one is maintained by HasData and returns the result as structured JSON.
|
|
287
|
+
|
|
288
|
+
### What is a Google Trends MCP server?
|
|
289
|
+
|
|
290
|
+
A server that exposes Google Trends as a tool an AI client can call. The client sends a tool call over the Model Context Protocol, the server fetches the data and returns structured JSON, and the model works with the result. This one exposes a single tool and runs remotely, so the client connects to a URL and starts no local process.
|
|
291
|
+
|
|
292
|
+
### Do the numbers mean absolute search volume?
|
|
293
|
+
|
|
294
|
+
No, and neither does Google Trends itself. The values are relative interest scaled 0 to 100 within the query, window and region you asked for. Use them for shape and comparison, not as a count of searches.
|
|
295
|
+
|
|
296
|
+
### Why is the last data point lower than the rest?
|
|
297
|
+
|
|
298
|
+
The most recent bucket is usually still filling in and comes back with `isPartial: true`. Drop it before computing a trend.
|
|
299
|
+
|
|
300
|
+
### Can I compare several terms at once?
|
|
301
|
+
|
|
302
|
+
Yes, in `timeseries` and `geoMap`. Pass the terms comma-separated in `q`. The related-query and related-topic types take a single term.
|
|
303
|
+
|
|
304
|
+
### Can I use this together with other HasData APIs?
|
|
305
|
+
|
|
306
|
+
Yes. The `apis` parameter takes a list, and `?apis=google_trends,google_serp` gives your agent Trends plus Google search. [Drop the parameter](#tool-selection) and you get everything.
|
|
307
|
+
|
|
308
|
+
### Compliance and personal data
|
|
309
|
+
|
|
310
|
+
HasData accesses publicly available data only. A platform's terms may restrict automated access, and you are responsible for your own compliance.
|
|
311
|
+
|
|
312
|
+
## HasData links
|
|
313
|
+
|
|
314
|
+
| | |
|
|
315
|
+
| :--- | :--- |
|
|
316
|
+
| Product page and request builder | [Google Trends API](https://hasdata.com/apis/google-trends-api?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
317
|
+
| Server documentation | [MCP server docs](https://docs.hasdata.com/mcp-server?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
318
|
+
| All 57 tools in one server | [HasData/hasdata-mcp](https://github.com/HasData/hasdata-mcp) |
|
|
319
|
+
| Client walkthroughs | [MCP clients and integrations](https://hasdata.com/integrations/mcp?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
320
|
+
| Everything else we scrape | [Google Trends API and 54 more](https://hasdata.com/apis/?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
321
|
+
| Plans and credit costs | [Plans and credit costs](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
322
|
+
| Keys and usage | [HasData dashboard](https://app.hasdata.com?utm_source=github&utm_medium=syndication&utm_campaign=google-trends-mcp) |
|
|
323
|
+
|
|
324
|
+
## Development
|
|
325
|
+
|
|
326
|
+
This repository is configuration and documentation for a remote server. There is no build step and nothing to containerize.
|
|
327
|
+
|
|
328
|
+
The tests in `test/` assert the tool contract, the part that can break without a commit here. They check that `?apis=google_trends` returns exactly one tool, that it still declares its required parameter, that the name has not changed, and that the key in use is actually accepted. That last check calls the tool for real and costs 5 credits, which is the price of a canary that can fail for the right reason.
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
# macOS and Linux
|
|
332
|
+
HASDATA_API_KEY=your_key_here npm test
|
|
333
|
+
|
|
334
|
+
# Windows PowerShell
|
|
335
|
+
$env:HASDATA_API_KEY="your_key_here"; npm test
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
The same suite runs in CI on every push and once a week on a schedule, because the upstream tool list can change without anyone touching this repository. A failure means the tool list moved, the key stopped working, or the endpoint was unreachable, and the assertion message says which.
|
|
339
|
+
|
|
340
|
+
## Contributing
|
|
341
|
+
|
|
342
|
+
Corrections to the parameter table and the response sample are the most useful contribution, because those are the parts that drift. Include the call you made and the response you got. Pull requests from forks run the suite without a key, and the live checks skip instead of going red.
|
|
343
|
+
|
|
344
|
+
## License
|
|
345
|
+
|
|
346
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Thin launcher for HasData's hosted Google Trends MCP server.
|
|
2
|
+
|
|
3
|
+
Connects an MCP client to the remote streamable-HTTP endpoint through mcp-proxy.
|
|
4
|
+
The server runs on HasData's infrastructure. This package only proxies stdio to it.
|
|
5
|
+
"""
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
import subprocess
|
|
9
|
+
|
|
10
|
+
URL = "https://mcp.hasdata.com/api/mcp?apis=google_trends"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main() -> None:
|
|
14
|
+
key = os.environ.get("HASDATA_API_KEY")
|
|
15
|
+
if not key:
|
|
16
|
+
sys.stderr.write(
|
|
17
|
+
"HASDATA_API_KEY is not set. Create a free key at https://app.hasdata.com "
|
|
18
|
+
"and set HASDATA_API_KEY.\n"
|
|
19
|
+
)
|
|
20
|
+
raise SystemExit(1)
|
|
21
|
+
args = [
|
|
22
|
+
sys.executable, "-m", "mcp_proxy", URL,
|
|
23
|
+
"--transport=streamablehttp",
|
|
24
|
+
"--headers", "x-api-key", key,
|
|
25
|
+
]
|
|
26
|
+
rc = subprocess.call(args)
|
|
27
|
+
# subprocess returns -N when mcp_proxy is killed by signal N; map to 128+N.
|
|
28
|
+
raise SystemExit(rc if rc >= 0 else 128 - rc)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Thin launcher: connects an MCP client to HasData's hosted Google Trends MCP server
|
|
3
|
+
// (streamable HTTP) through the mcp-remote stdio bridge. The server runs remotely.
|
|
4
|
+
// This package only proxies, so nothing here scrapes anything.
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
|
|
9
|
+
const URL = 'https://mcp.hasdata.com/api/mcp?apis=google_trends';
|
|
10
|
+
const key = process.env.HASDATA_API_KEY;
|
|
11
|
+
if (!key) {
|
|
12
|
+
process.stderr.write('HASDATA_API_KEY is not set. Create a free key at https://app.hasdata.com and set HASDATA_API_KEY.\n');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
// Resolve mcp-remote's CLI from its own package.json bin, so a future layout change
|
|
16
|
+
// or an exports map does not break a hardcoded deep path.
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
const pkg = require('mcp-remote/package.json');
|
|
19
|
+
const proxy = join(dirname(require.resolve('mcp-remote/package.json')), pkg.bin['mcp-remote']);
|
|
20
|
+
const child = spawn(process.execPath, [proxy, URL, '--header', `x-api-key:${key}`], { stdio: 'inherit' });
|
|
21
|
+
child.on('exit', (code, signal) => {
|
|
22
|
+
if (signal) process.kill(process.pid, signal);
|
|
23
|
+
else process.exit(code ?? 0);
|
|
24
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hasdata/google-trends-mcp",
|
|
3
|
+
"mcpName": "com.hasdata/google-trends",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "MCP server for Google Trends through HasData's hosted API: interest over time, interest by region, and rising and top related queries and topics. No Google account.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": { "hasdata-google-trends-mcp": "index.mjs" },
|
|
8
|
+
"files": ["index.mjs", "README.md", "LICENSE"],
|
|
9
|
+
"scripts": { "test": "node --test" },
|
|
10
|
+
"dependencies": { "mcp-remote": "^0.1.43" },
|
|
11
|
+
"engines": { "node": ">=18" },
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": { "type": "git", "url": "https://github.com/HasData/google-trends-mcp.git" },
|
|
14
|
+
"homepage": "https://hasdata.com/apis/google-trends-api",
|
|
15
|
+
"keywords": ["mcp", "google-trends", "google-trends-mcp", "trends", "seo", "model-context-protocol", "hasdata", "scraper"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "hasdata-google-trends-mcp"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "MCP server for Google Trends through HasData's hosted API. No Google account."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
keywords = ["mcp", "google-trends", "trends", "seo", "model-context-protocol", "hasdata"]
|
|
9
|
+
# mcp is pinned below 2 because mcp-proxy 0.12.0 imports request_ctx, removed in the mcp 2.x SDK.
|
|
10
|
+
dependencies = ["mcp-proxy>=0.12.0", "mcp>=1.17,<2"]
|
|
11
|
+
|
|
12
|
+
[project.urls]
|
|
13
|
+
Homepage = "https://hasdata.com/apis/google-trends-api"
|
|
14
|
+
Repository = "https://github.com/HasData/google-trends-mcp"
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
hasdata-google-trends-mcp = "hasdata_google_trends_mcp:main"
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["hatchling"]
|
|
21
|
+
build-backend = "hatchling.build"
|
|
22
|
+
|
|
23
|
+
[tool.hatch.build.targets.wheel]
|
|
24
|
+
packages = ["hasdata_google_trends_mcp"]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "com.hasdata/google-trends",
|
|
4
|
+
"title": "HasData Google Trends",
|
|
5
|
+
"description": "Google Trends interest over time, by region, and related queries and topics, as JSON.",
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"websiteUrl": "https://hasdata.com/apis/google-trends-api",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/HasData/google-trends-mcp",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_trends",
|
|
16
|
+
"headers": [
|
|
17
|
+
{
|
|
18
|
+
"name": "x-api-key",
|
|
19
|
+
"description": "HasData API key, created at app.hasdata.com. The free trial needs no card.",
|
|
20
|
+
"isRequired": true,
|
|
21
|
+
"isSecret": true
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"packages": [
|
|
27
|
+
{
|
|
28
|
+
"registryType": "npm",
|
|
29
|
+
"identifier": "@hasdata/google-trends-mcp",
|
|
30
|
+
"version": "1.0.0",
|
|
31
|
+
"transport": {
|
|
32
|
+
"type": "stdio"
|
|
33
|
+
},
|
|
34
|
+
"environmentVariables": [
|
|
35
|
+
{
|
|
36
|
+
"name": "HASDATA_API_KEY",
|
|
37
|
+
"description": "HasData API key, created at app.hasdata.com. The free trial needs no card.",
|
|
38
|
+
"isRequired": true,
|
|
39
|
+
"isSecret": true
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Tool contract test.
|
|
2
|
+
//
|
|
3
|
+
// The README promises one tool with a specific name and required parameter. The upstream list
|
|
4
|
+
// can change without a single commit here, and the README would start lying silently. These
|
|
5
|
+
// checks catch that before a user does.
|
|
6
|
+
//
|
|
7
|
+
// The last test calls the tool for real. Listing tools accepts any non-empty key, so a contract
|
|
8
|
+
// check that only lists tools stays green with a revoked or mistyped key. That call costs
|
|
9
|
+
// 5 credits, which is the price of a canary that can fail for the right reason.
|
|
10
|
+
//
|
|
11
|
+
// Run: HASDATA_API_KEY=your_key_here npm test
|
|
12
|
+
|
|
13
|
+
import { test } from 'node:test';
|
|
14
|
+
import assert from 'node:assert/strict';
|
|
15
|
+
|
|
16
|
+
const ENDPOINT = 'https://mcp.hasdata.com/api/mcp?apis=google_trends';
|
|
17
|
+
const KEY = process.env.HASDATA_API_KEY;
|
|
18
|
+
const TIMEOUT_MS = 30_000;
|
|
19
|
+
|
|
20
|
+
const EXPECTED = {
|
|
21
|
+
hasdata_google_trends_search_getTrendsData: 'q',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// A streamable HTTP body arrives either as plain JSON or as server-sent events. One SSE event
|
|
25
|
+
// can span several data: lines, several events can share one response, and a server is free to
|
|
26
|
+
// send progress notifications before the answer. So collect every event and pick the message
|
|
27
|
+
// carrying our request id instead of trusting the first data: line.
|
|
28
|
+
function parseRpc(raw, id) {
|
|
29
|
+
const trimmed = raw.trim();
|
|
30
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) return JSON.parse(trimmed);
|
|
31
|
+
|
|
32
|
+
const messages = [];
|
|
33
|
+
for (const event of trimmed.split(/\r?\n\r?\n+/)) {
|
|
34
|
+
const data = event
|
|
35
|
+
.split(/\r?\n/)
|
|
36
|
+
.filter((l) => l.startsWith('data:'))
|
|
37
|
+
.map((l) => l.slice(5).replace(/^ /, ''))
|
|
38
|
+
.join('\n');
|
|
39
|
+
if (!data || data === '[DONE]') continue;
|
|
40
|
+
try {
|
|
41
|
+
messages.push(JSON.parse(data));
|
|
42
|
+
} catch {
|
|
43
|
+
// A keep-alive or a partial event is not our response.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
assert.ok(messages.length, `no JSON-RPC message in the response: ${raw.slice(0, 300)}`);
|
|
47
|
+
const match = messages.find((m) => m.id === id);
|
|
48
|
+
assert.ok(match, `no message with id ${id} in the response: ${raw.slice(0, 300)}`);
|
|
49
|
+
return match;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let nextId = 1;
|
|
53
|
+
|
|
54
|
+
async function rpc(method, params = {}) {
|
|
55
|
+
const id = nextId++;
|
|
56
|
+
const res = await fetch(ENDPOINT, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
headers: {
|
|
59
|
+
'x-api-key': KEY,
|
|
60
|
+
'Content-Type': 'application/json',
|
|
61
|
+
// The server answers over streamable HTTP, so accept both a plain body and a stream.
|
|
62
|
+
Accept: 'application/json, text/event-stream',
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({ jsonrpc: '2.0', id, method, params }),
|
|
65
|
+
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
66
|
+
});
|
|
67
|
+
assert.equal(res.status, 200, `${method} returned ${res.status}`);
|
|
68
|
+
const raw = await res.text();
|
|
69
|
+
return { raw, body: parseRpc(raw, id) };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// One network round trip for every test that needs the list.
|
|
73
|
+
let toolsPromise;
|
|
74
|
+
function listTools() {
|
|
75
|
+
toolsPromise ??= rpc('tools/list').then(({ body }) => {
|
|
76
|
+
assert.ok(body.result?.tools, 'the response carried no result.tools');
|
|
77
|
+
return body.result.tools;
|
|
78
|
+
});
|
|
79
|
+
return toolsPromise;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const live = { skip: KEY ? false : 'HASDATA_API_KEY is not set, skipping the live checks' };
|
|
83
|
+
|
|
84
|
+
test('apis=google_trends exposes exactly one tool', live, async () => {
|
|
85
|
+
const tools = await listTools();
|
|
86
|
+
const names = tools.map((t) => t.name).sort().join(', ');
|
|
87
|
+
assert.equal(
|
|
88
|
+
tools.length,
|
|
89
|
+
Object.keys(EXPECTED).length,
|
|
90
|
+
`expected ${Object.keys(EXPECTED).length} tool, got ${tools.length}: ${names}`
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('the tool name has not changed', live, async () => {
|
|
95
|
+
const tools = await listTools();
|
|
96
|
+
const names = new Set(tools.map((t) => t.name));
|
|
97
|
+
for (const expected of Object.keys(EXPECTED)) {
|
|
98
|
+
assert.ok(names.has(expected), `tool ${expected} is missing from the list`);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('the tool still declares its required parameter', live, async () => {
|
|
103
|
+
const tools = await listTools();
|
|
104
|
+
for (const tool of tools) {
|
|
105
|
+
const required = tool.inputSchema?.required ?? [];
|
|
106
|
+
const want = EXPECTED[tool.name];
|
|
107
|
+
assert.ok(want, `tool ${tool.name} is not covered by this test`);
|
|
108
|
+
assert.ok(
|
|
109
|
+
required.includes(want),
|
|
110
|
+
`${tool.name} should require ${want}, declares: ${required.join(', ') || 'nothing'}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('the tool carries a description', live, async () => {
|
|
116
|
+
const tools = await listTools();
|
|
117
|
+
for (const tool of tools) {
|
|
118
|
+
assert.ok(
|
|
119
|
+
(tool.description || '').trim().length > 20,
|
|
120
|
+
`${tool.name} has an empty or near-empty description`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('the key is accepted by HasData', live, async () => {
|
|
126
|
+
const { raw } = await rpc('tools/call', {
|
|
127
|
+
name: 'hasdata_google_trends_search_getTrendsData',
|
|
128
|
+
arguments: { q: 'coffee' },
|
|
129
|
+
});
|
|
130
|
+
assert.ok(!raw.includes('401 Unauthorized'), 'HasData rejected the key');
|
|
131
|
+
assert.ok(!raw.includes('"isError":true'), `the tool call failed: ${raw.slice(0, 300)}`);
|
|
132
|
+
});
|