Bybit MCP 服务器
模型上下文协议 (MCP)服务器提供对 Bybit 加密货币交换 API 的只读访问。
这是 Alpha 质量软件 - 使用风险自负!
请务必在此服务器上使用只读 API 密钥。我不会将您的“钱”托付给我的代码,您也一样!
Started integrated server
Chatting with llama-3.2-11b-instruct:Q8_0 (Ctrl+C to exit)
Tools are available - ask about cryptocurrency data!
You: Whats the current spot price for USDT/BTC?
Assistant: <tool>get_ticker</tool>
<arguments>
{
"category": "spot",
"symbol": "BTCUSDT"
}
</arguments>
Tool result: {
"timestamp": "2024-12-14T12:32:30.628Z",
"meta": {
"requestId": "ad5177bc-93d1-49ed-80a1-dd95b3ec970b"
},
"symbol": "BTCUSDT",
"category": "spot",
"lastPrice": "101368.71",
"price24hPcnt": "0.0107",
"highPrice24h": "102661.3",
"lowPrice24h": "99683.96",
"prevPrice24h": "100292.67",
"volume24h": "22543.911683",
"turnover24h": "2285318788.68303381",
"bid1Price": "101366.07",
"bid1Size": "0.136049",
"ask1Price": "101366.08",
"ask1Size": "0.648039",
"usdIndexPrice": "101365.707576"
}
Processing result...
The current spot price for USDT/BTC is $101,368.71.特征
该 MCP 服务器提供以下工具用于与 Bybit 的 API 交互:
get_ticker:获取交易对的实时股票行情信息get_orderbook:获取交易对的订单簿(市场深度)数据get_kline:获取交易对的 K 线/K 线数据get_market_info:获取交易对的详细市场信息get_trades:获取交易对的近期交易get_instrument_info:获取特定交易对的详细工具信息get_wallet_balance:获取已验证用户的钱包余额信息get_positions:获取已验证用户的当前位置信息get_order_history:获取经过身份验证的用户的订单历史记录
Related MCP server: Coin MCP Server
要求和安装
Node.js(v20+)
pnpm(
npm i -g pnpm)如果您想运行 Ollama 客户端(如下面的快速入门所示),您需要安装并运行 Ollama,以及您选择的模型。
pnpm i快速入门
要安装软件包,请构建所有内容并启动交互式客户端:
pnpm i将 .env.example 文件复制到 .env 并填写您的详细信息。
cp .env.example .env
code .envMCP 服务器(仅限)
pnpm serveMCP-Server 和 Ollama 客户端
安装所需的客户端包:
(cd client && pnpm i)将客户端 .env.example 文件复制到 .env 并填写您的详细信息。
cp client/.env.example client/.env
code client/.env然后通过一个命令启动客户端和服务器:
pnpm start配置
环境变量
服务器需要将 Bybit API 凭证设置为环境变量:
BYBIT_API_KEY:您的 Bybit API 密钥(必需)BYBIT_API_SECRET:您的 Bybit API 密钥(必需) -重要 - 仅创建只读 API 密钥!BYBIT_USE_TESTNET:设置为“true”以使用测试网而不是主网(可选,默认为 false)DEBUG:设置为“true”以启用调试日志记录(可选,默认为 false)
客户端环境变量(./client/.env):
OLLAMA_HOST:Ollama 服务器的主机(默认为http://localhost:11434 )DEFAULT_MODEL:用于聊天的默认模型(默认为 llama-3.2-11b-instruct:Q8_0)
MCP 设置配置
要将此服务器与 MCP 客户端一起使用,您需要将其添加到 MCP 设置配置文件中。文件位置取决于您的客户端:
MCP 示例 - Claude 桌面
位置: ~/Library/Application\ Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"bybit": {
"command": "node",
"args": ["/path/to/bybit-mcp/build/index.js"],
"env": {
"BYBIT_API_KEY": "your-api-key",
"BYBIT_API_SECRET": "your-api-secret",
"BYBIT_USE_TESTNET": "false"
}
}
}
}MCP 示例 - gomcp
位置: ~/.config/gomcp/config.yaml
mcp_servers:
- name: "bybit"
command: "cd /path/to/bybit-mcp && pnpm run serve"
arguments: []
env:
BYBIT_API_KEY: "" # Add your Bybit API **READ ONLY** key here
BYBIT_API_SECRET: "" # Add your Bybit API **READ ONLY** secret here
BYBIT_USE_TESTNET: "true" # Set to false for production
DEBUG: "false" # Optional: Set to true for debug logging客户端集成
此软件包包含一个 TypeScript 客户端,该客户端提供命令行界面,用于与 Ollama LLM 和 bybit-mcp 服务器交互。该客户端支持:
与 Ollama 模特互动聊天
直接访问所有 bybit-mcp 交易工具
自动服务器管理
基于环境的配置
调试日志记录
有关详细的客户端文档,请参阅客户端 README 。
运行服务器
生产
构建服务器:
pnpm build运行服务器:
node build/index.js发展
对于使用自动 TypeScript 重新编译进行开发:
pnpm watch在开发过程中检查 MCP 服务器:
pnpm inspector工具文档
获取股票信息
{
"name": "get_ticker",
"arguments": {
"symbol": "BTCUSDT",
"category": "spot" // optional, defaults to "spot"
}
}获取订单簿数据
{
"name": "get_orderbook",
"arguments": {
"symbol": "BTCUSDT",
"category": "spot", // optional, defaults to "spot"
"limit": 25 // optional, defaults to 25 (available: 1, 25, 50, 100, 200)
}
}获取K线/K线数据
{
"name": "get_kline",
"arguments": {
"symbol": "BTCUSDT",
"category": "spot", // optional, defaults to "spot"
"interval": "1", // optional, defaults to "1" (available: "1", "3", "5", "15", "30", "60", "120", "240", "360", "720", "D", "M", "W")
"limit": 200 // optional, defaults to 200 (max 1000)
}
}获取市场信息
{
"name": "get_market_info",
"arguments": {
"category": "spot", // optional, defaults to "spot"
"symbol": "BTCUSDT", // optional, if not provided returns info for all symbols in the category
"limit": 200 // optional, defaults to 200 (max 1000)
}
}获取最近交易
{
"name": "get_trades",
"arguments": {
"symbol": "BTCUSDT",
"category": "spot", // optional, defaults to "spot"
"limit": 200 // optional, defaults to 200 (max 1000)
}
}获取仪器信息
{
"name": "get_instrument_info",
"arguments": {
"symbol": "BTCUSDT", // required
"category": "spot" // optional, defaults to "spot"
}
}返回有关交易工具的详细信息,包括:
基础货币和报价货币
交易状态
批量过滤器(最小/最大订单数量)
价格过滤器(刻度大小)
杠杆设置(针对期货)
合约详情(针对期货)
获取钱包余额
{
"name": "get_wallet_balance",
"arguments": {
"accountType": "UNIFIED", // required (available: "UNIFIED", "CONTRACT", "SPOT")
"coin": "BTC" // optional, if not provided returns all coins
}
}获取职位
{
"name": "get_positions",
"arguments": {
"category": "linear", // required (available: "linear", "inverse")
"symbol": "BTCUSDT", // optional
"baseCoin": "BTC", // optional
"settleCoin": "USDT", // optional
"limit": 200 // optional, defaults to 200
}
}获取订单历史记录
{
"name": "get_order_history",
"arguments": {
"category": "spot", // required (available: "spot", "linear", "inverse")
"symbol": "BTCUSDT", // optional
"baseCoin": "BTC", // optional
"orderId": "1234567890", // optional
"orderLinkId": "myCustomId", // optional
"orderStatus": "Filled", // optional (available: "Created", "New", "Rejected", "PartiallyFilled", "PartiallyFilledCanceled", "Filled", "Cancelled", "Untriggered", "Triggered", "Deactivated")
"orderFilter": "Order", // optional (available: "Order", "StopOrder")
"limit": 200 // optional, defaults to 200
}
}支持的类别
spot:现货交易linear:线性永续合约inverse:逆向永续合约
执照
麻省理工学院
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.