TB

tienan92it/binance-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 4 forks 质量 52 趋势 0MIT

一个模型上下文协议(MCP)服务器,将币安加密货币交易所数据暴露给大型语言模型(LLM)代理。

概览

一个模型上下文协议(MCP)服务器,将币安加密货币交易所数据暴露给大型语言模型(LLM)代理。该服务器允许LLM通过标准化接口访问币安的实时和历史市场数据。 - : 获取币安任何交易对的当前价格 - : 获取显示不同价格水平买卖兴趣的订单簿快照 - : 获取任意时间段的OHLCV(开盘、高、低、收盘、成交量)K线数据 - : 通过WebSockets订阅实时交易、行情和订单簿更新 - 访问交易、24小时统计、汇总交易、滚动窗口数据等 - 访问交易规则、股票信息和费用结构 - : 所有数据均通过币安的公开REST API获取(无需API密钥) - : 支持任何兼容MCP的LLM客户端 - Python 3。

概述(AI 翻译)

一个模型上下文协议(MCP)服务器,将币安加密货币交易所数据暴露给大型语言模型(LLM)代理。该服务器允许LLM通过标准化接口访问币安的实时和历史市场数据。

特色

  • 实时价格数据:获取币安上任何交易对的最新价格
  • 订单簿访问:检索显示不同价格水平买卖兴趣的订单簿快照
  • 历史价格数据:获取任意时间段的OHLCV(开盘、高、低、收盘、成交量)K线数据
  • 实时WebSocket流:通过WebSockets订阅实时交易、行情行情和订单簿更新
  • 全面的市场数据:访问交易、24小时统计、汇总交易、滚动窗口数据等
  • 交易所信息:访问交易规则、股票代码信息及费用结构
  • 只读操作:所有数据均通过币安的公开REST API获取(无需API密钥)
  • MCP 标准兼容:可与任何兼容 MCP 的 LLM 客户端兼容

要求

  • Python 3.8+
  • mcp 包含 CLI 工具(mcp[cli])
  • requests REST API 库
  • websockets WebSocket 流库

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Binance MCP Server

A Model Context Protocol (MCP) server that exposes Binance cryptocurrency exchange data to Large Language Model (LLM) agents. This server allows LLMs to access real-time and historical market data from Binance through a standardized interface.

Features

  • Live Price Data: Get current prices for any trading pair on Binance
  • Order Book Access: Retrieve order book snapshots showing buy/sell interest at different price levels
  • Historical Price Data: Fetch OHLCV (Open, High, Low, Close, Volume) candlestick data for any timeframe
  • Real-time WebSocket Streams: Subscribe to real-time trade, ticker, and order book updates via WebSockets
  • Comprehensive Market Data: Access trades, 24hr statistics, aggregate trades, rolling window data, and more
  • Exchange Information: Access trading rules, symbol information, and fee structures
  • Read-only Operation: All data is fetched via Binance’s public REST API (no API keys required)
  • MCP Standard Compliant: Works with any MCP-compatible LLM client

Requirements

  • Python 3.8+
  • mcp package with CLI tools (mcp[cli])
  • requests library for REST API
  • websockets library for WebSocket streams
  • uvicorn for serving (optional)

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/binance_mcp_server.git
cd binance_mcp_server
  1. Install dependencies:
pip install -r requirements.txt

Usage

Running the Server Directly

To run the server in standalone mode:

python run_server.py

This will start the MCP server, which will listen for connections via STDIO.

Development Mode with MCP Inspector

For development and testing, use the MCP Inspector:

mcp dev run_server.py

This opens the MCP Inspector interface where you can test the server’s tools interactively.

Installing in Claude Desktop

To use this server with Claude Desktop:

  1. Install the MCP CLI tools if you haven’t already:
pip install "mcp[cli]"
  1. Install the server in Claude Desktop:
mcp install run_server.py
  1. You can now access Binance data directly within your Claude Desktop conversations.

Example Client

An example client script is provided to demonstrate programmatic usage:

python example_client.py

This script connects to the server and retrieves various types of market data.

Available Tools

Connectivity and Basic Info

  • ping_binance(): Test connectivity to the Binance API server

    • Example: ping_binance()
  • get_server_time(): Get the current server time from Binance

    • Example: get_server_time()

Market Data

  • get_price(symbol): Get the current price for a trading pair

    • Example: get_price(symbol="BTCUSDT")
  • get_order_book(symbol, depth=10): Get the current order book

    • Example: get_order_book(symbol="ETHUSDT", depth=5)
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →