Skip to main content
Glama
NinjaTrader 8 MCP Server

NinjaTrader 8 MCP Server

by anfs-pain

NinjaTrader 8 MCP Server

Claude Code integration for NinjaTrader 8. Gives Claude direct access to accounts, positions, orders, market data, charts, and strategy management through a NinjaScript Add-On running inside NT8.

Architecture

Claude Code (claude.ai/code)
     | stdio JSON-RPC 2.0 (MCP protocol)
     v
src/server.js  (Node.js MCP server — 26 tools)
     | HTTP  localhost:7890
     v
nt8-addon/McpBridgeAddon.cs  (NinjaScript Add-On running inside NT8.exe)
     | NT8 internal API
     +-- Account.All             -> accounts, balances, P&L
     +-- Order.CreateOrder()     -> place / cancel / modify orders
     +-- Account.Positions       -> open positions
     +-- Instrument.All          -> market data, quotes, instrument search
     +-- ChartControl            -> chart state, instrument, reload
     +-- Strategy management     -> enumerate and stop running strategies

Key difference from browser-based MCPs: NT8 has no external HTTP API. McpBridgeAddon.cs is a NinjaScript Add-On that runs inside NT8's process and bridges its internal .NET APIs to an HTTP listener on localhost:7890. Without it, nothing works.


Related MCP server: PineScript MCP Server

Features (26 MCP tools)

Category

Tools

Health

nt_health_check

Connections

nt_connection_status

Accounts

nt_accounts, nt_account_balance, nt_account_info

Positions

nt_positions, nt_position

Orders

nt_orders, nt_place_order, nt_modify_order, nt_cancel_order, nt_cancel_all_orders, nt_close_position, nt_flatten_all

Market Data

nt_quote, nt_instrument_info, nt_instrument_search, nt_bars, nt_depth

Charts

nt_charts, nt_chart_state, nt_chart_instrument, nt_chart_reload

Strategies

nt_strategies_running, nt_strategy_stop

Indicators

nt_indicator_values


Quick Setup

Prerequisites

  • NinjaTrader 8 (any account — Sim, Demo, or Live)

  • Node.js 18+

  • Claude Code

1. Install the Add-On

Copy McpBridgeAddon.cs to NT8's custom Add-Ons folder:

