怎样通过 Social2api 的 MCP 工具查询抖音关键词趋势?
需要在对话或研究工具中使用抖音指数时,MCP 可以发现当前凭据有权调用的工具。先用显式演示参数跑一条日线,再决定是否需要实时数据。
查看 MCP 请求并调用抖音工具本页用到的 Social2api 接口
在 Social2api 使用Social2api 的 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。
复制请求并试跑
先通过 HTTP 合成响应核对单词单日的一行结构,再用授权 MCP 客户端验收工具调用。
这条请求使用合成样例,免登录、免 API Key,上游请求数为 0。要查真实数据,将 mode 改为 live,换成实际输入,并在 Authorization 中提供有相应任务权限的 Bearer API Key。可用 maxRequests 限制实时上游请求数。
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。
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。