Connect Trade MCP Server

The Connect Trade MCP server gives AI agents structured, permissioned access to brokerage accounts, live trading, and real-time market data through the Model Context Protocol (MCP). Connect it to your AI coding assistant in 5 minutes, or embed it in an existing AI product.

Quick Start with an AI Coding Assistant

If you already use Claude Code, Cursor, Windsurf, VS Code (GitHub Copilot), or Codex CLI, you can point it at the Connect Trade MCP server without writing any code. Mint a JWT for a test user, paste it into your assistant's MCP config, and start asking about that user's accounts, balances, positions, and orders.

You'll need: a Connect Trade platform (client_id + client_secret) and at least one provisioned user (user_id + user_secret) connected to a broker.

Step 1: Mint a JWT

Call the Connect Trade Unified API user token endpoint to get a short-lived JWT for your test user. Tokens are valid for 1 hour. Use {"scopes": ["read"]} for read-only or {"scopes": ["read", "trade"]} for trading.

curl -X POST https://api.connecttrade.com/auth/tokens/user \
  -H "client-id: YOUR_CLIENT_ID" \
  -H "client-secret: YOUR_CLIENT_SECRET" \
  -H "user-id: YOUR_USER_ID" \
  -H "user-secret: YOUR_USER_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"scopes": ["read", "trade"]}'

Step 2: Register the MCP server in your AI tool

MCP server endpoint: https://mcp.connecttrade.com/mcp (Streamable HTTP transport). Replace YOUR_JWT_HERE with the access_token from Step 1.

Claude Code

claude mcp add --transport http connecttrade \
  https://mcp.connecttrade.com/mcp \
  --header "Authorization: Bearer YOUR_JWT_HERE"

Cursor

Create or edit ~/.cursor/mcp.json:

{"mcpServers": {"connecttrade": {"url": "https://mcp.connecttrade.com/mcp", "headers": {"Authorization": "Bearer YOUR_JWT_HERE"}}}}

Windsurf

Edit ~/.codeium/windsurf/mcp_config.json:

{"mcpServers": {"connecttrade": {"serverUrl": "https://mcp.connecttrade.com/mcp", "headers": {"Authorization": "Bearer YOUR_JWT_HERE"}}}}

VS Code (GitHub Copilot — Agent Mode)

Add to .vscode/mcp.json:

{"servers": {"connecttrade": {"type": "http", "url": "https://mcp.connecttrade.com/mcp", "headers": {"Authorization": "Bearer YOUR_JWT_HERE"}}}}

Codex CLI

Add to ~/.codex/config.toml using the mcp-remote bridge:

[mcp_servers.connecttrade]
command = "npx"
args = ["-y", "mcp-remote", "https://mcp.connecttrade.com/mcp", "--header", "Authorization: Bearer YOUR_JWT_HERE"]

Step 3: Chat with your AI tool

Open your AI assistant and ask it anything: "What broker accounts do I have connected?", "Show me my current positions", "What's my buying power?", "Show me my last 10 filled orders", or "Buy 1 share of AAPL at market" (the assistant will ask you to confirm before submitting).

Note: The JWT is valid for 1 hour. When it expires, MCP calls will return 401 Unauthorized — re-run Step 1 and update the Authorization header in your MCP config.

Embedding the MCP Server in Your Existing AI Product

If you already have an LLM-powered product, you can extend it with Connect Trade broker tools by registering the MCP server as a tool source. Three things to build regardless of stack: a per-user JWT minting service in your backend, a way to pass the JWT to the MCP server on every call, and a confirmation flow for trades.

Per-user JWT minting

Platform credentials (client_id + client_secret) identify your platform — they're shared across every end-user. User credentials (user_id + user_secret) identify a specific person. Mint a separate JWT per user and cache it server-side, re-minting when within ~5 minutes of expiry.

Scope control

Mint tokens with only the scopes the user needs: {"scopes": ["read"]} for read-only (accounts, balances, positions, orders, transactions) or {"scopes": ["read", "trade"]} for full access. The MCP server enforces scopes per-tool. Connection-level permissions also apply — trading requires both a JWT with the trade scope and a broker connection created with trading enabled.

Trade confirmation

Trades go through a mandatory two-step confirmation flow: (1) LLM calls create_order() → MCP server returns a confirmation_id and a human-readable summary. (2) User confirms → LLM calls confirm_trade(confirmation_id) → order is submitted to the broker. Pending orders expire after 2 minutes if not confirmed. There is no way to bypass this.

Error handling

Three failure modes to handle: 401 Unauthorized — JWT expired, re-mint and retry. Rate limits — 60 requests/min per user across all tools, 30 requests/min on trade-related tools; returns a ToolError. Broker errors — pass-through errors from the underlying broker (insufficient buying power, market closed, invalid symbol).

Building Your Own Chatbot From Scratch

The sample client (ct-sample-mcp-client) is a complete starting point — a single-user FastAPI app with a chat UI demonstrating the full flow: browser chat UI → FastAPI backend → Claude API (tool calling) + Connect Trade MCP server (broker tools) + Connect Trade Unified API (JWT minting).

Run with Docker: docker build -t ct-sample-mcp-client . && docker run --env-file .env -p 3000:3000 ct-sample-mcp-client. Or without Docker: pip install -e . && python -m ct_sample_mcp_client. Then open http://localhost:3000.

Environment Variables

Required: ANTHROPIC_API_KEY (from console.anthropic.com), CT_MCP_URL (https://mcp.connecttrade.com/mcp), CT_API_URL (https://api.connecttrade.com), CT_CLIENT_ID, CT_CLIENT_SECRET, CT_USER_ID, CT_USER_SECRET. Optional: CT_SCOPES (defaults to read,trade).

Next Steps