MCP服务器-集群API v1
这是用于集群API v1的模型上下文协议(MCP)服务器实现。它为身份验证、集群管理、名称注册和社区注册提供端点。
依赖项
{
"@modelcontextprotocol/sdk": "^1.7.0",
"dotenv": "^16.4.7",
"zod": "^3.24.2"
}设置
- 安装依赖项:
npm install- 创建一个
.env具有的文件:CLUSTERS_API_KEY={CLUSTERS-API_KEY}(可选)
- 构建并启动服务器:
npm run dev测试端点
由于此服务器使用 StdioServerTransport,您需要通过stdin发送JSON-RPC消息。以下是测试每个端点的示例命令:
身份验证端点
获取消息
echo '{"jsonrpc":"2.0","id":1,"method":"get_signing_message"}' | node dist/index.js获取令牌
echo '{"jsonrpc":"2.0","id":1,"method":"get_auth_key","params":{"signature":"0x123","signingDate":"2024-05-07","type":"evm","wallet":"0x123"}}' | node dist/index.js验证令牌
echo '{"jsonrpc":"2.0","id":1,"method":"validate_auth_token","params":{"authKey":"your-auth-key"}}' | node dist/index.js群集管理端点
创建群集
echo '{"jsonrpc":"2.0","id":1,"method":"create_a_cluster","params":{"authKey":"your-auth-key","testnet":false}}' | node dist/index.js按ID获取群集
echo '{"jsonrpc":"2.0","id":1,"method":"get_cluster_by_id","params":{"id":"cluster-id","testnet":false}}' | node dist/index.js按名称获取群集
echo '{"jsonrpc":"2.0","id":1,"method":"get_cluster_by_name","params":{"name":"cluster-name","testnet":false}}' | node dist/index.js按地址获取群集ID
echo '{"jsonrpc":"2.0","id":1,"method":"get_cluster_id_by_address","params":{"address":"0x123","testnet":false}}' | node dist/index.js添加钱包
echo '{"jsonrpc":"2.0","id":1,"method":"add_wallets","params":{"wallets":[{"address":"0x123","name":"new-wallet","isPrivate":false}],"authKey":"your-auth-key","testnet":false}}' | node dist/index.js生成钱包
echo '{"jsonrpc":"2.0","id":1,"method":"generate_wallet","params":{"type":"evm","name":"new-wallet","isPrivate":false,"authKey":"your-auth-key","testnet":false}}' | node dist/index.js更新钱包
echo '{"jsonrpc":"2.0","id":1,"method":"update_wallets","params":{"wallets":[{"address":"0x123","name":"updated-name"}],"authKey":"your-auth-key","testnet":false}}' | node dist/index.js删除钱包
echo '{"jsonrpc":"2.0","id":1,"method":"remove_wallets","params":{"addresses":["0x123"],"authKey":"your-auth-key","testnet":false}}' | node dist/index.js验证钱包
echo '{"jsonrpc":"2.0","id":1,"method":"verify_wallet","params":{"clusterId":"cluster-id","authKey":"your-auth-key","testnet":false}}' | node dist/index.js地址↔ 名称解析端点
按地址获取姓名
echo '{"jsonrpc":"2.0","id":1,"method":"get_name_by_address","params":{"address":"0x123","testnet":false}}' | node dist/index.js按地址获取所有姓名
echo '{"jsonrpc":"2.0","id":1,"method":"get_all_names_by_address","params":{"address":"0x123","testnet":false}}' | node dist/index.js按地址获取批量数据
echo '{"jsonrpc":"2.0","id":1,"method":"get_bulk_data_by_addresses","params":{"addresses":["0x123","0x456"],"testnet":false}}' | node dist/index.js按名称获取批量数据
echo '{"jsonrpc":"2.0","id":1,"method":"get_bulk_data_by_names","params":{"names":[{"name":"name-1"},{"name":"name-2"}],"testnet":false}}' | node dist/index.js注册端点
检查名称可用性
echo '{"jsonrpc":"2.0","id":1,"method":"check_name_availability","params":{"names":["name-1","name-2"],"testnet":false}}' | node dist/index.js获取注册标志数据
- 此端点目前无法运行。
echo '{"jsonrpc":"2.0","id":1,"method":"get_registration_sign_data","params":{"network":"1","sender":"0x123","names":[{"name":"name1","amountWei":"1000000000000000000"}],"referralClusterId":"optional-id","testnet":false}}' | node dist/index.js获取交易状态
echo '{"jsonrpc":"2.0","id":1,"method":"get_transaction_status","params":{"txHash":"0x123","testnet":false}}' | node dist/index.js社区端点
检查社区名称可用性
echo '{"jsonrpc":"2.0","id":1,"method":"check_community_name_availability","params":{"communityName":"community-name","name":"some-name","testnet":false}}' | node dist/index.js注册社区名称
echo '{"jsonrpc":"2.0","id":1,"method":"register_community_name","params":{"authKey":"your-auth-key","communityName":"some_community","name":"some_name","walletAddress":"your-wallet-address","testnet":false}}' | node dist/index.js备注
- 替换占位符值(如
0x123,your-auth-key等)与实际值 - 这
testnet参数对于所有端点都是可选的 - 所有响应都将采用JSON-RPC 2.0格式
- 对于经过身份验证的端点,请确保获取并包含有效的
authKey - 服务器使用可选的环境变量进行配置,确保
.env文件已正确设置以使用它
