Skip to main content
Glama

list_optimizations

Retrieve all optimization runs for a specific project to analyze performance improvements and parameter tuning results.

Instructions

List all optimizations for a project.

Args: project_id: ID of the project to list optimizations for

Returns: Dictionary containing list of optimizations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Implementation Reference

  • The async handler function decorated with @mcp.tool() that implements the list_optimizations tool. It lists optimizations for a given project_id by calling the QuantConnect API endpoint 'optimizations/list'.
    @mcp.tool()
    async def list_optimizations(
        project_id: int
    ) -> Dict[str, Any]:
        """
        List all optimizations for a project.
    
        Args:
            project_id: ID of the project to list optimizations for
    
        Returns:
            Dictionary containing list of optimizations
        """
        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 = {"projectId": project_id}
    
            # Make API request
            response = await auth.make_authenticated_request(
                endpoint="optimizations/list", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    optimizations = data.get("optimizations", [])
                    
                    return {
                        "status": "success",
                        "project_id": project_id,
                        "optimizations": optimizations,
                        "total_optimizations": len(optimizations),
                        "message": f"Successfully retrieved {len(optimizations)} optimizations for project {project_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "Failed to list optimizations",
                        "details": 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"Failed to list optimizations: {str(e)}",
                "project_id": project_id,
            }
  • The call to register_optimization_tools(mcp) in the main entry point, which registers the list_optimizations tool by defining it with @mcp.tool().
    register_optimization_tools(mcp)
  • The call to register_optimization_tools(mcp) in the server module, which registers the list_optimizations tool.
    register_optimization_tools(mcp)

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