tokenhub-websearch
v1.0.6
Published
TokenHub WebSearch MCP Server - 使用 TokenHub 额度调用网络搜索
Maintainers
Readme
TokenHub WebSearch MCP Server
用于将 TokenHub 网络搜索接口封装为 MCP 工具,供 Claude Desktop、Cursor、Windsurf 等支持 MCP 的客户端使用。
功能
- 工具名:
websearch - 参数:
q(必填):搜索关键词key(可选):TokenHub API Key,以sk-开头
- 每次调用消耗 5000 TokenHub 额度
安装方式
通过 npx 直接使用(无需本地安装)
npx tokenhub-websearch在 MCP 客户端配置中:
{
"mcpServers": {
"tokenhub-websearch": {
"command": "npx",
"args": ["-y", "tokenhub-websearch"],
"env": {
"TOKENHUB_USER_KEY": "sk-你的TokenHubKey"
}
}
}
}全局安装
npm install -g tokenhub-websearch{
"mcpServers": {
"tokenhub-websearch": {
"command": "tokenhub-websearch",
"env": {
"TOKENHUB_USER_KEY": "sk-你的TokenHubKey"
}
}
}
}环境变量
| 变量名 | 必填 | 说明 |
|--------|------|------|
| TOKENHUB_USER_KEY | 是* | TokenHub API Key,以 sk- 开头 |
| WEBSEARCH_BASE_URL | 否 | 后端接口地址,默认 https://cardcdn.jwbpro.com |
*如果环境变量未设置,每次调用时必须通过 key 参数传入。
各客户端安装方法
Claude Desktop
- 确保已安装 Node.js 18+。
- 打开配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json
- macOS:
- 添加:
{
"mcpServers": {
"tokenhub-websearch": {
"command": "npx",
"args": ["-y", "tokenhub-websearch"],
"env": {
"TOKENHUB_USER_KEY": "sk-你的TokenHubKey"
}
}
}
}- 重启 Claude Desktop。
- 在对话里说"搜索人工智能最新进展"即可自动调用
websearch工具。
Cursor
- 打开 Cursor Settings → MCP。
- 点击 "Add MCP Server",选择 Type 为
command。 - 填入:
- Name:
tokenhub-websearch - Command:
npx -y tokenhub-websearch
- Name:
- 在 Environment Variables 中设置:
TOKENHUB_USER_KEY=sk-你的TokenHubKey
- 保存后即可在 Composer/Chat 中使用。
Windsurf
- 打开
~/.windsurf/mcp_config.json或项目级.windsurf/mcp_config.json。 - 添加:
{
"mcpServers": {
"tokenhub-websearch": {
"command": "npx",
"args": ["-y", "tokenhub-websearch"],
"env": {
"TOKENHUB_USER_KEY": "sk-你的TokenHubKey"
}
}
}
}- 重启 Windsurf。
工具说明
当用户或 agent 请求搜索时,MCP server 会调用:
POST {WEBSEARCH_BASE_URL}/user/noCheck/tokenhub/websearch
Content-Type: application/json
{"key": "sk-xxx", "q": "搜索关键词"}并返回搜索结果。
注意事项
- 默认后端地址为
https://cardcdn.jwbpro.com,如需换线可设置WEBSEARCH_BASE_URL环境变量。 - 如果
key参数和TOKENHUB_USER_KEY同时存在,优先使用参数传入的 key。 - 关键词最长 200 字符,超出会被接口拒绝。
- 余额不足时接口返回 429,server 会将错误信息返回给客户端。可以在 https://tokenhub.scjwb.com/ 进行充值。
License
MIT
