Skip to main content

How to Connect Sourcegraph Cody to NinjaTrader 8 with CrossTrade MCP

Cody is Sourcegraph's AI coding assistant. Important caveats: Cody supports LOCAL (stdio) MCP servers only — no native remote HTTP MCP. To connect CrossTrade (a remote server), wrap it with the mcp-remote stdio proxy. Cody also requires Sourcegraph Enterprise with the agentic-context-mcp-enabled feature flag turned on.

OAuth scope: mcp:tradeMulti-model harness

Prerequisites

RequirementDetail
CrossTrade subscriptionElite
CrossTrade Add-Onv1.13.0 or higher
NinjaTrader 8Running, broker connected
AccountSim101 for first runs
OAuth scopemcp:trade
Config filecody.mcpServers in settings.json (VS Code) or cody_settings.json (JetBrains)
CrossTrade MCP server
https://app.crosstrade.io/v1/api/mcp
Transport: streamable-http. Auth: OAuth 2.1 + PKCE. Request scope mcp:trade. Read plus write. Place/cancel orders, deploy strategies, compile NinjaScript.

Important: Cody is stdio-only

Cody's official docs are explicit: "Cody currently supports only local MCP servers." For a remote server like CrossTrade, the supported pattern is to wrap it with the mcp-remote stdio proxy.

Prerequisites

  • Cody installed (VS Code Marketplace or JetBrains Marketplace; extension name Cody AI).
  • Sourcegraph Enterprise with agentic-context-mcp-enabled feature flag turned on by your admin. Cody Free and Pro do not have MCP.
  • npx available on PATH (for the mcp-remote proxy).

Step 1: Configure CrossTrade via mcp-remote

In VS Code settings.json (or JetBrains cody_settings.json):

"cody.mcpServers": {
"crosstrade": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://app.crosstrade.io/v1/api/mcp"]
}
}

For JetBrains, use the absolute path to npx:

"cody.mcpServers": {
"crosstrade": {
"command": "/Users/you/.nvm/versions/node/v20.x/bin/npx",
"args": ["-y", "mcp-remote", "https://app.crosstrade.io/v1/api/mcp"]
}
}

Find your absolute npx path with which npx in a terminal.

Step 2: OAuth via mcp-remote

On first connection, mcp-remote opens a browser tab. Authorize CrossTrade. The token caches in ~/.mcp-auth/.

Step 3: First prompt

In Cody chat:

@strategies/ Look at SampleEmaCross.cs. Then call CrossTrade RunStrategyBacktest
on Sim101 for the last 30 days. Where does the live spec disagree with the
backtest assumptions in the source comments?

Cody pairs well with repo-wide code intelligence: ask questions that span both your codebase and live MCP state.

Should you use Cody for CrossTrade?

For most CrossTrade workflows, other MCP hosts are easier: Claude Desktop, Cursor, Cline, OpenCode, and Roo Code all support remote HTTP MCP natively without the proxy step. Use Cody specifically when:

  1. Your team already pays for Sourcegraph Enterprise.
  2. You want repo-aware retrieval mixed with CrossTrade tool calls in the same chat.
  3. The agentic-context-mcp-enabled flag is on.

If none of those apply, see Connect Cline or Connect Cursor.

Sourcegraph's newer Amp product (ampcode.com) DOES support remote HTTP MCP natively, with OAuth + DCR. Amp's config is amp.mcpServers with url + headers directly. If your team is considering Sourcegraph for trading agents, Amp is the better fit; Cody is the older product.

OAuth handshake

The first tool call surfaces an authorization URL. Open it in a browser, approve mcp:trade, and return to the harness. The access token is stored by the harness (keychain, config file, or memory depending on the client).

See CrossTrade MCP OAuth for the full flow, and 403/408 troubleshooting if the handshake fails.

Verify the connection

Smoke-test before doing anything stateful:

Call GetMcpCapabilities and McpSelfTest. Then ListAccounts and GetConnections.
Report add-on version, NT8 version, and which accounts are linked.

If you authorized mcp:trade, also confirm Sim101 is the default account before any order placement.

Funded-account safety
The mcp:trade scope grants order placement. The scope does not protect a funded account; your prompt and account selection do. Default to Sim101 during setup. For funded accounts, verify the firm's automation policy first.

Troubleshooting

SymptomLikely causeFix
403 insufficient_scopeToken authorized at mcp:read but tool requires mcp:tradeReauthorize the connection and select mcp:trade
OAuth callback failsSystem browser blocked the redirect or popupCopy the auth URL manually, complete it, paste the code back
Tools list is empty after connectServer registered but session did not refreshRestart the harness or trigger a tool list refresh
Add-on offline errorNT8 not running, or add-on not loadedConfirm NT8 is open and the CrossTrade add-on (v1.13.0+) is installed
MCP section missing entirelyCody Enterprise feature flag agentic-context-mcp-enabled not enabled on instanceAsk your Sourcegraph admin to enable the flag at the Enterprise instance level
Remote URL doesn't connectCody supports stdio MCP onlyUse the mcp-remote proxy wrapper shown below
Stdio command fails in JetBrainsIDE PATH differs from your shell PATHUse absolute path: which npx and put the full path in command field
Resources or prompts from MCP server not visibleCody supports MCP Tools only, not Resources or PromptsStick to Tools; CrossTrade's API is Tool-based