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.

Example Conversation

The following example conversation with Claude Desktop 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 following table describes the tools the server provides:

ToolCloudLocal
Account
read_account
Read the organization account status.
green check
Projects
create_project
Create a new project in your default organization.
green checkgreen check
read_project
List details of a project or recent projects.
green checkgreen check
list_projects
List the details of all projects.
green checkgreen check
update_project
Update a project's name or description.
green checkgreen check
delete_project
Delete a project.
green checkgreen check
Project Collaboration
create_project_collaborator
Add a collaborator to a project.
green checkgreen check
read_project_collaborators
List all collaborators on a project.
green checkgreen check
update_project_collaborator
Update collaborator information for a project.
green checkgreen check
delete_project_collaborator
Remove a collaborator from a project.
green checkgreen check
lock_project_with_collaborators
Lock a project so you can edit it.
green check
Project Nodes
read_project_nodes
Read the available and selected nodes of a project.
green checkgreen check
update_project_nodes
Update the active state of the given nodes to true.
green check
Compile
create_compile
Asynchronously create a compile job request for a project.
green checkgreen check
read_compile
Read a compile packet job result.
green check
Files
create_file
Add a file to a given project.
green checkgreen check
read_file
Read a file from a project or all files if no name is provided.
green checkgreen check
update_file
Update the name or content of a file.
green check
update_file_name
Update the name of a file.
green check
update_file_contents
Update the contents of a file.
green check
patch_file
Apply a unified diff patch to a file.
green check
delete_file
Delete a file in a project.
green checkgreen check
Backtests
create_backtest
Create a new backtest request and get the backtest ID.
green checkgreen check
read_backtest
Read the results of a backtest.
green checkgreen check
list_backtests
List all backtests for the project.
green checkgreen check
read_backtest_chart
Read a chart from a backtest.
green check
read_backtest_orders
Read the orders of a backtest.
green check
read_backtest_insights
Read the insights of a backtest.
green check
update_backtest
Update the name or note of a backtest.
green checkgreen check
delete_backtest
Delete a backtest from a project.
green checkgreen check
Optimization
estimate_optimization_time
Estimate execution time of an optimization.
green check
create_optimization
Create an optimization with parameters.
green checkgreen check
read_optimization
Read an optimization.
green checkgreen check
list_optimizations
List all optimizations for a project.
green checkgreen check
update_optimization
Update the name of an optimization.
green check
abort_optimization
Abort an optimization.
green checkgreen check
delete_optimization
Delete an optimization.
green checkgreen check
Live Trading
authorize_connection
Authorize an external live connection.
green check
create_live_algorithm
Create a live algorithm.
green checkgreen check
read_live_algorithm
Read details of a live algorithm.
green checkgreen check
list_live_algorithms
List all active and past live deployments.
green check
read_live_chart
Read a chart from a live algorithm.
green check
read_live_logs
Get logs of a live algorithm.
green checkgreen check
read_live_portfolio
Read the live portfolio state.
green checkgreen check
read_live_orders
Read orders from a live algorithm.
green checkgreen check
read_live_insights
Read insights from a live algorithm.
green check
stop_live_algorithm
Stop a live algorithm.
green checkgreen check
liquidate_live_algorithm
Liquidate and stop a live algorithm.
green checkgreen check
Live Commands
create_live_command
Send a command to a live algorithm.
green check
broadcast_live_command
Broadcast a live command to all live algorithms.
green check
Object Store
upload_object
Upload files to the Object Store.
green check
read_object_properties
Read Object Store properties for an organization/key.
green check
read_object_store_file_job_id
Create a job to download files and return job ID.
green check
read_object_store_file_download_url
Get download URL for Object Store files.
green check
list_object_store_files
List Object Store files under a directory.
green check
delete_object
Delete an Object Store file.
green check
Lean Versions
read_lean_versions
Return a list of LEAN versions.
green check
MCP Server Versions
read_mcp_server_version
Return the current MCP Server version.
green check
read_latest_mcp_server_version
Return the latest released MCP Server version.
green check
AI
check_initialization_errors
Run a short backtest to detect initialization errors.
green check
complete_code
Show code completion for specific text.
green check
enhance_error_message
Show enhanced error context and suggestions.
green check
update_code_to_pep8
Update Python code to follow PEP8 style.
green check
check_syntax
Check syntax of code.
green check
search_quantconnect
Search for QuantConnect content.
green check

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 integration supports multiple workflows, ranging from exclusively using the LLM for everything all the way to just prompting the LLM to supplement your activity on our other platforms. The following sections contain several examples of common workflows.

LLM-Focused Workflow

A cloud LLM-focused 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.

A local LLM-focused workflow might look like this:

  1. Open Docker Desktop and your MCP client application.
  2. Issue prompts to investigate new trading ideas, create projects, run backtests, analyze backtest performance, and manage live algorithms.
  3. When you're finished, shut down the client and Docker Desktop.

The advantage of an LLM-focused workflow is it doesn't require you to be an expert in programming or financial markets. It leverages the knowledge of the pre-trained LLM to fill your knowledge gaps. The downside to this workflow is LLMs aren't perfect, so you may need to intervene if it starts hallucinating or if it struggles to implement sophisticated trading logic.

Multi-Platform Workflow

A multi-platform workflow might look like this:

  1. Open Cloud Platform, Docker Desktop, and your local MCP client application.
  2. Create a new project in the Algorithm Lab and run a backtest.
  3. Prompt the client application to add a trailing stop order to the project.
  4. Deploy an optimization in the Algorithm Lab.
  5. Prompt the client application to interpret the optimization results and offer suggestions for improvement.
  6. When you’re finished, close the Cloud Platform, client application, and Docker Desktop.

The advantage of this workflow is you can continue using the Cloud Platform, Local Platform, and CLI as you usually would while leveraging the power of LLMs to perform tedious tasks and brainstorm solutions.

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.

No Local 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 check the client to ensure it’s connected.

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

  1. Shut down the client application.
  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 client application.

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 the Getting Started guide for one of the supported MCP clients.

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.

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:

> Create a QuantConnect project.

The client should call the create_project tool.

Example 2: Search QuantConnect, Create Projects, and Fix Errors

The following video shows this conversation with Claude Desktop in real-time:

Example 3: Brainstorm Ideas, Add Project Descriptions, and Add Collaborators

The following video shows this conversation with Claude Desktop in real-time:

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: