Rasattrading MCP
Provides tools for interacting with Binance's trading API, enabling AI agents to manage accounts, execute trades, analyze price action, screen markets, and handle alerts and risk management.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Rasattrading MCP Scan for symbols with recent liquidity sweeps near order blocks"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 | Turkish
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.
Related MCP server: tradingview-mcp
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. Alarm-generated order specs follow the approval path:
pending_orders→ explicit human approval viaapprove_pending_order. Theexecute_on_accountsandplace_ordertools are exceptions: they place orders directly and bypass the pending-approval queue. If the account is unlocked for real trading, those tools can place real-money orders.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| BinanceEvery 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 -qInstalled console scripts:
Script | Purpose |
| MCP stdio adapter. Starts/connects the daemon, then serves MCP tools to the agent. |
| Runs the daemon standalone. |
| 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.
Available Tools
39 toolsadd_accountA
Spot hesap ekler. api_key/api_secret verilmezse hesap public/read-only modda oluşturulur; secret alanlar hiçbir cevapta döndürülmez.
Inputs: label (required), tags, market, api_key, +3 more.
annotate_chartA
Sembol+timeframe'e agent işaretlemesi ekler (örn. {level, label, kind}). Hesaplamaya etkisi yoktur, kalıcı kaydedilir.
Inputs: symbol (required), timeframe (required), annotations (required), created_by, +2 more.
approve_pending_orderA
Onay bekleyen emri onaylar ve GERÇEK emir olarak açar. Boyutlandırma daemon tarafında yapılır (risk_pct x hesap equity'si + sembol filtreleri). Idempotency: pending:<order_id> key'iyle retry çift emir üretmez. Bu işlem gerçek para kullanır — yalnızca kullanıcının açık onayıyla çağrılmalı.
Inputs: order_id, request_id, idempotency_key.
calculate_position_sizeA
Risk-bazlı pozisyon boyutu hesaplar (base asset): account_balance * risk_pct risk tutarı, |entry - stop| risk-per-unit'e bölünür; fee düşülür; LOT_SIZE/MIN_NOTIONAL/PRICE_FILTER'e göre aşağı yuvarlanır. Borsa filtreleri karşılanamıyorsa FILTER_VIOLATION döner (fail-closed). Temel doğruluk kontrolleri her zaman aktiftir: stale fiyat / yanlış stop yönü / bilinmeyen sembol / yetersiz bakiye reddedilir.
Inputs: entry (required), symbol (required), risk_pct (required), stop_loss (required), +5 more.
clear_annotationsA
Sembol+timeframe'in tüm işaretlemelerini siler; silinen sayıyı döner.
Inputs: symbol (required), timeframe (required), request_id, idempotency_key.
close_all_positionsA
Hesabın (veya account_id='all' ise tüm hesapların) açık emirlerini iptal edip base asset bakiyelerini market fiyatından satar. Kısmi başarıda hangi hesabın kapandığı/kapanamadığı açıkça raporlanır; idempotenttir (tekrar çalıştırma çift satış yapmaz). Paper hesapta gerçek bakiye satışı yapılmaz; yanıt closed=false, simulated=true ve position_close_supported=false ile yalnızca yerel emir iptalini belirtir. İptal geçişleri audit_log'a yazılır.
Inputs: account_id (required), request_id, idempotency_key.
create_alertA
Tek sembol+timeframe için koşullu alarm tanımlar. Koşul, scan_market ile aynı allowlisted filtre AST'sidir. State machine: armed→triggered→cooldown→armed; aynı veri penceresi tekrar tetiklenmez (dedup).
Inputs: note, symbol, condition, timeframe, +4 more.
create_composite_alertA
Birden çok clause'ı AND/OR ile birleştiren alarm. Her clause bir (symbol,timeframe) çifti + koşul taşır; tüm clause'ların verisi taze olmadan değerlendirilmez (stale → tetiklenmez).
Inputs: note, clauses, combine, request_id, +2 more.
delete_alertB
Alarm tanımını siler.
Inputs: alert_id, request_id, idempotency_key.
disable_real_tradingA
Kill switch: hesabın (veya 'all') trading kilidini real'den paper'a çevirir; yeni emirler gönderilmez. Audit log'a yazılır; zaten paper ise idempotent.
Inputs: account_id (required), request_id, idempotency_key.
enable_real_tradingA
Hesabın trading kilidini kalıcı olarak real'e çevirir (tek yönlü; zaten real ise idempotent). Credential'sız hesapta reddedilir; değişiklik audit_log'a yazılır.
Inputs: account_id (required), request_id, idempotency_key.
execute_on_accountsA
Birden çok hesapta pozisyon açar. account_ids + tags birlikte verilirse UNION'dur; ikisi de boşsa reddedilir. Emir boyutu daemon'ın kendi taze bakiye/equity/fiyat snapshot'ından hesaplanır (agent rakamlarına güvenilmez). Idempotency: aynı idempotency_key retry'i çift emir üretmez. Kısmi başarı: hesap başına ayrı sonuç döner. Temel doğruluk kontrolleri (bakiye/stale/stop yönü/sembol) her zaman aktiftir.
Inputs: side (required), entry (required), symbol (required), risk_pct (required), +6 more.
get_account_balanceA
Hesabın tam bakiye görünümü: free (serbest), locked (açık emirlerde kilitli), holdings_value (elde tutulan base asset'lerin güncel piyasa değeri) ve total/equity (free + locked + holdings_value). Sadece serbest bakiyeyi değil, hesabın gerçek toplam değerini döner — daemon'ın kendi taze bakiye/fiyat snapshot'ıyla.
Inputs: account_id (required), request_id, idempotency_key.
get_audit_logC
Hash-chain doğrulamalı audit log sorgusu. verified=true ise zincir sağlam; değilse broken kırık satırları içerir.
Inputs: limit, request_id, idempotency_key.
get_candlesB
Ham OHLCV mum verisi. Sembol sabit izlenen timeframe setinde ise (15m/1h/4h/1d) öncelikli warm-up yapılır; değilse istek anında canlı çekilir. meta.freshness son barın güncelliğini gösterir.
Inputs: symbol (required), timeframe (required), limit, source, +2 more.
get_chart_annotationsC
Sembol+timeframe'in kayıtlı işaretlemelerini döner.
Inputs: symbol (required), timeframe (required), request_id, idempotency_key.
get_full_analysisA
Tek çağrıda tüm PA özeti: yapı + likidite + order block/FVG + VWAP + session seviyeleri. Context şişmesin diye vwap noktaları sınırlıdır. meta.algo_version ve data.algo_version tüm bileşen sürümlerini taşır; data.versions her bileşeni ayrı verir. Likidite skorunun equal_levels açıklamasındaki zones toplamıdır; aktif (mitigasyonsuz) sayı varsayılan zones listesiyle birebir örtüşür.
Inputs: symbol (required), timeframe (required), lookback, request_id, +2 more.
get_liquidity_zonesA
Equal highs/lows likidite bölgeleri + sweep/mitigasyon durumu + futures tabanlı likidite skoru. Varsayılan yalnızca aktif (mitigasyonsuz) bölgeleri döner; include_mitigated=true ile depolanan tarihçenin tamamı döner. Skorun equal_levels bileşeni aktif bölge sayısına göre puanlanır (mitigasyonlular puan getirmez); funding bileşeni bias: long_crowded|short_crowded taşır. NOT: include_mitigated=true tarihçe, eski (2.15 öncesi) semantiğe göre mitigated=false kalmış breaker kayıtlarını da içerebilir — bu beklenen immutable-tarihçe davranışıdır, listedeki her bölge 'aktif' değildir; aktif görünüm varsayılan çağrıdır.
Inputs: symbol (required), timeframe (required), lookback, request_id, +2 more.
get_market_structureC
Swing High/Low + BOS/CHoCH yapısı: trend, swing'ler (HH/LH/HL/LL) ve yapı kırılım olayları. meta.algo_version algoritma sürümünü taşır.
Inputs: symbol (required), timeframe (required), lookback, request_id, +1 more.
get_open_ordersA
Borsadaki (Binance) GERÇEK açık emirleri döner — get_pending_orders'ın aksine bu MCP'nin dahili onay kuyruğu değil, borsada fiilen bekleyen emirlerdir (OCO/stop-loss/limit dahil; hesap bakiyesindeki locked miktarın kaynağı budur). Salt-okunur, hiçbir emri değiştirmez/iptal etmez.
Inputs: account_id (required), request_id, idempotency_key.
get_order_blocksA
BOS/CHoCH sonrası order block'lar (order_block|breaker|mitigation_block) + FVG'ler. Varsayılan yalnızca aktif bölgeler; include_mitigated=true ile tam tarihçe. Breaker'lar kapanışla kırılmış OB olduğu için mitigated=true taşır; aynı/çok yakın fiyat aralığındaki OB'ler tek mantıksal bölgede birleştirilir (2.15). NOT: include_mitigated=true tarihçe, eski semantiğe göre mitigated=false kalmış breaker kayıtlarını da içerebilir (immutable geçmişin üzerine yazılmaz) — listedeki her bölge 'aktif' değildir; aktif görünüm varsayılan çağrıdır.
Inputs: symbol (required), timeframe (required), lookback, request_id, +2 more.
get_pending_ordersA
Onay bekleyen emir kayıtlarını listeler (alarm order_spec'i tetiklenince awaiting_approval kaydı düşer). status filtresi: awaiting_approval|approved|executing|rejected|executed|reconcile_required|expired. Emirler otomatik açılmaz — approve_pending_order gerekir.
Inputs: limit, status, request_id, idempotency_key.
get_readinessC
Daemon hazır olma durumu: starting|migrating|warming_up|ready ve pipeline sağlığı.
Inputs: request_id, idempotency_key.
get_risk_policyA
Hesabın mevcut risk politikasını döner (configüre edilmemişse boş/limitsiz varsayılan).
Inputs: account_id (required), request_id, idempotency_key.
get_symbol_infoA
Binance exchangeInfo filtrelerini döner: LOT_SIZE (step_size/min_qty/max_qty), MIN_NOTIONAL, PRICE_FILTER (tick_size/min_price/max_price) + sembol durumu. meta.freshness exchangeInfo'nun güncelliğini gösterir.
Inputs: symbol (required), request_id, idempotency_key.
get_tickerA
Sembolün anlık 24h ticker'ı (miniTicker WS'ten). meta.freshness verinin güncel olup olmadığını söyler; WS kopuksa stale döner.
Inputs: symbol (required), request_id, idempotency_key.
get_total_exposureA
Tüm hesapların toplam exposure'ını döner: sembol bazlı (açık emir notional + base bakiye değeri, daemon'ın taze fiyatıyla) ve hesap bazlı özet.
Inputs: request_id, idempotency_key.
get_triggered_alertsA
Kalıcı tetiklenme kayıtlarını döner (agent kapalıyken tetiklenenler kaybolmaz). İsteğe bağlı alert_id filtresi + sayfalama.
Inputs: limit, cursor, alert_id, request_id, +1 more.
get_unprotected_positionsA
Tüm real hesaplarda, açık SELL emri (stop-loss/take-profit/OCO dahil) olmayan dust-üstü base asset bakiyelerini bulur — 'hangi pozisyon korumasız kaldı' sorusuna tek çağrıda cevap. Salt-okunur, hiçbir emri değiştirmez. Boş sonuç = taranan tüm real hesaplarda her pozisyon en az bir açık SELL emriyle eşleşiyor demektir.
Inputs: request_id, idempotency_key.
list_accountsB
Hesapları secret içermeyen özetlerle listeler. credentials_configured/read_only alanları hesapta API anahtarı bulunup bulunmadığını gösterir.
Inputs: request_id, idempotency_key.
list_alertsC
Tüm alarm tanımlarını durumlarıyla (armed/triggered) listeler.
Inputs: request_id, idempotency_key.
override_risk_policyA
Tek kullanımlık, atomik risk politikası istisnası (scope='next_order'). Yalnızca kullanıcı-tanımlı cap'leri bir emir için aşmaya izin verir; temel doğruluk kontrollerini asla atlamaz. reason zorunludur, audit_log'a yazılır. Aynı idempotency_key ile retry aynı override'a bağlanır, ikincil üretmez.
Inputs: reason (required), account_id (required), scope, expires_at, +2 more.
pingA
Daemon ile bağlantı ve canlılık kontrolü. Tool çağrısı için ready gerekmez.
Inputs: request_id, idempotency_key.
place_oco_orderA
Spot OCO emri: kâr hedefi (LIMIT) + stop (STOP_LOSS_LIMIT) TEK emir listesinde. Biri dolunca diğeri borsada otomatik iptal olur (true OCO). Aynı pozisyon için ayrı ayrı SL+TP emri bakiyeyi birbirinden çaldığı için imkânsızdır; bu tool ikisini tek orderList/oco çağrısında taşır. price=TP, stop_price=stop tetikleme, stop_limit_price=stop tetiklenince satılacak limit (stop_price'dan düşük olmalı).
Inputs: side (required), price (required), symbol (required), quantity (required), +5 more.
place_orderA
Tek hesapta doğrudan emir gönderir (order_type: MARKET|LIMIT|STOP_LOSS_LIMIT, miktar base asset). STOP_LOSS_LIMIT spot stop korumasıdır: stop_price'a ulaşınca price seviyesinde LIMIT satış tetiklenir (pozisyonu borsada korur, daemon kapalı olsa bile). Aynı idempotency_key ile retry çift emir üretmez; ağ zaman aşımında Binance'ten gerçek durum reconcile edilir. Temel doğruluk kontrolleri her zaman aktiftir.
Inputs: side (required), symbol (required), quantity (required), account_id (required), +5 more.
reject_pending_orderB
Onay bekleyen emri reddeder (emir açılmaz).
Inputs: reason, order_id, request_id, idempotency_key.
remove_accountB
Hesabı ve bağlı credential kayıtlarını kaldırır; işlem audit log'a yazılır.
Inputs: account_id (required), request_id, idempotency_key.
scan_marketA
Sembol evrenini allowlisted filtre AST'si ile tarar (serbest SQL değil). Filtre türleri: volume_change, price_change, structure_event, liquidity_sweep_occurred, near_order_block, funding_rate, oi_change, above_below_vwap; and/or düğümleriyle iç içe kullanılabilir. Her satır data_stale (PA tazeliği) YANINDA symbol_valid (evrende işlem yapılabilir mi — delist olmayan), matched_filters (hangi filtre(ler) eşleşti) ve signal_summary (eşleşmeyi tetikleyen ham değerler) taşır (2.16). data_stale=false tek başına sembolün işlem yapılabilir olduğu anlamına gelmez; symbol_valid kontrol edin.
Inputs: filters (required), limit, cursor, combine, +4 more.
set_risk_policyA
Hesap için isteğe bağlı risk politikası tanımlar: max_notional_per_order, max_aggregate_exposure, allowed_symbols. Varsayılan tamamen boş/limitsiz. Cap'ler KATI üst sınırdır — tolerans uygulanmaz, yuvarlama sonrası nihai değer <= cap olmalıdır. Patch'te gönderilmeyen değerler korunur; temizleme yalnızca açık clear_max_notional, clear_max_exposure veya clear_allowed_symbols boolean'larıyla yapılır.
Inputs: account_id (required), request_id, allowed_symbols, idempotency_key, +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 39 tools
Most tools target distinct resources and actions, with clear separation between account management, risk policy, order placement, alerts, and market analysis. Potential confusion points like get_open_orders vs get_pending_orders and execute_on_accounts vs place_order are explicitly disambiguated in descriptions, though a few pairs (create_alert/create_composite_alert, get_full_analysis versus component analysis tools) still require careful reading.
The names mostly follow a consistent verb_noun snake_case pattern (get_, set_, create_, delete_, list_, place_, approve_, reject_). Minor deviations exist: 'ping' lacks a get_ prefix, and 'annotate_chart' contrasts with 'get_chart_annotations', but these are understandable and do not break the overall pattern.
With 39 tools, this is well beyond the 16-25 range considered heavy. While each tool has a defined role, the sheer count makes the surface area large and could overwhelm an agent, suggesting the tool set could be consolidated (e.g., combining analysis getters into fewer summary tools).
The server covers a broad domain: account lifecycle, risk policies, order placement (including OCO), alerts, market analysis, audit, and protected-position scanning. However, notable gaps exist: there is no single-order cancel tool, no individual position close (only close_all_positions), and no alert update mechanism, which forces workarounds or bulk operations.
Maintenance
Related MCP Connectors
Research-only MCP server: your AI as a quant research desk. 90 tools, no trades, no brokers.
Unlock the power of real-time cryptocurrency data with our Crypto Price Insights MCP server.
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that streams the latest Binance announcements to your AI agents in real time, enabling instant analysis and action on market-moving updates.11MIT
- AlicenseNot gradedqualityDmaintenanceThe most complete AI-powered trading toolkit for Claude and MCP clients, offering backtesting, live sentiment, Yahoo Finance, and 30+ technical analysis tools in one MCP server.MIT
- AlicenseNot gradedqualityDmaintenanceMCP server providing 12 computed intelligence tools for Binance, including accumulation detection, whale tracking, market impact simulation, and more, using public endpoints with no API keys needed.8MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that enables any compatible AI model to autonomously trade Binance USDT-margined perpetual futures. Includes a separate paper-trading strategy lab that requires no credentials.1MIT