Bybit MCP Server

Bybit MCP Server

一个模型上下文协议(Model Context Protocol)服务器,提供对 Bybit 加密货币交易所 API 的只读访问权限,允许用户使用自然语言查询实时加密货币数据。

Category
访问服务器

Tools

get_instrument_info

Get detailed instrument information for a specific trading pair

get_kline

Get kline/candlestick data for a trading pair

get_market_info

Get detailed market information for trading pairs

get_order_history

Get order history for the authenticated user

get_orderbook

Get orderbook (market depth) data for a trading pair

get_positions

Get positions information for the authenticated user

get_ticker

Get real-time ticker information for a trading pair

get_trades

Get recent trades for a trading pair

get_wallet_balance

Get wallet balance information for the authenticated user

README

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 线/蜡烛图数据
  • get_market_info: 获取交易对的详细市场信息
  • get_trades: 获取交易对的最近交易
  • get_instrument_info: 获取特定交易对的详细工具信息
  • get_wallet_balance: 获取已验证用户的钱包余额信息
  • get_positions: 获取已验证用户的当前仓位信息
  • get_order_history: 获取已验证用户的订单历史记录

要求 & 安装

  1. Node.js (v20+)
  2. pnpm (npm i -g pnpm)
  3. 如果你想运行如下面的快速入门中所示的 Ollama 客户端,你需要安装并运行 Ollama,以及你选择的模型。
pnpm i

快速入门

要安装软件包,构建所有内容并启动交互式客户端:

pnpm i

将 .env.example 文件复制到 .env 并填写您的详细信息。

cp .env.example .env
code .env

MCP-服务器(仅)

pnpm serve

MCP-服务器和 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 Desktop

位置:~/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: ""      # 在此处添加您的 Bybit API **只读** 密钥
      BYBIT_API_SECRET: ""   # 在此处添加您的 Bybit API **只读** 密钥
      BYBIT_USE_TESTNET: "true"  # 对于生产环境,设置为 false
      DEBUG: "false"         # 可选:设置为 true 以进行调试日志记录

客户端集成

此软件包包含一个 TypeScript 客户端,该客户端提供了一个命令行界面,用于与 Ollama LLM 和 bybit-mcp 服务器进行交互。 客户端支持:

  • 与 Ollama 模型进行交互式聊天
  • 直接访问所有 bybit-mcp 交易工具
  • 自动服务器管理
  • 基于环境的配置
  • 调试日志记录

有关详细的客户端文档,请参阅 客户端 README

运行服务器

生产环境

  1. 构建服务器:
pnpm build
  1. 运行服务器:
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 线/蜡烛图数据

{
  "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: 反向永续合约

许可证

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选