Skip to main content
Glama

read_optimization

Retrieve optimization details and results by ID to analyze trading strategy performance in the QuantConnect platform.

Instructions

Read an optimization by its ID.

Args: optimization_id: ID of the optimization to read

Returns: Dictionary containing optimization details and results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
optimization_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'read_optimization' tool. It authenticates with QuantConnect, makes a POST request to the /optimizations/read endpoint, and returns the optimization details or error information.
    @mcp.tool()
    async def read_optimization(
        optimization_id: str
    ) -> Dict[str, Any]:
        """
        Read an optimization by its ID.
    
        Args:
            optimization_id: ID of the optimization to read
    
        Returns:
            Dictionary containing optimization details and results
        """
        auth = get_auth_instance()
        if auth is None:
            return {
                "status": "error",
                "error": "QuantConnect authentication not configured. Use configure_auth() first.",
            }
    
        try:
            # Prepare request data
            request_data = {"optimizationId": optimization_id}
    
            # Make API request
            response = await auth.make_authenticated_request(
                endpoint="optimizations/read", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    optimization = data.get("optimization", {})
                    
                    return {
                        "status": "success",
                        "optimization_id": optimization_id,
                        "optimization": optimization,
                        "message": f"Successfully read optimization {optimization_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "Failed to read optimization",
                        "details": errors,
                        "optimization_id": optimization_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"Failed to read optimization: {str(e)}",
                "optimization_id": optimization_id,
            }
  • Call to register_optimization_tools(mcp) which defines and registers the read_optimization tool among others.
    register_optimization_tools(mcp)
  • Call to register_optimization_tools(mcp) which defines and registers the read_optimization tool among others.
    register_optimization_tools(mcp)
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a read operation, implying it's non-destructive, but doesn't cover authentication requirements, rate limits, error conditions, or what happens if the ID doesn't exist. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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

Conciseness5/5

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

The description is extremely concise and well-structured: a clear purpose statement followed by brief 'Args' and 'Returns' sections. Every sentence earns its place with no redundant information. It's front-loaded with the main action and efficiently communicates essential details.

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 low complexity (single parameter) and the presence of an output schema (which handles return values), the description is reasonably complete for basic usage. However, with no annotations and 0% schema description coverage, it lacks important contextual details like authentication needs, error handling, and relationship to sibling tools, making it minimally adequate.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining that 'optimization_id' is 'ID of the optimization to read', which clarifies the parameter's purpose beyond the schema's title 'Optimization Id'. However, it doesn't provide format details (e.g., UUID, numeric), validation rules, or examples, leaving some ambiguity.

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 action ('Read') and target resource ('an optimization by its ID'), making the purpose immediately understandable. It distinguishes from siblings like 'list_optimizations' (which returns multiple) and 'create_optimization' (which creates new). However, it doesn't specify what 'optimization' means in this context (e.g., financial algorithm optimization), leaving some ambiguity.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing optimization ID), compare it to 'list_optimizations' for browsing, or indicate when 'read_optimization' is appropriate versus other read operations like 'read_backtest'. Usage is implied but not explicitly stated.

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