武藏mcp
musashi-mcp 将武藏市场情报作为MCP工具公开给Claude和ChatGPT等客户。
它连接到 musashi-api 并通过MCP提供这些功能:
analyze_textget_arbitrageget_moversground_probabilityget_feedget_feed_statsget_feed_accountsget_wallet_activityget_wallet_positionsget_market_wallet_flowget_smart_money_marketsget_market_briefexplain_market_moveget_health
钱包和市场上下文工具状态:
get_wallet_activity,get_wallet_positions,get_market_wallet_flow,以及get_smart_money_markets得到...的支持musashi-api端点。get_market_brief和explain_market_move组合现有musashi-api没有直接市场源代码调用的原语。
快速开始
托管服务器
生产MCP端点:
https://musashi-production.up.railway.app/mcpOAuth发现端点:
https://musashi-production.up.railway.app/.well-known/oauth-authorization-serverOAuth动态客户端注册端点:
https://musashi-production.up.railway.app/oauth/register为了授权访问,服务器需要一个有效的 mcp_sk_... 密钥来自 MCP_API_KEYS 或 MUSASHI_MCP_API_KEY.
联系克劳德
如果您的Claude帐户支持自定义MCP连接器:
- 打开Claude MCP或连接器设置。
- 添加自定义MCP服务器。
- 使用此服务器URL:
https://musashi-production.up.railway.app/mcp- 选择
OAuth如果提示。 - 填写武藏授权表
mcp_sk_...钥匙。
从ChatGPT连接
如果您的帐户启用了ChatGPT应用程序或开发人员模式:
- 打开
Settings->Apps. - 创建一个新的自定义应用程序。
- 集
MCP Server URL致:
https://musashi-production.up.railway.app/mcp- 将身份验证保留为
OAuth. - 如果ChatGPT使用自动注册,请继续使用发现的OAuth设置。
- 如果ChatGPT要求手动客户端凭据,请使用通过上述注册端点创建的客户端。
- 填写武藏授权表
mcp_sk_...钥匙。
如果连接成功,ChatGPT应该能够从聊天中发现并调用武藏工具。
示例提示
一旦应用程序连接,这些都是很好的烟雾测试:
Use the Musashi app to get health status.Use the Musashi app to get feed statistics.Use the Musashi app to list tracked feed accounts.Use the Musashi app to show market movers with a minimum change of 0.03.Use the Musashi app to analyze this text: Bitcoin will be above 150k by the end of 2026.Use the Musashi app to show wallet activity for 0x...Use the Musashi app to show open positions for 0x...Use the Musashi app to explain wallet flow for this market: ...Use the Musashi app to find smart money markets in crypto.Use the Musashi app to get a market brief for BTC 100k.Use the Musashi app to explain why this market moved: BTC 100k.
本地开发
需求
- Node.js
>=18 pnpm- a可达
musashi-api例子
安装依赖项:
pnpm install可用脚本
pnpm build:将服务器编译为dist/pnpm dev:在本地运行stdio传输pnpm dev:http:在本地运行可流式传输的HTTPpnpm test:构建服务器并运行本地烟雾测试pnpm start:从以下位置运行编译后的stdio服务器dist/pnpm start:http:从以下位置运行编译后的HTTP服务器dist/pnpm watch:在监视模式下运行TypeScriptpnpm clean:删除dist/
环境变量
MUSASHI_API_BASE_URL:Musashi API基础URLPORT:与一起运行时的HTTP端口--transport=httpMUSASHI_MCP_PUBLIC_BASE_URL:OAuth元数据的可选公共MCP服务器基URLMUSASHI_MCP_API_KEY:可选单个有效MCP API密钥MCP_API_KEYS:有效MCP API密钥的可选通讯分离列表MCP_OAUTH_TOKEN_SECRET: 生产中所需 --用于签署OAuth访问令牌的秘密;没有它,启动时会生成一个随机密钥,每次服务器重启时所有令牌都会失效UPSTASH_REDIS_REST_URL: 生产中所需 --用于共享OAuth状态的更新Redis REST URLUPSTASH_REDIS_REST_TOKEN: 生产中所需 --Uptash Redis REST令牌MCP_RATE_LIMIT_PER_MINUTE:每个经过身份验证的主体的消息速率限制(默认值:60)MCP_RATE_LIMIT_PER_HOUR:每个经过身份验证的主体每小时提供一次支持(默认值:1000)
生产需求 (HTTP传输、铁路或 NODE_ENV=production):
UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN,以及 MCP_OAUTH_TOKEN_SECRET 必须全部设置,否则服务器将在启动时以代码1退出。如果没有共享的KV,注册的OAuth客户端和身份验证代码都是本地进程,每次重启都会丢失,从而破坏GPT/Claude的重新连接。
令牌生命周期:
- 访问令牌将在1小时后过期。
- 刷新令牌将在30天后过期。当使用刷新令牌时,它会被轮换——旧令牌被消耗,新令牌被发出。如果重放已消耗的令牌,则整个令牌系列将被撤销,用户必须重新进行身份验证。
- 当刷新令牌过期时,用户必须再次完成OAuth流程。
本地值示例:
MUSASHI_API_BASE_URL=http://127.0.0.1:3000
PORT=3030
MUSASHI_MCP_PUBLIC_BASE_URL=https://your-mcp-server.example.com
MUSASHI_MCP_API_KEY=mcp_sk_your_key_here对于本地钱包工具, MUSASHI_API_BASE_URL 必须指向 musashi-api 服务器具有 /api/wallet/activity 和 /api/wallet/positions 可用。
溢出stdio
MUSASHI_API_BASE_URL=http://127.0.0.1:3000 pnpm dev当您的MCP客户端直接启动服务器进程时,请使用此选项。
通过HTTP运行
MUSASHI_API_BASE_URL=http://127.0.0.1:3000 PORT=3030 pnpm dev:http有用的本地端点:
GET /healthGET /.well-known/oauth-authorization-serverGET /oauth/authorizePOST /oauth/authorizePOST /oauth/tokenPOST /mcpGET /mcpDELETE /mcp
基本检查
构建:
pnpm build烟雾测试:
pnpm test手动健康检查:
curl http://127.0.0.1:3030/health手动OAuth发现检查:
curl http://127.0.0.1:3030/.well-known/oauth-authorization-server手动OAuth验证:
BASE=http://127.0.0.1:3030
# 1. Register a public client
CLIENT_JSON=$(curl -s -X POST "${BASE}/oauth/register" \
-H 'Content-Type: application/json' \
-d '{"redirect_uris":["http://127.0.0.1/callback"]}')
CLIENT_ID=$(node -e "console.log(JSON.parse(process.argv[1]).client_id)" -- "${CLIENT_JSON}")
# 2. Generate a PKCE S256 verifier and challenge
VERIFIER=$(node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))")
CHALLENGE=$(node -e \
"const c=require('crypto');process.stdout.write(c.createHash('sha256').update(process.argv[1]).digest('base64url'))" \
-- "${VERIFIER}")
# 3. Open the authorization URL in a browser and submit a valid mcp_sk_... key
# code_challenge_method is S256 by default and may be omitted
echo "${BASE}/oauth/authorize?client_id=${CLIENT_ID}&redirect_uri=http://127.0.0.1/callback&state=test-state&code_challenge=${CHALLENGE}"
# 4. After submitting the key, the browser redirects to:
# http://127.0.0.1/callback?code=AUTH_CODE&state=test-state
# Copy the code value from the URL, then run:
read -rp "Paste auth code: " AUTH_CODE
curl -s -X POST "${BASE}/oauth/token" \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "grant_type=authorization_code&code=${AUTH_CODE}&client_id=${CLIENT_ID}&redirect_uri=http://127.0.0.1/callback&code_verifier=${VERIFIER}"备注
- 打破释放:此版本使所有现有的OAuth会话和已注册的连接器状态无效。GPT/Claude用户必须在部署后重新连接一次。没有迁移路径。
- OAuth PKCE:仅限
S256支持。所有客户都是公开的(token_endpoint_auth_method: none)以及 必须 提供code_challenge;省略它将返回a400 invalid_request.code_challenge_method可以省略(默认为S256)或设置为S256明确地;任何其他值都被拒绝。client_secret_post不支持。 - 生产需要共享KV(
UPSTASH_REDIS_REST_URL+UPSTASH_REDIS_REST_TOKEN).没有它,注册的OAuth客户端和身份验证代码是每个进程的,每次重启都会丢失。内存存储仅用于本地开发。 - 集
MCP_OAUTH_TOKEN_SECRET在生产中达到稳定的价值。没有它,所有OAuth令牌在每次服务器重启时都会失效。 - 会话连续性:一旦配置了KV存储并部署了服务器,连接器注册和会话将在服务重启后继续有效。用户在首次部署此版本时只需要重新连接一次。
pnpm test这是一个烟雾套件,而不是一个完整的MCP互操作套件。- 行为取决于健康和可达性
musashi-api.
