Skip to main content
Glama

abort_optimization

Stop a running optimization process by providing its ID to halt execution and free resources.

Instructions

Abort an optimization that is currently running.

Args: optimization_id: ID of the optimization to abort

Returns: Dictionary containing abort result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
optimization_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler implementation for the 'abort_optimization' tool. This async function takes an optimization_id, authenticates with QuantConnect, and sends a POST request to the 'optimizations/abort' endpoint to abort the running optimization, returning success or error status.
    @mcp.tool()
    async def abort_optimization(
        optimization_id: str
    ) -> Dict[str, Any]:
        """
        Abort an optimization that is currently running.
    
        Args:
            optimization_id: ID of the optimization to abort
    
        Returns:
            Dictionary containing abort result
        """
        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/abort", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    return {
                        "status": "success",
                        "optimization_id": optimization_id,
                        "message": f"Successfully aborted optimization {optimization_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "Optimization abort failed",
                        "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 abort optimization: {str(e)}",
                "optimization_id": optimization_id,
            }
  • The call to register_optimization_tools(mcp) which defines and registers the abort_optimization tool among other optimization tools.
    register_optimization_tools(mcp)
  • The call to register_optimization_tools(mcp) in the main entry point, which registers the abort_optimization tool.
    register_optimization_tools(mcp)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('abort') but lacks details on permissions required, whether the abort is reversible, side effects (e.g., if partial results are saved), rate limits, or error conditions. This is a significant gap for a mutation tool with zero annotation coverage.

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 appropriately sized and front-loaded: the first sentence states the core purpose, followed by structured sections for args and returns. However, the 'Returns' section is vague ('Dictionary containing abort result') and could be more specific, slightly reducing efficiency.

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 with no annotations) and schema richness (0% coverage, but with an output schema), the description is partially complete. It covers the basic action and parameter but lacks behavioral context and detailed return info. The output schema exists, so the description needn't fully explain returns, but overall it's adequate with clear gaps.

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 documents the single parameter ('optimization_id') and its purpose ('ID of the optimization to abort'), adding meaning beyond the bare schema. However, it doesn't specify the ID format (e.g., numeric string, UUID) or where to obtain it, 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 verb ('abort') and resource ('an optimization that is currently running'), making the purpose specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'delete_optimization' or 'stop_live_algorithm', which might handle related but different operations.

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., the optimization must be running), exclusions (e.g., cannot abort completed optimizations), or compare to siblings like 'delete_optimization' or 'stop_live_algorithm', leaving the agent to infer usage context.

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