# 怎样通过 Social2api 的 MCP 工具查询抖音关键词趋势？

[规范网址](https://social2api.com/guides/douyin-keyword-trends-mcp-tool/)

需要在对话或研究工具中使用抖音指数时，MCP 可以发现当前凭据有权调用的工具。先用显式演示参数跑一条日线，再决定是否需要实时数据。

## Agent 提示词

~~~~text
请在 Social2api 使用Social2api 的 MCP 取数服务，执行以下任务。
目标：在授权 MCP 客户端读取工具结构并完成只读演示调用。
输入与对照示例：工具参数可用 {"name":"get_douyin_trends","arguments":{"mode":"demo","keywords":["咖啡"],"since":"2025-03-01","until":"2025-03-01"}}。核查看到对应词日的一行且 requestCount 为 0。
检查客户端是否支持 MCP，使用已授权的连接或凭据。核对免费示例与实时模式。
按以下步骤完成：把已获授权的 MCP 客户端连接到 https://social2api.com/mcp，使用密钥或已支持的 OAuth 授权方式。 完成 initialize，调用 tools/list，确认返回 get_douyin_trends 并查看 arguments 的参数限制。 用 tools/call 传入工具名和 mode=demo，解析 result.content[0].text 中的 JSON；调用层同时检查 RPC error 和 result.isError。
交付能核对的结果和必要字段：result.content[].text、result.isError、keyword、date、searchIndex、requestCount。注明来源或限制，并以本页为操作参考。
https://social2api.com/guides/douyin-keyword-trends-mcp-tool/
~~~~

[查看 MCP 请求并调用抖音工具](https://social2api.com/docs/api/mcp/)

## 本页用到的 Social2api 接口

| 接口与参数文档 | 用途 |
| --- | --- |
| [调用 MCP 服务](https://social2api.com/docs/api/mcp/) · POST /mcp | 使用 JSON-RPC 查找并调用与密钥授权范围相符的取数工具。 |
| [抖音关键词逐日趋势](https://social2api.com/docs/api/douyin-keyword-trends/) · POST /api/run · task=douyin | 查询最多 20 个关键词的日搜索指数和可用的综合指数。 |

## 在 Social2api 使用Social2api 的 MCP 取数服务

1. 把已获授权的 MCP 客户端连接到 https://social2api.com/mcp，使用密钥或已支持的 OAuth 授权方式。
2. 完成 initialize，调用 tools/list，确认返回 get\_douyin\_trends 并查看 arguments 的参数限制。
3. 用 tools/call 传入工具名和 mode=demo，解析 result.content\[0\].text 中的 JSON；调用层同时检查 RPC error 和 result.isError。

## 复制请求并试跑

先通过 HTTP 合成响应核对单词单日的一行结构，再用授权 MCP 客户端验收工具调用。

这条请求使用合成样例，免登录、免 API Key，上游请求数为 0。要查真实数据，将 mode 改为 live，换成实际输入，并在 Authorization 中提供有相应任务权限的 Bearer API Key。可用 maxRequests 限制实时上游请求数。

~~~~bash
curl --fail-with-body -sS 'https://social2api.com/api/run' \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'JSON'
{
  "task": "douyin",
  "mode": "demo",
  "params": {
    "keywords": [
      "咖啡"
    ],
    "since": "2025-03-01",
    "until": "2025-03-01"
  }
}
JSON
~~~~

## 用 MCP 调用得到一个关键词日行

使用具有对应任务权限的 Social2api Key。以下脚本明确发送 demo，可验收 JSON-RPC 和 MCP 文本包装，样例实际发往上游的请求数为 0。留存 JSON 回包并输出 CSV。服务错误和工具 isError 分开处理，两种错误均停止导出。

如果客户端只显示普通 JSON rows，先确认调用的是 /mcp。读取 tools/list 才能验证当前连接可见的工具。工具 live 请求另行配置授权和 maxRequests。

~~~~bash
set -euo pipefail
: "${SOCIAL2API_API_KEY:?请设置获准该任务的 Social2api Key}"
rpc() {
  curl -fsS 'https://social2api.com/mcp' \
    -H "Authorization: Bearer $SOCIAL2API_API_KEY" \
    -H 'Content-Type: application/json' \
    -H 'MCP-Protocol-Version: 2025-11-25' \
    --data-binary "$1"
}
rpc '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"csv-check","version":"1"}}}' |
  jq -e '.result.protocolVersion' >/dev/null
rpc '{"jsonrpc":"2.0","method":"notifications/initialized"}' >/dev/null
rpc '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' |
  jq -e '.result.tools | any(.name == "get_douyin_trends")' >/dev/null
rpc '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_douyin_trends","arguments":{"mode":"demo","keywords":["咖啡"],"since":"2025-03-01","until":"2025-03-01"}}}' > mcp-result.json
jq -er '
  if .error then error(.error.message)
  elif .result.isError then error(.result.content[0].text)
  else .result.content[] | select(.type == "text") | .text | fromjson end
  | if .mode != "demo" or .requestCount != 0 then error("Expected a demo response") else . end
  | (["keyword","date","searchIndex"], (.rows[] | [.keyword, .date, .searchIndex])) | @csv
' mcp-result.json > result.csv
~~~~

## 操作示例与核对

工具参数可用 {"name":"get\_douyin\_trends","arguments":{"mode":"demo","keywords":\["咖啡"\],"since":"2025-03-01","until":"2025-03-01"}}。核查看到对应词日的一行且 requestCount 为 0。

## 需要核对的字段

result.content\[\].text、result.isError、keyword、date、searchIndex、requestCount。

## 接口文档

- [抖音关键词逐日趋势](https://social2api.com/docs/api/douyin-keyword-trends/)
- [调用 MCP 服务](https://social2api.com/docs/api/mcp/)

## 相关用户讨论

- [相邻平台类比 · Google Trends · 能提供 Google Trends 数据的 MCP 吗？](https://x.com/catfishcomstock/status/1948379668287234497)
- [相邻平台类比 · YouTube · Which unified API tool works best in n8n for domain traffic, social posts, and work email lookups?](https://www.reddit.com/r/n8n/comments/1y2is25/which_unified_api_tool_works_best_in_n8n_for/)

## 相关指南和问答

- [怎么批量获取过去 30 天的抖音关键词搜索热度？](https://social2api.com/guides/douyin-keyword-trends-30-days/)

[查看 MCP 请求并调用抖音工具](https://social2api.com/docs/api/mcp/)
