MCP Server

Key Concepts

Introduction

The QuantConnect Model Context Protocol (MCP) server is a bridge that connects a Large Language Model (LLM) to the QuantConnect API. With this setup, you can prompt the LLM and have it interact with our API on your behalf. This server equips the LLM with tools to create projects, run backtests, deploy live algorithms, and more. Our MCP integration can supercharge your existing workflow on QuantConnect and can even unlock quant trading to non-programmers. Simply prompt the LLM in layperson language and let it do the heavy lifting for you.

To use the remote MCP server, your organization must have a paid agent node, such as an A1-1, A4-8, or A16-32 node. The free A-MICRO agent node can't connect to the remote MCP server.

Example Conversation

The following conversation with Copilot Chat in Local Platform demonstrates how the server equips an LLM with the ability to create trading strategies, backtest them, and deploy them to live trading:

Getting Started

To start using the QC MCP Server, see the Getting Started guide for one of the supported MCP clients.

Tools

The server provides the following tools:

Projects

  • create_project - Creates a project in the authorized organization with the given files. The files must include the algorithm entry point: main.py for Py projects, main.cs for C# projects.
  • list_projects - Lists the projects of the authorized organization, most recently modified first, 50 per page, optionally filtered by a text query. Use it to find the projectId the other tools require.
  • read_project - Reads a project by projectId: its name, language and files.
  • read_open_project - Read the current open project details and files.
  • update_project - Update project name or description. Provide at least one.
  • read_project_templates - Reads the best matching project templates based on a provided project description, returning the templates and their file contents.

Files

  • create_file - Create a new .py or .cs file and compile to check for syntax/compilation errors. Returns errors found. File content is limited to the organization plan file size limit; oversized writes are rejected, split the content into smaller files.
  • edit_file - Replace a unique snippet of an existing file, then compile to check for syntax/compilation errors. oldString must match the exact text to replace; to write an entire file use create_file. Returns errors found. File content is limited to the organization plan file size limit; oversized writes are rejected, split the content into smaller files.
  • read_file - Read full file content or a 1-based line range from .py/.cs files.
  • delete_file - Delete a file under the project root.
  • search_file_content - Search all project files case-insensitively and return matching lines. Results are paginated; use page to fetch subsequent pages.

Compile

  • create_compile - Compile and check for syntax and runtime errors. Run after code changes.

Backtests

  • create_backtest - Submits an algorithm for backtesting against historical data. The code is compiled, then the backtest is queued to run asynchronously on a worker. Returns a backtest ID acknowledging the job was accepted. When the run finishes, the system will deliver the completed results to you as a new message. Once you create a backtest, in most cases go to sleep and another system will awake you when the backtest is done. Do not poll to check backtest status.
  • read_backtest - Reads results and performance stats for previously-completed backtests — for example, ones the user references by ID from an earlier session, or ones whose results have already been delivered in this conversation and you need to re-examine or compare. Do NOT use this to check on a backtest you submitted earlier in this conversation but haven't yet received results for. Those arrive automatically as a new message when ready; calling this tool to fetch them early will return empty or stale data and only delays things.
  • read_backtest_orders - Read the orders of a backtest, paginated in placement order. Optionally filter by tag, symbol, type, id or date.
  • list_backtests - List recent backtests with name, date, and stats. Find specific IDs or review past runs.
  • update_backtest - Rename a backtest or update its note. Provide at least name or note. Defaults to latest.
  • delete_backtest - Permanently delete a backtest. Cannot be undone. Clean up old runs.
  • search_backtest_logs - Search backtest logs to monitor performance and behavior during backtesting.

Optimization

  • create_optimization - Submits an optimization job that runs multiple backtests across parameter combinations to find the best settings. The code is compiled, then the optimization is queued to run asynchronously on workers. Returns an optimization ID acknowledging the job was accepted. When the run finishes, the system will deliver the completed results to you as a new message. Once you create an optimization, in most cases go to sleep and another system will awake you when it is done. Do not poll to check optimization status.
  • read_optimization - Read the natural-language interpretation of a completed optimization. Do NOT use this to check on an optimization you submitted earlier in this conversation but haven't yet received results for. Those arrive automatically as a new message when ready; calling this tool to fetch them early will return empty or stale data and only delays things.
  • list_optimizations - List optimizations with name, status, date. Find IDs or review past runs.
  • delete_optimization - Permanently delete an optimization and results. Cannot be undone.

