QuantConnect MCP Server for Algorithmic LLM Trading
Deploy agentic LLM trading strategies with the QuantConnect MCP server to design, research, and implement algorithmic trading workflows.
npx -y @taylorwilsdon/quantconnect-mcpOverview
The QuantConnect MCP Server implements a Model Context Protocol (MCP) bridge for algorithmic trading workflows built on QuantConnect. It exposes an HTTP-based interface that lets agentic large language models (LLMs) and other automation frameworks request market context, run research and backtests, and submit algorithm jobs to QuantConnect Lean — all through a uniform MCP-compatible surface.
This server is useful when you want to combine LLM-driven decision-making with programmatic access to historical data, backtesting, and live execution. Instead of wiring multiple APIs and custom adapters, the MCP server centralizes context management and tools (market data queries, algorithm submission, order proxies) so agents can focus on strategy logic and natural language planning.
Features
- MCP-compliant HTTP server that exposes context and tool endpoints for agents
- Integrates with QuantConnect Lean for research, backtesting, and live/algo deployment
- Toolset for market data queries, account info, order placement, and backtest orchestration
- Configurable authentication and environment-driven configuration
- Runs locally (dev) or in containers for staging / production
- Designed to work with agent frameworks that consume MCP (LLM agents, search tools, workflow engines)
Installation / Configuration
Prerequisites:
- Python 3.9+ (or Docker)
- A QuantConnect account and API credentials
- (Optional) An OpenAI or other LLM API key if you plan to run LLMs that connect to the server
Clone and install locally:
Environment variables (example .env):
# .env
QUANTCONNECT_API_TOKEN=your_quantconnect_api_token
MCP_HOST=0.0.0.0
MCP_PORT=8080
LOG_LEVEL=info
# Optional: LLM provider keys if the server will mediate LLM requests
OPENAI_API_KEY=sk-...
Run the server:
# From the project root
Run in Docker:
Configuration table
| Variable | Purpose | Example |
|---|---|---|
| QUANTCONNECT_API_TOKEN | QuantConnect API token for submitting jobs / accessing data | abc123 |
| MCP_HOST | Host the server binds to | 0.0.0.0 |
| MCP_PORT | Port to expose MCP endpoints | 8080 |
| LOG_LEVEL | Server log verbosity | info, debug |
| OPENAI_API_KEY | Optional LLM API key (if used) | sk-… |
Available Tools / Resources
The MCP server exposes a collection of tools and resources that agents can call through MCP:
- Market Data Query: historical bars, ticks, and basic time series retrieval for supported symbols
- Backtest / Research Runner: submit a research/backtest job to QuantConnect Lean and fetch results/metrics
- Live Job Submitter: submit and manage live algorithm deployments to broker connectors supported by QuantConnect
- Orders & Accounts: read account balances, open orders, and place/cancel orders via QuantConnect APIs (subject to account permissions)
- Tool Registry: a discovery endpoint listing available tools, their capabilities, and how to invoke them
- Health & Metrics: basic healthchecks and operational metrics for orchestration and monitoring
Each tool appears as an MCP tool: a named capability with a JSON schema describing inputs/outputs so agents can plan calls programmatically.
Use Cases
Research-to-Backtest Workflow
- An LLM proposes a new factor or signal in natural language.
- The agent requests historical data via the Market Data Query tool and builds a feature set.
- The agent uses the Backtest Runner tool to submit a Lean backtest, then analyzes returned metrics to iterate.
Agentic Live Trading Execution
- A goal-directed agent monitors news and market signals.
- When a trade idea is decided, the agent synthesizes a trading plan and uses the Orders tool to submit an order via QuantConnect.
- The server keeps execution context and returns confirmations to the agent.
Automated Strategy Discovery
- An orchestration pipeline generates candidate algorithms using LLM-generated code snippets.
- Each candidate is sandboxed and backtested through the MCP server; top performers are promoted for further review.
Human-in-the-Loop Decisioning
- The server provides context summaries, backtest reports, and proposed orders to a dashboard.
- A human operator reviews and approves live deployments or order execution.
Example: calling the MCP server from a simple Python agent (conceptual)
=
# discover tools
=
# request historical bars (tool