# Adjust the path to match your user directory
Copy-Item "nt8-addon\McpBridgeAddon.cs" `
    "$env:USERPROFILE\OneDrive\Documents\NinjaTrader 8\bin\Custom\AddOns\McpBridgeAddon.cs" -Force

Or copy to:

%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom\AddOns\McpBridgeAddon.cs

2. Compile in NT8

  1. Open NinjaTrader 8

  2. Control Center menu: New -> NinjaScript Editor

  3. In the left tree, expand Add-Ons -> click McpBridgeAddon

  4. Press F5 to compile

  5. If an authorization dialog appears ("NinjaTrader has detected new add-on(s)"), click Yes NT8 will restart and auto-enable the Add-On.

  6. If the port doesn't come up automatically: Tools -> Add-Ons -> check McpBridgeAddon -> OK

3. Verify the Add-On is running

curl.exe http://localhost:7890/api/health
# Expected: {"status":"ok","version":"1.2.0","port":7890,"accounts":N}

4. Install the MCP server

npm install

5. Register with Claude Code

Add to ~/.claude/settings.json under mcpServers:

"ninjatrader": {
  "command": "node",
  "args": ["C:/path/to/ninjatrader-mcp/src/server.js"],
  "env": {
    "NINJATRADER_MODE": "local",
    "NINJATRADER_LOCAL_URL": "http://localhost:7890"
  }
}

Restart Claude Code, then verify:

Use nt_health_check to verify NinjaTrader is connected.

Automated Boot (optional)

scripts/nt8-full-boot.ps1 automates the entire cold-start sequence:

  1. Launch NT8

  2. Complete Google OAuth login (reads credentials from .env)

  3. Select Simulation mode

  4. Open NinjaScript Editor -> compile McpBridgeAddon

  5. Detect and fix compile errors before proceeding

  6. Enable Add-On via Tools -> Add-Ons

  7. Verify port 7890 + run health check

cp .env.example .env   # fill in NINJATRADER_USERNAME
powershell -ExecutionPolicy Bypass -File scripts\nt8-full-boot.ps1

API Reference

The Add-On exposes 26 HTTP endpoints on localhost:7890. The MCP server wraps these as tools.

Key endpoints

GET  /api/health
GET  /api/connection/status
GET  /api/accounts
GET  /api/account/{id}/balance
GET  /api/account/{id}
GET  /api/positions
POST /api/order/place
POST /api/order/cancel
POST /api/order/modify
GET  /api/quote/{symbol}          -- symbol format: "NQ 09-26" not "NQ DEC25"
GET  /api/instrument/{symbol}
GET  /api/instruments/search?q=NQ
GET  /api/bars/{symbol}?period=1&type=minute
GET  /api/orders
POST /api/order/closeposition
POST /api/order/flattenall
GET  /api/charts
GET  /api/chart/state
POST /api/chart/instrument
POST /api/chart/reload
GET  /api/strategies/running
POST /api/strategy/stop
GET  /api/indicator/{symbol}/{name}
GET  /api/depth/{symbol}

Place order

curl -X POST http://localhost:7890/api/order/place \
  -H "Content-Type: application/json" \
  -d '{"accountId":"Sim101","instrument":"NQ 09-26","action":"Buy","orderType":"Market","quantity":1}'

Field names: accountId (not account), instrument (not symbol)

NT8 symbol format: Use NQ 09-26 (futures month-year code). The current front month as of mid-2026 is NQ 09-26. Quarterly rolls change this in March/June/September/December.


Accounts (Simulation)

Account

Connection

Cash

Sim101

Simulation

$100,000

DEMO7847095

Simulation

$50,000

Backtest

-

$100,000

Playback101

-

$0


Environment Variables

Copy .env.example to .env:

NINJATRADER_MODE=local
NINJATRADER_LOCAL_URL=http://localhost:7890
NINJATRADER_USERNAME=your@gmail.com
NINJATRADER_ACCOUNT=simulated

NINJATRADER_USERNAME and NINJATRADER_ACCOUNT are only used by the boot automation script. The MCP server itself only needs NINJATRADER_MODE and NINJATRADER_LOCAL_URL.


Troubleshooting

Symptom

Cause

Fix

Connection refused on port 7890

NT8 not running or Add-On disabled

Start NT8, enable Add-On via Tools -> Add-Ons

Compile error in NinjaScript Editor

API mismatch (rare)

See nt8-addon/McpBridgeAddon.cs header comments

Account not found

No broker connection

Connect Simulation account in NT8 Connections menu

Quote returns zeros

Market closed or no subscription

Normal on weekends; open a chart for that symbol

Order state: Rejected

Market hours (Sim broker)

Expected outside RTH; will fill when market opens

instrument is required

Wrong field name

Use instrument not symbol in order body


File Structure

ninjatrader-mcp/
+-- src/
|   +-- server.js          MCP server (26 tools, JSON-RPC 2.0 over stdio)
|   +-- api.js             NT8 HTTP API client
+-- nt8-addon/
|   +-- McpBridgeAddon.cs  NinjaScript Add-On (runs inside NT8.exe)
|   +-- INSTALL.md         Add-On installation guide
+-- scripts/
|   +-- nt8-full-boot.ps1  Full cold-start automation (launch -> login -> compile -> verify)
|   +-- nt8-enable-addon.ps1  Standalone: enable Add-On via Tools -> Add-Ons
|   +-- nt8-mcp-start.ps1    Standalone: start MCP server (assumes NT8 already running)
+-- .env.example           Environment variable template
+-- package.json
+-- README.md
+-- SETUP_GUIDE.md         Extended setup walkthrough

License

MIT

Available Tools

26 tools
nt_account_balanceB

Get cash value, net liquidation, realized P&L, unrealized P&L, and buying power for an account.

Inputs: accountId.

nt_account_infoA

Get full details for a specific account (name, connection, P&L, buying power).

Inputs: accountId.

nt_accountsA

List all trading accounts in NinjaTrader with balances and open position counts.

Inputs: no named parameters.

nt_cancel_all_ordersA

Cancel all working orders for an account (or all accounts).

Inputs: accountId.

nt_cancel_orderB

Cancel a specific working order by its ID.

Inputs: orderId (required).

nt_chart_instrumentA

[Phase 2] Change the primary instrument on a chart (equivalent of right-click → Data Series → change symbol). Use for quarterly futures rolls. Local mode only.

Inputs: instrument (required), chartId.

nt_chart_listA

List all open chart windows in NinjaTrader with their symbol, timeframe, and chart ID. Local mode only.

Inputs: no named parameters.

nt_chart_reloadA

[Phase 2] Reload all NinjaScript on a chart (equivalent of pressing F5). Use after changing data series. Local mode only.

Inputs: chartId.

nt_chart_stateA

Get current chart state — symbol, timeframe, indicators, and strategies. Use nt_chart_list first to get chart IDs. Local mode only.

Inputs: chartId.

nt_close_positionA

Flatten (close) a specific position by instrument. Submits a market order at NT8 side.

Inputs: instrument (required), accountId.

nt_connection_statusA

Get the status of all broker connections in NinjaTrader (Connected / Disconnected / Connecting). Local mode only.

Inputs: no named parameters.

nt_flatten_allA

EMERGENCY STOP — flatten all open positions and cancel all working orders across all accounts.

Inputs: no named parameters.

nt_health_checkA

Verify the McpBridgeAddon is running inside NinjaTrader and return account count.

Inputs: no named parameters.

nt_historical_barsA

Request historical OHLCV bars. Note: NT8 historical bars are async — returns a placeholder; use nt_quote for live data.

Inputs: symbol (required), bars, interval.

nt_indicator_valuesA

Read the current output series values of a NinjaScript indicator on an open chart. Local mode only.

Inputs: symbol (required), indicatorName (required).

nt_instrument_infoA

Get instrument details: tick size, point value, exchange, currency, instrument type.

Inputs: symbol (required).

nt_market_depthA

Get the Level 2 order book for an instrument. Requires L2 subscription in NT8.

Inputs: symbol (required).

nt_modify_orderA

Modify an existing working order — change quantity, limit price, or stop price.

Inputs: orderId (required), quantity, stopPrice, limitPrice.

nt_ordersA

List orders, optionally filtered by account and/or status (Working, Accepted, Filled, Cancelled, Rejected).

Inputs: status, accountId.

nt_place_orderB

Place a new order (Market, Limit, Stop, or StopLimit) for any instrument.

Inputs: action (required), quantity (required), instrument (required), accountId, +3 more.

nt_positionA

Get a specific position by account and instrument.

Inputs: accountId, instrument.

nt_positionsA

List all open positions across all accounts (or a specific account).

Inputs: accountId.

nt_quoteA

Get the current bid, ask, last price, and volume for an instrument. Requires the instrument to be subscribed in NT8.

Inputs: symbol (required).

nt_search_instrumentsA

Search for instruments by name or symbol (returns up to 50 matches from NT8 instrument database).

Inputs: query (required).

nt_strategies_runningA

List all currently running NinjaScript strategies with their state, chart ID, and symbol. Local mode only.

Inputs: no named parameters.

nt_strategy_stopA

Stop a running NinjaScript strategy by class name. Use nt_strategies_running first to get exact names. Local mode only.

Inputs: strategyName (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 26 tools

    Disambiguation4/5

    Most tools target distinct resources and actions (orders vs positions vs accounts vs charts). The main ambiguity is among the three account tools (nt_accounts, nt_account_info, nt_account_balance), which offer overlapping balance/position information.

    Naming Consistency5/5

    All tools follow the 'nt_' prefix with snake_case, and the pattern is predictable: action verbs for mutations (place_order, cancel_order) and noun phrases for queries (orders, positions, account_info). No camelCase or mixed conventions.

    Tool Count3/5

    26 tools is on the heavy side, but the broad domain of a trading platform justifies many of them. However, there is some redundancy (e.g., three account tools, two position tools) and the chart/strategy tools feel somewhat niche, making the set slightly over-scoped.

    Completeness4/5

    The surface covers core trading workflows: order CRUD, position management, account details, market data, and basic chart/strategy controls. Notable gaps include no tool to start a strategy and the historical bars tool is a non-functional placeholder, but most essential operations are present.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects your TastyTrade trading account to AI assistants like Claude Desktop and ChatGPT for conversational trading and portfolio management.
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables creation, optimization, and management of PineScript trading strategies with Claude Desktop integration for AI-assisted development.
      26 npm
      106
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants like Claude to run backtests, fetch market data, list strategies, and analyze trading algorithms via natural language.
      1,134
      GPL 3.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects Claude AI to TradingView Desktop for multi-angle market analysis using 10 specialized agents, delivering verdicts, confidence scores, and trade levels for symbols like Nifty 50.
      MIT