Skip to main content
Glama

get_job_log

Retrieve execution logs for GitLab CI/CD jobs to monitor pipeline status and debug failures. Specify project and job IDs to access log content.

Instructions

取得 Job 的執行日誌

Args: project_id: 專案 ID 或路徑 job_id: Job ID last_lines: 只顯示最後 N 行(0 表示全部,預設 0)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
job_idYes
last_linesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The tool definition and implementation in the MCP server layer.
    @mcp.tool()
    def get_job_log(project_id: int | str, job_id: int, last_lines: int = 0) -> str:
        """取得 Job 的執行日誌
    
        Args:
            project_id: 專案 ID 或路徑
            job_id: Job ID
            last_lines: 只顯示最後 N 行(0 表示全部,預設 0)
        """
        try:
            client = get_client()
            log = client.get_job_log(project_id, job_id)
    
            if not log:
                return f"Job #{job_id} 沒有日誌"
    
            if last_lines > 0:
                log_lines = log.splitlines()
                if len(log_lines) > last_lines:
                    log = "\n".join(log_lines[-last_lines:])
                    return f"Job #{job_id} 日誌(最後 {last_lines} 行,共 {len(log_lines)} 行):\n\n{log}"
    
            # 截斷過長的日誌
            if len(log) > 50000:
                log = log[:50000] + "\n\n... (日誌已截斷,共 " + str(len(log)) + " 字元,請使用 last_lines 參數限制輸出)"
    
            return f"Job #{job_id} 日誌:\n\n{log}"
        except GitLabAPIError as e:
            return f"取得日誌失敗: {str(e)}"
    
    
    @mcp.tool()
    def retry_job(project_id: int | str, job_id: int) -> str:
        """重試單一 Job
    
        Args:
  • The underlying GitLab API call implementation for fetching job logs.
    def get_job_log(self, project_id: int | str, job_id: int) -> str:
        """GET /projects/:id/jobs/:job_id/trace — 回傳純文字日誌"""
        pid = self._resolve_project_id(project_id)
        return self._get_text(f"/projects/{pid}/jobs/{job_id}/trace")
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 for behavioral disclosure. It mentions that 'last_lines' displays only the last N lines (with 0 meaning all), which adds some context about output behavior. However, it lacks critical details: whether this is a read-only operation, authentication needs, rate limits, error conditions, or what the output schema contains. For a tool 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 appropriately sized and front-loaded: the purpose is stated first in a single sentence, followed by a structured 'Args:' section. There's no wasted text, and each part earns its place. Minor points are deducted because the 'Args:' formatting could be more integrated, but overall it's 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 no annotations, 0% schema coverage, but an output schema exists, the description is minimally adequate. It covers the tool's purpose and parameter semantics well, but lacks behavioral context (e.g., safety, errors) and doesn't leverage the output schema to explain return values. For a tool with three parameters and no annotations, it should do more to be complete.

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 adds meaningful semantics for all three parameters: 'project_id' as project ID or path, 'job_id' as Job ID, and 'last_lines' with a clear explanation (last N lines, 0 for all, default 0). This goes beyond the schema's basic titles, providing essential context for proper usage, though it doesn't cover all edge cases (e.g., format of project path).

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's purpose: '取得 Job 的執行日誌' (Get job execution logs). It specifies the verb ('取得' - get) and resource ('Job 的執行日誌' - job execution logs), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get_job' or 'retry_job', which prevents a perfect score.

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, context (e.g., after a job runs), or comparisons to siblings like 'get_job' (which might return job metadata) or tools for pipeline logs. Usage is implied only through parameter descriptions, not explicit guidelines.

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/snowild/gitlab-mcp'

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