Rasattrading MCP
A Binance price-action and liquidity-focused MCP server for AI agents, offering 39 tools for market data, analysis, screening, alerts, and order execution with paper-first safety and optional real trading.
README
Rasattrading MCP
A Binance price-action / liquidity-focused Model Context Protocol (MCP) server for AI agents.
A background daemon collects Binance REST/WebSocket data, runs price-action analysis (market structure, liquidity zones, order blocks), and evaluates screener and alarm logic. A thin MCP stdio adapter connects to that daemon over local HTTP RPC and exposes the system to AI agents as tools.
English | Türkçe
Warning: This system can place and close real-money orders on Binance. Read the Safety and risk section before use.
Overview
Rasattrading MCP is a self-hosted, locally run trading system built for agentic use. An AI agent drives it through standard MCP tools; the system never runs unattended market orders by default and enforces a paper-first account lifecycle.
- 39 MCP tools covering market data, price-action analysis, screening, alerts, order execution, and account/risk management.
- Daemon + thin adapter architecture: a single long-lived daemon owns Binance connections, state, and computation; the MCP stdio adapter is a stateless client that forwards calls over HTTP RPC on localhost.
- Paper-first by design: every account starts locked to paper trading. Real trading is a deliberate, one-way, irreversible opt-in per account.
Features
- Price-action analysis: market structure (swings), liquidity zones, order blocks, FVGs,
VWAP sessions, and chart annotations. Computed only on closed candles, stored as
immutable, append-only records (
effective_from/effective_to+algo_version). - Screener:
scan_marketfilters the universe with an allowlisted filter AST (volume_change,price_change,structure_event,liquidity_sweep_occurred,near_order_block,funding_rate,oi_change,above_below_vwap) combined with AND/OR and sortable by symbol, price change, or volume change — safe against free-form SQL/string injection. - Alarm engine: event-driven triggers with deduplication and cooldown; composite alerts
supported. A triggered alarm can create a
pending_orderawaiting approval. - Execution: idempotent order placement, OCO orders, reconcile-before-retry, and a
fail-closed risk policy. Orders are never opened automatically — alarms and order specs
produce
pending_ordersthat require explicit human approval (approve_pending_order). - Paper / real separation: each account starts with
trading_lock=paper.enable_real_tradingis a one-way, irreversible unlock. Accounts with real trading enabled cannot be deleted. - Emergency stop: a standalone kill-switch script (
rasattrading-emergency-stop) that works independently of the daemon — it reads stored credentials directly, cancels open orders, and liquidates spot balances at market price through Binance REST. - Account and risk management: per-account risk policy, position sizing, exposure/balance queries, and an append-only audit hash-chain log.
Architecture
src/rasattrading_mcp/
config.py, errors.py, envelope.py, tools.py, logging_util.py # shared
daemon/ # HTTP IPC server (localhost, bearer token), lock/readiness/handlers
storage/ # SQLite (WAL), migrations, audit hash-chain, credentials (DPAPI), orders, risk_policy
data/ # Binance REST/WS client, rate limit, universe, kline pipeline, futures, order broker
pa/ # price-action chain: swings -> liquidity -> obfvg -> vwap_sessions -> analysis -> screener -> alarms -> worker
adapter/ # MCP stdio subprocess (talks to the daemon over HTTP RPC)
emergency_stop.py # daemon-independent, standalone kill switch
tests/
flowchart LR
Agent["AI agent (MCP client)"]
Adapter["adapter - MCP stdio server"]
Daemon["daemon - HTTP IPC, localhost:8751"]
Data["data - Binance REST/WS, kline pipeline, order broker"]
PA["pa - analysis, screener, alarms, worker"]
Storage["storage - SQLite WAL, DPAPI credentials, audit chain"]
Binance["Binance"]
Stop["emergency_stop.py"]
Agent <-->|stdio| Adapter
Adapter <-->|HTTP RPC, bearer token| Daemon
Daemon <--> Data
Daemon <--> PA
Daemon <--> Storage
Data <-->|REST/WS| Binance
Stop -.->|direct REST, no daemon| Binance
Every tool response uses a common envelope:
{ "ok": true, "data": {}, "meta": { "as_of": "...", "source": "...", "freshness": "...", "algo_version": "..." } }
Errors are { "ok": false, "error": { "code": "...", "message": "..." } }.
Installation
Requirements: Python 3.11+ on Windows. Credential encryption uses Windows DPAPI; the
keyring backend could be ported to other platforms, but development and testing currently
target Windows.
python -m venv .venv
.venv\Scripts\pip install -e .[dev]
.venv\Scripts\python -m pytest -q
Installed console scripts:
| Script | Purpose |
|---|---|
rasattrading-mcp |
MCP stdio adapter. Starts/connects the daemon, then serves MCP tools to the agent. |
rasattrading-daemon |
Runs the daemon standalone. |
rasattrading-emergency-stop |
Standalone emergency kill switch (independent of the daemon). |
Quick start
- Install the package as above.
- Run
rasattrading-mcp. On first use it starts the daemon as a detached subprocess (state under~/.rasattrading/, HTTP IPC on127.0.0.1:8751, bearer token in~/.rasattrading/daemon.lock) and waits until it is ready. - Point any MCP-capable client at the adapter. The server advertises 39 tools; the daemon
state is shared, so the daemon can also be run separately with
rasattrading-daemon. - Register an account with
add_account(API key and secret are encrypted with DPAPI at rest). The account starts in paper mode. - Validate the installation with
ping,get_readiness, andget_candles; watchlist_accountsand the audit log (get_audit_log) to confirm paper mode before anything else.
Order flow: scan_market / create_alert → trigger → pending_order →
approve_pending_order (human confirmation) → broker executes. Nothing opens automatically.
Safety and risk
This project can place and close real-money orders. You use it entirely at your own risk.
- Test in paper mode and on a Binance testnet before connecting a live account.
- Start with small capital.
- Verify
rasattrading-emergency-stopworks in your environment before relying on it. - Real trading is a one-way unlock: re-enabling safety guards after going live is not automatic.
Neither the developers nor the contributors are liable for financial losses resulting from the use of this software. See LICENSE.
Contributing
See CONTRIBUTING.md for environment setup, coding style, and the pull request workflow.
Security
This system handles live exchange credentials and can trade with real money. See SECURITY.md for the supported-versions policy and how to report a vulnerability.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。