Live Trading

  • create_live_algorithm - Deploy live to paper trading using QuantConnect brokerage. Compiles first.
  • read_live_algorithm - Read the current live deployment status and results. Use this to monitor live trading performance.
  • read_live_holdings - Read the current holdings of the live deployment. Use this to inspect the open positions.
  • search_live_logs - Search logs from a live deployment. Defaults to the current deployment. Use this to monitor the performance and behavior.
  • stop_live_algorithm - Stop live trading without liquidating. Positions stay open.
  • liquidate_live_algorithm - Close positions at market prices and stop trading. Exit all trades.

Research

The following tools operate on a Jupyter notebook in the QuantConnect Cloud Research environment:

  • jupyter_create_cell - Insert a notebook cell in QuantConnect Research. Appends by default. The whole notebook (outputs excluded) is limited to the organization plan file size limit; oversized writes are rejected, keep cells small and move code into project files.
  • jupyter_read_cell - Read one notebook cell by zero-based index.
  • jupyter_update_cell - Replace cell source in QuantConnect Research. The whole notebook (outputs excluded) is limited to the organization plan file size limit; oversized writes are rejected, keep cells small and move code into project files.
  • jupyter_delete_cell - Delete a notebook cell at the specified zero-based index.
  • jupyter_execute_cell - Execute a cell in the QuantConnect Research environment and return outputs.
  • jupyter_create_notebook - Replace the QuantConnect Research notebook with raw JSON. The whole notebook (outputs excluded) is limited to the organization plan file size limit; oversized writes are rejected, keep cells small and move code into project files.
  • jupyter_read_notebook - Read the QuantConnect Research notebook as raw JSON.
  • jupyter_execute_notebook - Execute all QuantConnect Research notebook cells and return combined outputs.
  • jupyter_get_image - Fetch an image from a research URL and return it as a base64 string. To conserve tokens, only use when absolutely required.

Object Store

  • object_store_set - Writes content to a file, overwriting existing content.
  • object_store_pdf_to_markdown - Converts a PDF in the object store to markdown using the marker-pdf academic converter. Returns the markdown inline, or writes it to the object store when an outputPath is provided. The conversion has a time budget: pages left when it runs out are converted without OCR and a warning says so; request those pages as a shorter firstPage/lastPage range to give them a fresh budget.

Datasets and Environment

  • list_datasets - List the names of available QuantConnect datasets. Use get_dataset_details for full information about a specific dataset.
  • get_dataset_details - Get full details for a specific QuantConnect dataset, including description, history, reach, url, and code examples.
  • environment_library_support - List preinstalled libraries for the current QuantConnect environment.

Skills

  • list_skills - List the available skills, which can be loaded with load_skill.
  • load_skill - Load a skill by name. Use list_skills to discover the available skills.

Notifications

The following tools send messages from QuantConnect Cloud to you using the Live Trading Notifications system:

  • send_email_notification - Send an email notification.
  • send_sms_notification - Send an SMS notification.
  • send_telegram_notification - Send a Telegram notification.

Prompt Ideas

The following prompts are some ideas on how you can leverage the LLM’s knowledge to improve your workflow:

> Are there any new strategies out there being discussed online?


> How do you think we can improve the Sharpe ratio of this strategy?


> Review my live algorithms. Are there any you think we should stop trading?


> Add Option hedging to my strategy.

Workflow

The MCP server is available in QuantConnect Cloud and in some local IDEs.

Cloud Workflow

A cloud workflow might look like this:

  1. Open a project in Cloud Platform.
  2. In the IDE, open the Ask Mia panel.
  3. Issue prompts to investigate new trading ideas, create projects, run backtests, analyze backtest performance, and manage live algorithms.
  4. When you're finished, close the project.

Local Workflow

A local workflow might look like this:

  1. Open Local Platform, Cursor, or Devin Desktop.
  2. Open a project and connect to the MCP Server.
  3. For specific instructions on each IDE, open the MCP Server documentation, click a client application, and scroll down to the Getting Started section.

  4. In the chat window, issue prompts to investigate new trading ideas, create projects, run backtests, analyze backtest performance, and manage live algorithms.
  5. When you're finished, close the project.

Quotas

There are no quotas on the QuantConnect API, but the client you use may have quotas. For more information about the quotas, see the Quotas section for one of the supported MCP clients.

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 page. To check the status of your client and the LLM, see their status page.

Missing Agent Node

If your organization only has the free A-MICRO agent node, the MCP server returns the following error message:

The QuantConnect Remote MCP Server requires a dedicated Assistant node (A1-1, A4-8, or A16-32). Purchase nodes on the pricing page.

To resolve this issue, add a paid agent node to your organization.

Examples

The following examples demonstrate the MCP server.

Example 1: Hello World

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

> Read the open project.

The agent should call the read_open_project tool.

Example 2: Strategy Development and Deployment

This example uses Copilot Chat in Local Platform to brainstorm new strategy ideas, edit files, run backtests, and deploy 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: