aiowhitebit - mcp 是专门为 WhiteBit 加密货币交易所 API 打造的消息控制协议(MCP)服务器与客户端实现。它基于 aiowhitebit 库和 fastmcp 开发,为用户提供了便捷、高效的消息控制解决方案。
# 安装包
pip install aiowhitebit-mcp
# 运行服务器(用于 Claude 桌面的标准输入输出传输)
aiowhitebit-mcp --transport stdio
# 或使用 SSE 传输协议运行
aiowhitebit-mcp --transport sse --host 127.0.0.1 --port 8000
import asyncio
import os
from aiowhitebit_mcp.client import WhiteBitMCPClient
async def 主函数():
# 设置服务器 URL(或使用环境变量)
server_url = "http://localhost:8000/sse"
os.environ["WHITEBIT_MCP_URL"] = server_url
async with WhiteBitMCPClient() as client:
# 获取市场信息
btc_usdt = await client.get_market_info()
print(btc_usdt)
# 获取实时价格
price = await client.get_realtime_price()
print(price)
asyncio.run(主函数())
from aiowhitebit_mcp.server import create_server
async def main():
# 创建 MCP 服务器实例
server = await create_server(
host="127.0.0.1",
port=8000,
transport="stdio" # 可选:stdio, sse
)
# 启动服务器
await server.start()
asyncio.run(main())
pip install aiowhitebit-mcp[cli]
运行服务器:
aiowhitebit-mcp serve --host 127.0.0.1 --port 8000 --transport sse
连接到服务器:
aiowhitebit-mcp client --url http://localhost:8000/sse
git clone https://github.com/yourusername/aiowhitebit-mcp.git
cd aiowhitebit-mcp
pip install -r requirements.dev.txt
pytest tests/
项目提供了以下示例:
examples/stdio_server.py:使用标准输入输出传输协议的服务器。examples/stdio_client.py:连接到标准输入输出服务器的客户端。examples/sse_server.py:使用 SSE 传输协议的服务器。examples/sse_client.py:连接到 SSE 服务器的客户端。本项目采用 Apache License 2.0 许可证。