Skip to main content
Glama
pholex

Qinglong MCP Server

by pholex

get_task_logs

Retrieve execution logs for specific scheduled tasks in Qinglong Panel to monitor performance and troubleshoot issues.

Instructions

获取青龙面板中指定任务的执行日志

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYes任务 ID

Implementation Reference

  • The handler for the 'get_task_logs' tool. It retrieves the specified task's cron details from the Qinglong API, then fetches and returns the execution logs if available.
    elif tool_name == "get_task_logs":
        task_id = arguments.get("task_id")
        try:
            url = f"{QINGLONG_URL}/open/crons/{task_id}"
            headers = {"Authorization": f"Bearer {token}"}
            resp = requests.get(url, headers=headers, timeout=10)
            result = resp.json()
        except Exception as e:
            response = {
                "jsonrpc": "2.0",
                "id": request["id"],
                "error": {"code": -32603, "message": f"请求失败: {str(e)}"}
            }
            print(json.dumps(response), flush=True)
            continue
        
        if result.get("code") == 200:
            cron = result["data"]
            log_path = cron.get("log_path", "")
            
            if log_path:
                try:
                    log_url = f"{QINGLONG_URL}/open/crons/{task_id}/log"
                    log_resp = requests.get(log_url, headers=headers, timeout=10)
                    log_result = log_resp.json()
                    
                    if log_result.get("code") == 200:
                        log_content = log_result["data"]
                        output = f"任务 {task_id} ({cron.get('name')}) 的执行日志:\n\n{log_content}"
                    else:
                        output = f"获取日志失败: {log_result}"
                except Exception as e:
                    output = f"读取日志失败: {str(e)}"
            else:
                output = f"任务 {task_id} ({cron.get('name')}) 暂无执行日志"
            
            response = {
                "jsonrpc": "2.0",
                "id": request["id"],
                "result": {"content": [{"type": "text", "text": output}]}
            }
        else:
            response = {
                "jsonrpc": "2.0",
                "id": request["id"],
                "error": {"code": -32603, "message": f"获取任务信息失败: {result}"}
            }
  • The input schema for the 'get_task_logs' tool, defining the required 'task_id' parameter as an integer.
    {
        "name": "get_task_logs",
        "description": "获取青龙面板中指定任务的执行日志",
        "inputSchema": {
            "type": "object",
            "properties": {
                "task_id": {"type": "integer", "description": "任务 ID"}
            },
            "required": ["task_id"]
        }
    },
  • server.py:77-156 (registration)
    The tool registration in the 'tools/list' method response, where 'get_task_logs' is listed among available tools with its schema.
    response = {
        "jsonrpc": "2.0",
        "id": request["id"],
        "result": {
            "tools": [
                {
                    "name": "list_qinglong_tasks",
                    "description": "查询青龙面板中的所有定时任务列表",
                    "inputSchema": {
                        "type": "object",
                        "properties": {}
                    }
                },
                {
                    "name": "run_task",
                    "description": "执行任务并等待完成,返回执行日志(最多等待30秒)",
                    "inputSchema": {
                        "type": "object",
                        "properties": {
                            "task_id": {"type": "integer", "description": "任务 ID"}
                        },
                        "required": ["task_id"]
                    }
                },
                {
                    "name": "run_task_async",
                    "description": "异步启动任务,不等待执行完成",
                    "inputSchema": {
                        "type": "object",
                        "properties": {
                            "task_id": {"type": "integer", "description": "任务 ID"}
                        },
                        "required": ["task_id"]
                    }
                },
                {
                    "name": "get_task_logs",
                    "description": "获取青龙面板中指定任务的执行日志",
                    "inputSchema": {
                        "type": "object",
                        "properties": {
                            "task_id": {"type": "integer", "description": "任务 ID"}
                        },
                        "required": ["task_id"]
                    }
                },
                {
                    "name": "get_task_status",
                    "description": "获取青龙面板中指定任务的执行状态",
                    "inputSchema": {
                        "type": "object",
                        "properties": {
                            "task_id": {"type": "integer", "description": "任务 ID"}
                        },
                        "required": ["task_id"]
                    }
                },
                {
                    "name": "list_subscriptions",
                    "description": "查询青龙面板中的所有订阅列表",
                    "inputSchema": {
                        "type": "object",
                        "properties": {}
                    }
                },
                {
                    "name": "run_subscription",
                    "description": "运行指定的订阅",
                    "inputSchema": {
                        "type": "object",
                        "properties": {
                            "subscription_id": {"type": "integer", "description": "订阅 ID"}
                        },
                        "required": ["subscription_id"]
                    }
                }
            ]
        }
    }
    print(json.dumps(response), flush=True)
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 it 'gets' logs, implying a read-only operation, but doesn't specify if it retrieves all logs, recent logs, or paginated results. It also doesn't mention authentication needs, rate limits, or error conditions (e.g., invalid task ID). The description adds minimal context beyond the basic action.

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 a single, efficient sentence in Chinese that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by specifying the system (Qinglong panel), target (specified tasks), and what is retrieved (execution logs).

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

Completeness2/5

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

Given the complexity (a read operation with no output schema and no annotations), the description is incomplete. It doesn't explain what the logs contain (e.g., timestamps, output, errors), how they are returned (e.g., text, JSON), or if there are limitations (e.g., log size, retention). For a tool that likely returns detailed data, more context is needed to help the agent use it effectively.

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?

The input schema has 100% description coverage, with 'task_id' documented as '任务 ID' (task ID). The description adds no additional meaning beyond this, such as format examples (e.g., numeric ID from 'list_qinglong_tasks') or constraints (e.g., must be an existing task). With high schema coverage, the baseline is 3, as the schema does the heavy lifting without description enhancement.

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 ('获取' meaning 'get') and resource ('青龙面板中指定任务的执行日志' meaning 'execution logs of specified tasks in Qinglong panel'). It distinguishes from siblings like 'get_task_status' (status vs logs) and 'list_qinglong_tasks' (list tasks vs get logs). However, it doesn't explicitly mention it's for historical logs versus real-time monitoring, which could further differentiate from 'run_task' tools.

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 a valid task ID from 'list_qinglong_tasks'), exclusions (e.g., not for real-time logs during execution), or comparisons to siblings like 'get_task_status' for status information instead of logs. Usage is implied by the name 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/pholex/qinglong-mcp-server'

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