Skip to main content
Glama

read_live_logs

Monitor live trading algorithm logs in real-time to track performance and debug issues during execution.

Instructions

Read logs from a live algorithm.

Args: project_id: Project ID of the live running algorithm algorithm_id: Deploy ID (Algorithm ID) of the live running algorithm start_line: Start line of logs to read end_line: End line of logs to read (difference must be < 250) format: Format of log results (default: "json")

Returns: Dictionary containing live algorithm logs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
algorithm_idYes
start_lineYes
end_lineYes
formatNojson

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements the 'read_live_logs' tool. It handles authentication, input validation for log line ranges, constructs the API request to QuantConnect's live/logs/read endpoint, and parses the response to return log data or error information.
    @mcp.tool()
    async def read_live_logs(
        project_id: int,
        algorithm_id: str,
        start_line: int,
        end_line: int,
        format: str = "json",
    ) -> Dict[str, Any]:
        """
        Read logs from a live algorithm.
    
        Args:
            project_id: Project ID of the live running algorithm
            algorithm_id: Deploy ID (Algorithm ID) of the live running algorithm
            start_line: Start line of logs to read
            end_line: End line of logs to read (difference must be < 250)
            format: Format of log results (default: "json")
    
        Returns:
            Dictionary containing live algorithm logs
        """
        auth = get_auth_instance()
        if auth is None:
            return {
                "status": "error",
                "error": "QuantConnect authentication not configured. Use configure_auth() first.",
            }
    
        # Validate line range
        if end_line <= start_line:
            return {
                "status": "error",
                "error": "end_line must be greater than start_line",
            }
    
        if end_line - start_line >= 250:
            return {
                "status": "error",
                "error": "Line range too large: difference between start_line and end_line must be less than 250",
            }
    
        if start_line < 0 or end_line < 0:
            return {
                "status": "error",
                "error": "start_line and end_line must be non-negative",
            }
    
        try:
            # Prepare request data
            request_data = {
                "format": format,
                "projectId": project_id,
                "algorithmId": algorithm_id,
                "startLine": start_line,
                "endLine": end_line,
            }
    
            # Make API request
            response = await auth.make_authenticated_request(
                endpoint="live/logs/read", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    logs = data.get("logs", [])
                    length = data.get("length", 0)
                    deployment_offset = data.get("deploymentOffset", 0)
                    
                    return {
                        "status": "success",
                        "project_id": project_id,
                        "algorithm_id": algorithm_id,
                        "start_line": start_line,
                        "end_line": end_line,
                        "logs": logs,
                        "length": length,
                        "deployment_offset": deployment_offset,
                        "format": format,
                        "message": f"Successfully retrieved {len(logs)} log lines from live algorithm {algorithm_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "Failed to read live algorithm logs",
                        "details": errors,
                        "project_id": project_id,
                        "algorithm_id": algorithm_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 live algorithm logs: {str(e)}",
                "project_id": project_id,
                "algorithm_id": algorithm_id,
                "start_line": start_line,
                "end_line": end_line,
            }
  • Call to register_live_tools(mcp) which registers all live trading tools, including 'read_live_logs', with the MCP server instance.
    register_live_tools(mcp)
  • Call to register_live_tools(mcp) in the server initialization, registering the live tools including 'read_live_logs'.
    register_live_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 full burden. It mentions the constraint 'difference must be < 250' for line range, which is useful behavioral context. However, it lacks other critical details like permissions needed, rate limits, whether logs are real-time or historical, or error conditions. For a read operation with no annotations, this is insufficient.

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 clear sections (Args, Returns) and uses bullet-like formatting. It's front-loaded with the core purpose. Every sentence adds value, though the 'Returns' section is somewhat redundant given the output schema exists. Slightly verbose but efficient.

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 5 parameters with 0% schema coverage and no annotations, the description does a fair job explaining parameters and basic behavior. However, it lacks details on authentication, error handling, or log format specifics. The output schema exists, so return values don't need explanation. For a tool with moderate complexity, it's minimally adequate but has gaps.

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?

Schema description coverage is 0%, so the description must compensate. It clearly explains all 5 parameters: project_id, algorithm_id, start_line, end_line, and format, including the constraint on line difference and default for format. This adds significant meaning beyond the bare schema. It doesn't fully explain format options or line numbering specifics, but covers most semantics well.

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 tool reads logs from a live algorithm, specifying the resource (live algorithm logs) and action (read). It distinguishes from siblings like read_live_algorithm or read_live_orders by focusing specifically on logs. However, it doesn't explicitly contrast with other log-related tools (none exist in siblings), so it's not a perfect 5.

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. The description doesn't mention prerequisites (e.g., algorithm must be running), exclusions, or comparisons to other tools. It's a basic functional statement without contextual usage advice.

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