Skip to main content
Glama

compile_project

Compile QuantConnect trading algorithms to validate code and prepare for backtesting or live deployment.

Instructions

Compile a project in QuantConnect.

Args: project_id: The ID of the project to compile.

Returns: A dictionary containing the compilation result with compile ID, state, and logs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler for the 'compile_project' tool. Authenticates, sends POST to QuantConnect 'compile/create' API with projectId, parses response to return compileId, state, logs, or error details.
    @mcp.tool()
    async def compile_project(project_id: int) -> Dict[str, Any]:
        """
        Compile a project in QuantConnect.
    
        Args:
            project_id: The ID of the project to compile.
    
        Returns:
            A dictionary containing the compilation result with compile ID, state, and logs.
        """
        auth = get_auth_instance()
        if auth is None:
            return {
                "status": "error",
                "error": "QuantConnect authentication not configured. Use configure_auth() first.",
            }
    
        try:
            # Prepare request data with project ID in JSON payload
            request_data = {"projectId": project_id}
            
            response = await auth.make_authenticated_request(
                endpoint="compile/create", method="POST", json=request_data
            )
    
            if response.status_code == 200:
                data = response.json()
                if data.get("success"):
                    return {
                        "status": "success",
                        "compile_id": data.get("compileId"),
                        "state": data.get("state"),
                        "project_id": data.get("projectId"),
                        "signature": data.get("signature"),
                        "signature_order": data.get("signatureOrder", []),
                        "logs": data.get("logs", []),
                        "message": "Project compilation started successfully.",
                    }
                else:
                    return {
                        "status": "error",
                        "error": "Project compilation failed.",
                        "details": data.get("errors", []),
                        "project_id": project_id,
                    }
            elif response.status_code == 401:
                return {
                    "status": "error",
                    "error": "Authentication failed. Check your credentials and ensure they haven't expired.",
                }
            else:
                return {
                    "status": "error",
                    "error": f"API request failed with status {response.status_code}",
                    "response_text": response.text[:500] if hasattr(response, "text") else "No response text",
                }
        except Exception as e:
            return {
                "status": "error",
                "error": f"An unexpected error occurred: {e}",
                "project_id": project_id,
            }
  • Docstring schema defining input 'project_id: int' and output Dict[str, Any] with compile_id, state, project_id, signature, logs, etc.
    """
    Compile a project in QuantConnect.
    
    Args:
        project_id: The ID of the project to compile.
    
    Returns:
        A dictionary containing the compilation result with compile ID, state, and logs.
    """
  • Registration function that defines and registers all project tools, including compile_project, using @mcp.tool() decorators when called.
    def register_project_tools(mcp: FastMCP):
        """Register project management tools with the MCP server."""
  • Explicit call to register_project_tools(mcp) during MCP server initialization in the main entry point.
    register_project_tools(mcp)
  • Helper tool that consumes the compile_id output from compile_project to fetch and analyze compilation results, detecting errors and warnings.
    @mcp.tool()
    async def read_compilation_result(project_id: int, compile_id: str) -> Dict[str, Any]:
        """
        Read the result of a compilation job in QuantConnect.
    
        Args:
            project_id: The ID of the project that was compiled.
            compile_id: The compile ID returned from compile_project.
    
        Returns:
            A dictionary containing the compilation result with state, logs, and errors.
        """
        auth = get_auth_instance()
        if auth is None:
            return {
                "status": "error",
                "error": "QuantConnect authentication not configured. Use configure_auth() first.",
            }
    
        try:
            # Prepare request data with project ID and compile ID in JSON payload
            request_data = {"projectId": project_id, "compileId": compile_id}
            
            response = await auth.make_authenticated_request(
                endpoint="compile/read", method="POST", json=request_data
            )
    
            if response.status_code == 200:
                data = response.json()
                if data.get("success"):
                    logs = data.get("logs", [])
                    errors = data.get("errors", [])
                    state = data.get("state")
                    
                    # Check for compilation warnings in logs that indicate issues
                    warnings = []
                    for log in logs:
                        if "Warning" in log:
                            warnings.append(log)
                    
                    # If there are warnings or explicit errors, treat as compilation failure
                    if warnings or errors:
                        return {
                            "status": "error",
                            "compile_id": data.get("compileId"),
                            "state": state,
                            "project_id": data.get("projectId"),
                            "signature": data.get("signature"),
                            "signature_order": data.get("signatureOrder", []),
                            "logs": logs,
                            "errors": errors,
                            "warnings": warnings,
                            "message": f"Compilation completed with {len(warnings)} warnings and {len(errors)} errors. Code issues must be fixed before proceeding.",
                            "error": f"Compilation failed: {len(warnings)} warnings, {len(errors)} errors found",
                        }
                    
                    return {
                        "status": "success",
                        "compile_id": data.get("compileId"),
                        "state": state,
                        "project_id": data.get("projectId"),
                        "signature": data.get("signature"),
                        "signature_order": data.get("signatureOrder", []),
                        "logs": logs,
                        "errors": errors,
                        "message": f"Compilation result retrieved successfully. State: {state}",
                    }
                else:
                    return {
                        "status": "error",
                        "error": "Failed to read compilation result.",
                        "details": data.get("errors", []),
                        "project_id": project_id,
                        "compile_id": compile_id,
                    }
            elif response.status_code == 401:
                return {
                    "status": "error",
                    "error": "Authentication failed. Check your credentials and ensure they haven't expired.",
                }
            else:
                return {
                    "status": "error",
                    "error": f"API request failed with status {response.status_code}",
                    "response_text": response.text[:500] if hasattr(response, "text") else "No response text",
                }
        except Exception as e:
            return {
                "status": "error",
                "error": f"An unexpected error occurred: {e}",
                "project_id": project_id,
                "compile_id": compile_id,
            }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Compile') and return format, but lacks details on permissions, rate limits, side effects (e.g., if compilation affects project state), or error handling, which are critical for a mutation tool in this context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement followed by Args and Returns sections, making it front-loaded and efficient. However, the 'Args' and 'Returns' labels are slightly redundant with structured fields, and it could be more concise by integrating this information seamlessly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation operation with no annotations), the description is minimally adequate but incomplete. It covers the basic action and return format, and the output schema helps, but it lacks behavioral context like side effects or prerequisites, which are important for safe usage in this sibling set.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for the single parameter 'project_id' by specifying it as 'The ID of the project to compile', which clarifies its role beyond the schema's basic type. With 0% schema description coverage and only one parameter, this adequately compensates, though it doesn't detail format or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Compile') and resource ('a project in QuantConnect'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'read_compilation_result' or 'create_backtest', which might involve compilation indirectly, so it misses full sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention prerequisites like project creation or how it relates to tools like 'read_compilation_result' for checking results, leaving the agent to infer usage from context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/taylorwilsdon/quantconnect-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server