Skip to main content
Glama
ATAS MCP Bridge

ATAS MCP Bridge

ATAS MCP Bridge

CI License: MIT Python: 3.10+ MCP: 2.0 Platform: ATAS 7.x & 8.x Release: v1.0.0

Model Context Protocol (MCP) server connecting ATAS Platform (7.x) and ATAS X (8.x) to AI agents and development assistants.

Leer en Espanol


Overview

ATAS MCP Bridge bridges the gap between institutional-grade order flow trading in ATAS and modern AI models. It exposes real-time market data, full order book depth (DOM), delta volume candles, account positions, open orders, trade executions, and automated order routing directly to AI assistants.

Compatible with all major AI coding agents and MCP clients:

  • OpenCode

  • Qwen Code

  • Kiro (CLI & IDE)

  • Claude Code

  • OpenAI Codex / Developers Platform

  • OpenClaw

  • Kimi Kode

  • Z Code

  • Google Antigravity (AGY CLI & IDE)

  • Cursor

  • Claude Desktop

  • Windsurf / VS Code (Cline & Roo Code)


Related MCP server: MetaTrader 5 MCP Server

Architecture

+------------------------------------+          HTTP / SSE (127.0.0.1:8787)         +----------------------+
|           ATAS Platform            | <------------------------------------------> |   MCP Server (Py)    |
|            "MCP Bridge"            |             GET  /api/*                      |      server.py       |
|    (ChartStrategy in C# / .NET)    |             POST /api/order                  |      (mcp 2.0)       |
+------------------------------------+             GET  /api/stream                 +----------------------+
                                                                                               ^
                                                                                               | MCP (stdio)
                                                                                               v
                                                                                    +----------------------+
                                                                                    |      AI Clients      |
                                                                                    |  - OpenCode          |
                                                                                    |  - Qwen Code         |
                                                                                    |  - Kiro              |
                                                                                    |  - Claude Code       |
                                                                                    |  - OpenAI Codex      |
                                                                                    |  - OpenClaw          |
                                                                                    |  - Kimi Kode         |
                                                                                    |  - Z Code            |
                                                                                    |  - Antigravity       |
                                                                                    |  - Cursor            |
                                                                                    |  - Claude Desktop    |
                                                                                    +----------------------+

Communication Flow:

  1. C# Addon (ATAS.McpBridge): Runs inside the ATAS process as a native ChartStrategy. It hosts an embedded HTTP and Server-Sent Events (SSE) listener on 127.0.0.1:8787.

  2. Thread Safety & Lock-Free Design: All ATAS API calls occur strictly on the main ATAS thread within OnCalculate(). Incoming HTTP execution requests are queued in a thread-safe ConcurrentQueue and processed on the next tick. Read requests are answered immediately from volatile in-memory JSON snapshots without interrupting market data processing.

  3. Python MCP Server (server.py): Speaks Model Context Protocol over standard I/O (stdio), exposing 12 production-ready tools with robust structured error handling.

  4. Python HTTP Client (atas_client.py): Zero-dependency client using Python standard library with automated port discovery and environment variable support.


MCP Tools (12 Tools)

Tool

Description

Parameters

atas_status

Returns bridge connectivity status, symbol, portfolio account, tick size, activation state, and active port.

None

atas_quote

Live quote snapshot: last price, best bid and ask with volumes, DOM cumulative volume (order flow imbalance), spread, and tick size.

None

atas_dom

Full order book depth (DOM): sorted bids (highest first) and asks (lowest first) with exact price and size.

levels (int, default: 15)

atas_candles

Historical bars (up to 2000 candles) for the chart: open, high, low, close, volume, delta, timestamp, and the current forming candle.

None

atas_position

Current open position details: net volume, average entry price, direction (Buy/Sell), open PnL, and closed PnL.

None

atas_orders

Working orders: ID, direction, order type, price, trigger price, executed volume, remaining volume, and order state.

None

atas_trades

Execution log (fills) completed during the active session.

None

atas_snapshot

Consolidates status, quote, DOM, candles, orders, position, and trades in a single call.

None

atas_place_order

Places an order through ATAS. Prices are automatically rounded and snapped to instrument tick size.

direction ("buy"/"sell"), order_type ("limit"/"stop"/"market"/"stoplimit"), qty (float), price (optional float), trigger_price (optional float), comment (optional string)

atas_cancel_order

Cancels an open working order by its unique ID.

order_id (string)

atas_close_position

Closes (flattens) the current position using an opposing market order for the full or partial volume.

volume (optional float), direction (optional string)

atas_bridge_log

Retrieves recent diagnostic logs from the C# bridge inside ATAS for debugging.

None


HTTP REST and SSE Endpoints

The C# addon serves the following endpoints locally at http://127.0.0.1:8787:

Endpoint

Method

Description

/api/health

GET

Health check ({"ok":true,"id":"atas-mcp-bridge","version":"1.0.0"}).

/api/status

GET

Metadata: platform version, instrument, security code, portfolio, and tick size.

/api/quote

GET

Live ticker, best bid/ask, and cumulative order book imbalance.

/api/dom

GET

Full depth of market book snapshot.

/api/candles

GET

Array of completed candles plus current active bar.

/api/orders

GET

List of working orders.

/api/position

GET

Calculated net position and session PnL.

/api/trades

GET

Session trade executions (fills).

/api/snapshot

GET

All-in-one consolidated payload.

/api/log

GET

Diagnostic log buffer.

/api/order

POST

Submits a new order ({"direction":"buy","type":"limit","qty":1,"price":22000.25}).

/api/order/cancel

POST

Cancels an existing order ({"id":"<order_id>"}).

/api/position/close

POST

Flattens the open position ({}).

/api/stream

GET (SSE)

Real-time Server-Sent Events: quote (200ms throttle), dom (500ms throttle), position (1000ms throttle), orderSent, orderFailed, orderCancelSent, flattenSent.


Prerequisites

  • Operating System: Windows 10 / 11 (x64)

  • Platform: ATAS Platform (7.x) or ATAS X (8.x) installed

  • .NET SDK: .NET 8 SDK or higher (winget install Microsoft.DotNet.SDK.8 or dotnet --version)

  • Python: Python 3.10 or higher with pip


Installation and Quickstart

1. Clone the repository and install dependencies

git clone https://github.com/Ax3lsk3r3/atas-mcp.git
cd atas-mcp
pip install -r requirements.txt

Optionally install as an editable package so the atas-mcp CLI command is globally available:

pip install -e .

2. Compile and deploy the C# Addon

Run the build script:

build.bat

The script compiles the project in Release mode and copies ATAS.McpBridge.dll to both ATAS strategy folders:

  • %APPDATA%\ATAS\Strategies\ (ATAS Platform 7.x)

  • %APPDATA%\ATAS X\Strategies\ (ATAS X 8.x)

3. Attach the Strategy in ATAS

  1. Launch ATAS (or ATAS X).

  2. Open a chart for the instrument you want to trade (e.g. NQ, ES, BTCUSDT, EURUSD).

  3. Right-click the chart -> select Indicators (or Add Indicator).

  4. Search for MCP Bridge and add it to the chart.

  5. In the strategy properties panel:

    • Check the IsActivated checkbox.

    • Select your portfolio / account (simulation or demo accounts recommended).

  6. Verify in your web browser:

    • Navigate to http://127.0.0.1:8787/api/health

    • Expected output: {"ok":true,"id":"atas-mcp-bridge","version":"1.0.0"}

4. Run the Automated Smoke Test

Verify the Python client against a local mock bridge without launching ATAS:

python test_client.py

All 13 automated tests should pass.

5. Start the MCP Server

The server supports two primary modes:

Mode A: Stdio (for local desktop IDEs and CLIs):

start_mcp.bat
# or directly:
python server.py
# or if installed via pip:
atas-mcp

Mode B: Server-Sent Events (SSE) (for web applications, remote environments, cloud agents):

start_mcp_sse.bat
# or directly:
python server.py --transport sse --host 127.0.0.1 --port 8000
# or with Docker:
docker compose up -d

The SSE endpoint will be available at http://127.0.0.1:8000/sse for web chat UIs (LibreChat, Open WebUI, AnythingLLM) and remote agent runners (OpenClaw, LangChain, CrewAI, AutoGen).


Client Integration Examples

Detailed setup guides for all supported clients are provided in mcp-config-examples.md.

OpenCode

Add to ~/.config/opencode/config.json or project opencode.json:

{
  "mcp": {
    "atas": {
      "type": "stdio",
      "command": "python",
      "args": ["<PATH_TO_ATAS_MCP>/server.py"]
    }
  }
}

Qwen Code

Run via CLI:

qwen mcp add atas python "<PATH_TO_ATAS_MCP>/server.py"

Kiro (CLI & IDE)

Run via CLI:

kiro mcp add atas python "<PATH_TO_ATAS_MCP>/server.py"

Claude Code (CLI)

Run via CLI:

claude mcp add atas -- python "<PATH_TO_ATAS_MCP>/server.py"

Google Antigravity (AGY)

Add to %USERPROFILE%\.gemini\config\mcp_config.json:

{
  "mcpServers": {
    "atas": {
      "command": "python",
      "args": ["<PATH_TO_ATAS_MCP>/server.py"]
    }
  }
}

Cursor

Add to %USERPROFILE%\.cursor\mcp.json:

{
  "mcpServers": {
    "atas": {
      "command": "python",
      "args": ["<PATH_TO_ATAS_MCP>/server.py"]
    }
  }
}

Claude Desktop

Add to %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "atas": {
      "command": "python",
      "args": ["<PATH_TO_ATAS_MCP>\\server.py"],
      "cwd": "<PATH_TO_ATAS_MCP>"
    }
  }
}

Technical Details

  1. ATAS 7.x and 8.x Compatibility:

    • Targets .NET 8, which runs natively on ATAS 7.x and forwards cleanly into ATAS X .NET 10 cross-platform runtime.

    • Uses IndicatorCandle for full access to volume and delta statistics.

    • Price rounding respects ShrinkPrice(price) to prevent exchange reject errors.

    • Full order book depth snapshot extracted via MarketDepthInfo.GetMarketDepthSnapshot().

  2. Position Tracking:

    • In ChartStrategy, the net open volume and direction are computed from strategy-specific execution fills (MyTrades).

    • This ensures safe isolation: manual orders outside this strategy do not corrupt the algorithmic tracking of the strategy.

  3. Dynamic Port Discovery:

    • If port 8787 is occupied, the C# bridge scans ports 8787 through 8807 automatically.

    • The selected port is stored in %APPDATA%\ATAS\McpBridge.port and %APPDATA%\ATAS X\McpBridge.port.

    • atas_client.py auto-discovers this file or falls back to the ATAS_MCP_PORT environment variable.


Troubleshooting

Issue

Likely Cause

Solution

dotnet is not recognized

.NET 8 SDK is missing or PATH is not refreshed.

Run install_sdk.bat or winget install Microsoft.DotNet.SDK.8 and open a fresh terminal.

http://127.0.0.1:8787/api/health does not respond

Strategy is not added to a chart or IsActivated is unchecked.

Open ATAS, add MCP Bridge via chart Indicators, and check IsActivated. Check %APPDATA%\ATAS\McpBridge.log.

Network Access Denied on port bind

Windows HTTP.sys reservation missing.

Run in an Administrator Command Prompt: netsh http add urlacl url=http://localhost:8787/ user=Everyone (or language equivalent).

AI Client cannot find atas_* tools

Incorrect path in client MCP configuration file.

Verify that the path in your client JSON points to the absolute path of server.py on your machine.

Orders are rejected

Portfolio is not connected or demo connection inactive.

Verify in ATAS that your connector/broker status is green and select a valid portfolio in the strategy settings.


Risk Disclaimer

This software connects directly to financial trading platforms and can place binding orders on financial markets. Trading futures, equities, forex, and cryptocurrencies involves substantial risk of loss and is not suitable for every investor.

  • Always test strategies, prompts, and tool calls thoroughly on simulated accounts (DEMO or Market Replay) before deploying capital.

  • This software is distributed strictly for educational and technical automation purposes, without warranty of any kind.


License

MIT License. See LICENSE for details.

Available Tools

12 tools
atas_bridge_logA

Recent diagnostic logs from the ATAS bridge running inside ATAS. Useful when troubleshooting strategy activation, tick processing, or order issues.

Inputs: no named parameters. Returns: object

atas_cancel_orderA

Cancel a working order by its ID (see atas_orders for working order IDs).

Inputs: order_id (required). Returns: object

atas_candlesA

Recent candle history for the chart the strategy is attached to (up to 2000 bars): open, high, low, close, volume, delta, and time, plus the current forming candle. Essential for context and technical analysis.

Inputs: no named parameters. Returns: object

atas_close_positionA

Flatten the current position using a market order. If volume and direction are omitted, the strategy automatically calculates the opposite direction and entire volume to close the position completely.

Inputs: volume, direction. Returns: object

atas_domA

Current market depth (DOM / order book): asks (lowest price first) and bids (highest price first), each level with price and volume. The 'levels' argument limits how many levels are returned per side.

Inputs: levels. Returns: object

atas_ordersB

All working (active) orders with ID, direction, type, price, trigger price, filled quantity, unfilled quantity, and state.

Inputs: no named parameters. Returns: object

atas_place_orderA

Place an order through ATAS. Parameters: direction ('buy' or 'sell'); order_type ('limit', 'stop', 'market', or 'stoplimit'); qty (number of contracts/lots); price (required for limit and stoplimit); trigger_price (required for stop and stoplimit); comment (optional order label). Prices are automatically snapped to instrument tick size.

Inputs: qty (required), direction (required), order_type (required), price, +2 more. Returns: object

atas_positionA

Current open position details (volume, average price, direction, realized and unrealized PnL) derived from strategy fills.

Inputs: no named parameters. Returns: object

atas_quoteA

Live quote snapshot: last traded price, best bid/ask with sizes, cumulative DOM bid/ask volume (order flow imbalance), spread, and tick size.

Inputs: no named parameters. Returns: object

atas_snapshotA

Everything at once: status, quote, DOM, candles, orders, position, and trades in a single call. Useful for full context on each turn.

Inputs: no named parameters. Returns: object

atas_statusA

Connection status of the ATAS bridge: symbol, portfolio, tick size, whether the strategy is activated, bridge port, and current state. Call this first to verify the bridge is reachable.

Inputs: no named parameters. Returns: object

atas_tradesB

Recent executed trades (fills) of the current session.

Inputs: no named parameters. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 12 tools

    Disambiguation5/5

    Each tool addresses a single, well-defined aspect: market data (quote, DOM, candles), account state (position, orders, trades), actions (place, cancel, close), and diagnostics (log, status). The aggregate snapshot overlaps by design but is explicitly presented as a convenience for full context. No two tools appear to perform the same function.

    Naming Consistency5/5

    All tools share the 'atas_' prefix and use a consistent convention: noun-style names for data retrieval (quote, dom, position) and imperative verb_noun names for mutations (place_order, cancel_order, close_position). This read/write distinction makes the toolset predictable and easy to navigate. Minor variation like 'bridge_log' as a compound noun does not create confusion.

    Tool Count5/5

    Twelve tools is well within the ideal range for a trading bridge application. Each tool serves a distinct purpose and the set feels neither bloated nor sparse. The inclusion of an aggregate snapshot is justified as a convenience for agents needing full state in one call.

    Completeness4/5

    The toolset covers the essential lifecycle: read market data, inspect position/orders/trades, place and cancel orders, and close positions. It lacks a dedicated order modification operation, but agents can cancel and re-place orders as a workaround. Basic connection diagnostics and status are also included, making the surface practical for automated trading.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with the MetaTrader 5 trading platform for market data analysis, placing trades, and managing trading positions. Provides comprehensive access to forex and financial market operations through the Model Context Protocol.
      1
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to connect to MetaTrader 5 for trading, market data access, and account management through the Model Context Protocol.
      118 PyPI
      243
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Exposes a unified AI interface to MetaTrader 5 over the Model Context Protocol, enabling live quotes, historical data, technical indicators, order execution, position management, and headless backtests.
      109 PyPI
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to perform market analysis through typed access to deterministic market data, technical indicators, backtesting, and position sizing via the Model Context Protocol.
      5
      2
      MIT