---
title: "Claude Code"
description: "Claude Code is command line utility that can connect Claude to the QuantConnect MCP Server."
canonical: https://www.quantconnect.com/docs/v2/ai-assistance/mcp-server/claude-code
markdown: https://www.quantconnect.com/docs/v2/ai-assistance/mcp-server/claude-code.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/09%20AI%20Assistance/08%20MCP%20Server/16%20Claude%20Code
modified: 2026-10-21
index: https://www.quantconnect.com/llms.txt
---

# Claude Code

[Documentation](https://www.quantconnect.com/docs/v2.md) > [AI Assistance](https://www.quantconnect.com/docs/v2/ai-assistance.md) > [MCP Server](https://www.quantconnect.com/docs/v2/ai-assistance/mcp-server.md) > Claude Code

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

Claude Code is an AI coding assistant that can connect Claude to the QuantConnect MCP Server. This page explains how to set up and use the server with the Claude Code and the [Claude Code extension](https://marketplace.visualstudio.com/items?itemName=anthropic.claude-code) in [Local Platform](https://www.quantconnect.com/docs/v2/local-platform.md).

## Getting Started

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

1. Open Claude Code.
2. Click the menu icon in the top-left corner and then click **File > Settings**.
3. On the Settings page, click **Connectors**.
   ![Claude Code Settings page with an arrow highlighting the Connectors menu item](https://cdn.quantconnect.com/i/tu/claude-code-settings-page-add-connector.png)
4. On the Connectors page, click **Add**.
   ![Claude Code Connectors page with an arrow highlighting the Add button in the top-right corner](https://cdn.quantconnect.com/i/tu/claude-code-add-connector.png)
5. On the Add Custom Connector page, enter a name for the connector, enter the MCP server URL (https://www.quantconnect.com/api/v2/mcp), and then click **Add**.
   ![Claude Code Add Custom Connectors form with the QC MCP Server details filled in](https://cdn.quantconnect.com/i/tu/claude-code-add-custom-connector-form.png)
6. On the confirmation page, click **Add**.
   ![Claude Code Add Custom Connectors confirmation form with an arrow to the Add button](https://cdn.quantconnect.com/i/tu/claude-code-add-custom-connector-form-confirmation.png)
7. On the Connectors page, click **Connect**.
   ![Claude Code Add Custom Connectors confirmation form with an arrow to the Connect button](https://cdn.quantconnect.com/i/tu/claude-code-connect-to-qc-mcp-server.png)
   It opens a page in your default browser. If you sign into your QuantConnect account with a different browser, update your computer's default browser application and then repeat these steps.
8. In the browser page that opens, click **Continue connecting**.
   ![Claude Code page that says Finishing connecting a connector](https://cdn.quantconnect.com/i/tu/claude-code-continue-connecting.png)
9. In the Authorize MCP Server form, select the organization you want to connect to and then click **Authorize**.
   ![QuantConnect form to Authorize MCP Server connection](https://cdn.quantconnect.com/i/tu/authorize-mcp-server.png)

Claude Code should now show all the tools available through the QuantConnect MCP Server.

![QuantConnect MCP Server tools listed in Claude Code Connectors](https://cdn.quantconnect.com/i/tu/claude-code-qc-mcp-server-tools.png)

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

1. In Local Platform, install the [Claude Code](https://marketplace.visualstudio.com/items?itemName=anthropic.claude-code) extension.
2. [Create a new project](https://www.quantconnect.com/docs/v2/local-platform/projects/getting-started.md#03-Create-Projects) or [open an existing one](https://www.quantconnect.com/docs/v2/local-platform/projects/getting-started.md#04-Open-Projects).
3. In the top navigation bar, click the ![Claude Code icon](https://cdn.quantconnect.com/i/tu/claude-code-icon.png) **Claude Code** icon.
4. In the Claude Code panel, enter **/mcp**.
   It should show the the QuantConnect MCP Server is connected.
   ![Showing the QC MCP server is connected](https://cdn.quantconnect.com/i/tu/claude-code-extension-mcp-list.png)

## 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](https://www.anthropic.com/engineering/claude-code-best-practices) 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?](https://support.claude.com/en/articles/11647753-understanding-usage-and-length-limits) on the Anthropic website.

## Troubleshooting

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

### 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](https://status.quantconnect.com/) page. To check the status of Claude Code and Claude AI, see the [Anthropic Status](https://status.anthropic.com/) 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 the Claude Code chat:

> > Read the open project.

The agent should call the `read_open_project` 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.

[Video](https://player.vimeo.com/video/1111428140)

### Example 3: Hybrid Workflow with Local Platform

This example uses Claude Code in [Local Platform](https://www.quantconnect.com/docs/v2/local-platform.md) to edit the project files, deploy backtests, and deploy the algorithm to paper trading.

[Video](https://player.vimeo.com/video/1111417978)
