Skip to main content
Glama
owayo

https://github.com/owayo/gitlab-mcp-server

get_pipeline_failed_jobs

Retrieve console output for failed jobs in GitLab pipelines to identify and resolve build issues.

Instructions

GitLabパイプラインで失敗したジョブのコンソール出力を取得

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:46-60 (handler)
    The handler function implementing the 'get_pipeline_failed_jobs' MCP tool. Decorated with @mcp.tool() for registration. Retrieves current MR ID, fetches failed jobs output using helper, and formats response.
    @mcp.tool()
    def get_pipeline_failed_jobs() -> str:
        """GitLabパイプラインで失敗したジョブのコンソール出力を取得"""
        mr_id = get_current_mr_id()
    
        failed_jobs_output = get_failed_jobs_output(mr_id=mr_id)
        if failed_jobs_output:
            return f"""
    パイプラインで以下のエラーが出ています。
    プロダクトコードの修正で対応が可能な場合は修正を行ってください。
    
    {failed_jobs_output}
    """
        else:
            return "パイプラインで失敗したジョブが見つかりません。"
  • Helper function that implements the core logic of fetching console output from failed jobs in the latest pipeline of a GitLab MR. Called by the tool handler.
    def get_failed_jobs_output(mr_id: int) -> str:
        """
        指定したMR IDに関連する最後のパイプラインで失敗したジョブのコンソール出力を取得します。
    
        最後のパイプラインに失敗したジョブがなければ、空の文字列を返します。
    
        Args:
            mr_id (int): Merge Request ID
    
        Returns:
            str: 失敗したジョブのコンソール出力、または空文字列
    
        Raises:
            ValueError: ジョブ出力の取得に失敗した場合
        """
        try:
            project = get_gitlab_project()
    
            # MRを取得
            mr = project.mergerequests.get(mr_id)
    
            # パイプライン情報を取得
            if not hasattr(mr, "pipelines") or not mr.pipelines:
                return ""
    
            # パイプラインを取得し、最新のものを選択
            pipelines = mr.pipelines.list()
            if not pipelines:
                return ""
    
            # 最新のパイプラインを取得 (GitLabのAPIはデフォルトで降順)
            latest_pipeline = pipelines[0]
            pipeline_detail = project.pipelines.get(latest_pipeline.id)
    
            # 失敗したジョブを検索
            failed_jobs = [
                job for job in pipeline_detail.jobs.list() if job.status == "failed"
            ]
    
            if not failed_jobs:
                return ""  # 失敗したジョブがない場合は空文字列を返す
    
            # 失敗したジョブのコンソール出力を取得
            outputs = []
            for job in failed_jobs:
                job_detail = project.jobs.get(job.id)
                job_output = job_detail.trace()
                outputs.append(
                    f"# ジョブ: {job.name}\n- ステータス: {job.status}\n- 出力:\n```\n{job_output}\n```"
                )
    
            return "\n\n".join(outputs)
        except gitlab.exceptions.GitlabGetError:
            raise ValueError(f"MR ID #{mr_id} が見つかりません。")
        except Exception as e:
            raise ValueError(f"失敗したジョブの出力取得に失敗しました: {str(e)}")
  • main.py:31-43 (helper)
    Helper function to get the current Merge Request ID from the current branch, used by the tool handler.
    def get_current_mr_id() -> int:
        """
        現在のブランチのMRIDを取得します。
    
        Returns:
            int: 現在のブランチのMRID
        """
        branch_name = get_current_branch()
        mr = get_merge_request(branch_name)
        if mr:
            return mr.iid
        else:
            return "現在のブランチに関連するMerge Requestが見つかりません。"
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. It mentions retrieving console output for failed jobs, implying a read-only operation, but doesn't disclose behavioral traits like authentication requirements, rate limits, error handling, or what happens if no failed jobs exist. The description is minimal and lacks critical operational context.

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, clear sentence in Japanese that directly states the tool's function without unnecessary words. It's front-loaded and efficiently conveys the core purpose, making it highly concise and well-structured.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the return value includes (e.g., job details, error messages, format) or address potential complexities like pagination or filtering. For a tool that likely interacts with GitLab APIs, more context is needed for effective use.

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?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add param details, but this is acceptable given the schema's completeness. Baseline is 4 for zero parameters, as the description doesn't need to compensate for gaps.

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: 'GitLabパイプラインで失敗したジョブのコンソール出力を取得' (Get console output for failed jobs in a GitLab pipeline). It specifies the verb ('取得' - get/retrieve) and resource ('失敗したジョブのコンソール出力' - console output of failed jobs), though it doesn't explicitly distinguish from sibling tools like 'get_review_changes' or 'get_review_comments'.

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 pipeline ID or authentication), context for invocation, or exclusions. Without annotations or sibling tool context, usage is implied but not explicit.

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

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