MCP Server

Claude Code

Introduction

Claude Code is command line utility that can connect Claude to the QuantConnect MCP Server. Claude Code runs in a terminal or in development environments like Visual Studio Code.

Getting Started

To connect Claude Code to the QC MCP Server, follow these steps:

  1. Install and open Docker Desktop.
  2. Install Claude Code.
  3. In a terminal, pull the QC MCP Server from Docker Hub.
  4. $ docker pull quantconnect/mcp-server

    If you have an ARM chip, add the --platform linux/arm64 option.

  5. Save the following configuration file on your computer:
    {
      "mcpServers": {
        "quantconnect": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e", "QUANTCONNECT_USER_ID",
            "-e", "QUANTCONNECT_API_TOKEN",
            "-e", "AGENT_NAME",
            "--platform", "<your_platform>",
            "quantconnect/mcp-server"
          ],
          "env": {
            "QUANTCONNECT_USER_ID": "<your_user_id>",
            "QUANTCONNECT_API_TOKEN": "<your_api_token>",
            "AGENT_NAME": "MCP Server"
          }
        }
      }
    }

    To get your user Id and API token, see Request API Token.

    Our MCP server is multi-platform capable. The options are linux/amd64 for Intel/AMD chips and linux/arm64 for ARM chips (for example, Apple's M-series chips).

    If you simultaneously run multiple agents, set a unique value for the AGENT_NAME environment variable for each agent to keep record of the request source.

  6. In a terminal, navigate to the directory you want Claude to operate in and then run claude --mcp-config <path_to_your_config_file>.
  7. $ claude --mcp-config C:/Users/derek/quantconnect_mcp_config.json

    You can even use the terminal in Visual Studio Code. To open it, click View > Terminal from the main menu.

To keep the Docker image up-to-date, in a terminal, pull the latest MCP server from Docker Hub.

$ docker pull quantconnect/mcp-server

If you have an ARM chip, add the --platform linux/arm64 option.

Tailor Behavior

The CLAUDE.md file is a special file that tailors how Claude behaves during your conversations. When you run claude to start a new conversation, Claude automatically pulls the CLAUDE.md file into context. To find the file, it checks your home directory (~ / .claude /) and it checks the current, parent, and child directories of where you run claude. The following CLAUDE.md file provides an example of how you might tailor Claude to aid in your QuantConnect workflow. Feel free to edit it to fit your needs. There is no strict format for the file.

# CLAUDE.md

## Purpose
This file defines the conventions and expectations for how Claude should interact with QuantConnect projects.

---

## Development Environment
- Code should be **Python-first**, but C# examples may be used for reference if necessary.
- The project Id is in the config file, under `cloud-id`. Don't call the `list_backtests` tool unless it's absolutely needed.
- External dependencies must be avoided unless they are supported in QuantConnect’s cloud environment. When in doubt, suggest native LEAN methods.
- When drafting code, prefer modular design. Place custom indicators in an `indicators/` directory.
- Prioritize classic QC algorithm design over the algorithm framework unless explicitly requested.
- When creating indicator objects (such as RSI, SMA, etc.), never overwrite the indicator method names (e.g., do not assign to `self.rsi`, `self.sma`, etc.). Instead, use a different variable name, preferably with a leading underscore for non-public instance variables (e.g., `self._rsi = self.rsi(self._symbol, 14)`). This prevents conflicts with the built-in indicator methods and ensures code reliability.
- After adding or editing code, call the compile tool (`create_compile` and `read_compile`) in the QuantConnect MCP server to get the syntax errors and then FIX ALL COMPILE WARNINGS.


---

## Data Handling
- Use QuantConnect’s **built-in dataset APIs** (Equity, Futures, Options, Crypto, FX).  
- For alternative datasets, reference [QuantConnect’s Data Library](https://www.quantconnect.com/datasets/) and link to documentation rather than suggesting unsupported APIs.

---

## Research Standards
- Backtest code should include:
  - A clear `initialize()` with securities, resolution, and cash set explicitly.
  - Example parameters (start date, end date, cash) that are realistic for production-scale testing.
  - At least one comment section explaining the strategy’s core logic.
- When generating new strategies, provide a **one-paragraph explanation** of the trading idea in plain English before showing code.
- Prefer **transparent, explainable strategies**. Avoid “black-box” style outputs.

---

## Style Guidelines
- Code must follow **PEP8** where possible.
- Use **docstrings** on all public classes and functions.
- Responses should be in **Markdown**, with code blocks fenced by triple backticks and the language identifier.

---

## Risk Management
- Always emphasize risk controls in strategy outputs:
  - Max position sizing rules.
  - Stop-loss or drawdown limits.
  - Portfolio exposure constraints.
- Always use the `live_mode` flag and log the live mode in `initialize`.

---

## Security & Compliance
- Do not reference or fabricate API keys, credentials, or client secrets.
- Avoid suggesting integrations with unsupported brokers.
- If a user requests something outside QuantConnect’s compliance boundaries (e.g., high-frequency order spoofing, or prohibited datasets), politely decline.

---

## Tone & Communication
- Keep responses professional, concise, and explanatory.
- Prioritize **clarity over cleverness**.  
- Always explain why you made a design choice if multiple options exist.

For more information about CLAUDE.md files, see Claude Code: Best practices for agentic coding on the Anthropic website.

Quotas

There are no quotas on the QuantConnect API, but the Claude has some. To view the quotas, see Does Claude have any message limits? on the Anthropic website.

Troubleshooting

The following sections explain some issues you may encounter and how to resolve them.

No Tools Available

When you open your MCP client, it can take up to 30 seconds for the MCP server to start up and for the client to connect to it. Before you start entering prompts, check Docker Desktop to ensure the container is running and run /mcp in Claude Code to ensure the QuantConnect tools are available.

If the client can’t discover the tools after 30 seconds, follow these steps:

  1. In the terminal, press Ctrl+C twice to exit Claude Code.
  2. If the server doesn’t automatically shut down in Docker Desktop, click the trash icon to shut it down.
  3. Docker Desktop container page showing the MCP server is still running.
  4. Restart the Claude Code.

Connection Error Code -32000

The docker run ... command in the configuration file also accepts a --name option, which sets the name of the Docker container when the MCP Server starts running. If your computer tries to start up two MCP Server containers with the same name, this -32000 error occurs. To avoid the error, remove the --name option and its value from the configuration file. For an example of a working configuration file, see Getting Started.

Service Outages

The MCP server relies on the QuantConnect API and the client application. To check the status of the QuantConnect API, see our Status page. To check the status of Claude Code and Claude AI, see the Anthropic Status page.

Examples

The following examples demonstrate the MCP server with Claude Code.

Example 1: Hello World

To test the server and client are working and connected, enter the following prompt into Claude Code:

> Read my QuantConnect account.

Claude should call the read_account tool.

Example 2: LLM-Focused Workflow from Powershell

This example uses Claude Code in a terminal window to create a new project, edit files, run backtests, and interpret backtest results.

Example 3: Hybrid Workflow with Local Platform

This example uses Claude Code in Local Platform to edit the project files, deploy backtests, and deploy the algorithm to paper trading.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: