Trading-MCP-Server
Integrates with Binance as a broker backend, providing real-time crypto quotes and Futures margin/portfolio tracking through the MCP server's trading tools.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
β‘ Trading-MCP-Server: Institutional Model Context Protocol Server
Institutional Model Context Protocol (FastMCP 2.x) trading server connecting Claude Desktop, Cursor, and LLM coding assistants to multi-broker execution backends (IBKR, Binance, Alpaca). Exposes portfolio analytics, order validation, quantitative Kelly sizing, and streaming market telemetry.
ποΈ System Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LLM Clients (Claude Desktop, Cursor, Agent Swarm) β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β Standard I/O (JSON-RPC)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Trading-MCP-Server Core β
β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β MCP Tools β β MCP Resources β β
β β β’ get_quote β β β’ portfolio:// β β
β β β’ get_portfolio β β β’ risk-limits β β
β β β’ validate_risk β β β’ health β β
β β β’ compute_size β ββββββββββββββββββββ β
β ββββββββββ¬ββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Pre-Trade Risk Engine & Quantitative Math β β
β β β’ Fat-Finger Guard ($50k) β’ Kelly Criterion β β
β β β’ Max Leverage Cap (3x) β’ 30D HV & ATR(14) β β
β β β’ Single-Asset Cap (25%) β’ 1D Parametric VaR β β
β ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Interactive ββ Binance ββ Alpaca Markets β
β Brokers (TWS) ββ (Spot/Futures) ββ (Paper/Live) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββRelated MCP server: ai-trader
π Key Features
Universal Model Context Protocol Support: Implements native MCP tools and resources compliant with Anthropic Claude Desktop, Cursor AI, Cline, and custom agent swarms.
Pre-Trade Risk Guardian: Automatically intercepts and inspects every order before transmission:
Fat-finger limits (default: $50,000 max single order).
Buying power verification and margin utilization guards.
Single-asset portfolio concentration cap (25% default).
Circuit breaker lockdown upon daily drawdown threshold breach.
Quantitative Sizing Engine: Volatility-adjusted position sizing using the Kelly Criterion, Historical Annualized Volatility (HV30), and Average True Range (ATR14).
Multi-Broker Adapters:
Interactive Brokers: TWS / Gateway socket and Client Portal API.
Binance: Real-time crypto quotes and Futures margin tracking.
Alpaca Markets: US Equities and commission-free paper/live execution.
π Available MCP Tools & Resources
MCP Tools (Callable by Claude & Cursor)
Tool Name | Parameters | Description |
|
| Returns real-time bid, ask, last price, spread, and 24h change. |
|
| Returns Net Liquidation Value, cash, margin, and open positions. |
|
| Validates proposed trade against hard pre-trade risk gates. |
|
| Computes optimal share count and capital allocation. |
|
| Computes 30-day volatility, ATR14, and daily expected move. |
MCP Resources
trading://health: Health status and latency telemetry across all broker connections.trading://risk-limits: Current institutional parameters and circuit breaker status.
π» Claude Desktop & Cursor Integration
1. Claude Desktop Setup
Add the server configuration to your claude_desktop_config.json:
{
"mcpServers": {
"Trading-MCP-Server": {
"command": "python",
"args": [
"-m",
"src.server"
],
"env": {
"MCP_TRANSPORT": "stdio",
"IBKR_HOST": "127.0.0.1",
"IBKR_PORT": "7497",
"MAX_ORDER_NOTIONAL_USD": "50000.0"
}
}
}
}2. Cursor AI Setup
Add to your project's .cursor/mcp.json:
{
"mcp": {
"servers": {
"Trading-MCP-Server": {
"command": "python",
"args": ["main.py"],
"transport": "stdio"
}
}
}
}β‘ Quickstart & Interactive Demonstration
1. Installation
git clone https://github.com/jahanzaib-codes/Trading-MCP-Server.git
cd Trading-MCP-Server
pip install -r requirements.txt
cp .env.example .env2. Interactive Terminal Demo
Run the automated end-to-end institutional test suite:
python cli.py demo================================================================================
β‘ TRADING-MCP-SERVER: INSTITUTIONAL DEMONSTRATION SUITE
================================================================================
[1/5] Broker Connector Telemetry:
| Broker | Status | Endpoint |
|----------------------|-----------|--------------------------|
| Interactive Brokers | CONNECTED | 127.0.0.1:7497 |
| Binance Spot/Futures | CONNECTED | api.binance.com |
| Alpaca Markets | CONNECTED | paper-api.alpaca.markets |
[2/5] Real-Time Multi-Asset Market Data Quotes:
| Symbol | Asset Class | Bid | Ask | Last | Spread | 24h Chg |
|----------|---------------|------------|------------|------------|-----------------|-----------|
| NVDA | EQUITY | $142.58 | $142.62 | $142.60 | $0.04 (0.028%) | +1.24% |
| SPY | EQUITY | $585.31 | $585.49 | $585.40 | $0.18 (0.031%) | +1.24% |
| BTCUSDT | CRYPTO | $88,445.57 | $88,454.43 | $88,450.00 | $8.85 (0.01%) | +3.85% |
| SOLUSDT | CRYPTO | $214.19 | $214.21 | $214.20 | $0.02 (0.0093%) | +3.85% |3. Individual CLI Commands
# Fetch live quote for NVDA
python cli.py quote NVDA --broker ibkr
# Inspect Binance portfolio
python cli.py portfolio --broker binance
# Calculate volatility-adjusted position size
python cli.py size --symbol NVDA --equity 100000 --risk 1.5 --entry 142.60 --stop 135.00π³ Docker Deployment
Run as an isolated container:
docker compose up -d --buildπ¨βπ» Author & Institutional Consulting
Developed by Jahanzaib β Quantitative Finance, Algorithmic Trading Systems, and AI Agent Architect.
Telegram: @JanzebBlockdev
GitHub: @jahanzaib-codes
For private institutional deployments, custom broker integrations, or proprietary risk modeling, reach out via Fiverr or Telegram.
π License
This project is licensed under the MIT License β see the LICENSE file for details.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Unified financial infrastructure connecting AI agents directly to trade live/demo brokerage accounts, Web3 non-custodial wallets, real-time market data across equities, ETFs, crypto, forex, options, DeFi swaps, and prediction markets, institutional research feeds, and algorithmic strategy backtesters.
Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.
Build, backtest, and deploy quantitative trading strategies from your AI agent.
AI agents backtest, paper trade and live trade via your broker. Free to connect; OAuth.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceConnects your TastyTrade trading account to AI assistants like Claude Desktop and ChatGPT for conversational trading and portfolio management.5MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants like Claude to run backtests, fetch market data, list strategies, and analyze trading algorithms via natural language.1,141GPL 3.0
- AlicenseNot gradedqualityDmaintenanceConnects a brokerage account to AI assistants, enabling portfolio queries, order management, and market data access through natural language.MIT
- FlicenseNot gradedqualityBmaintenanceConnects AI agents to real-time market data, options analysis, broker order staging, and automated alerts and workflows.-