Skip to main content
Glama

get_job

Retrieve detailed information about a specific CI/CD job in GitLab by providing the project identifier and job ID.

Instructions

取得 Job 詳細資訊

Args: project_id: 專案 ID 或路徑 job_id: Job ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
job_idYes

Implementation Reference

  • The MCP tool handler for "get_job". It wraps the gitlab_client's get_job method and formats the result.
    def get_job(project_id: int | str, job_id: int) -> str:
        """取得 Job 詳細資訊
    
        Args:
            project_id: 專案 ID 或路徑
            job_id: Job ID
        """
        try:
            client = get_client()
            j = client.get_job(project_id, job_id)
    
            status_emoji = {
                "success": "✅", "failed": "❌", "running": "🔄",
                "pending": "⏳", "canceled": "⛔", "skipped": "⏭️"
            }
            emoji = status_emoji.get(j.get("status", ""), "⚪")
            duration = f"{j['duration']:.1f}秒" if j.get("duration") else "N/A"
    
            return f"""{emoji} Job #{j['id']} — {j.get('name', 'N/A')}
    階段: {j.get('stage', 'N/A')}
    狀態: {j.get('status', 'N/A')}
    持續時間: {duration}
    Ref: {j.get('ref', 'N/A')}
    Runner: {j.get('runner', {}).get('description', 'N/A') if j.get('runner') else 'N/A'}
    建立時間: {j.get('created_at', 'N/A')}
    開始時間: {j.get('started_at', 'N/A')}
    完成時間: {j.get('finished_at', 'N/A')}
    網址: {j.get('web_url', '')}
    
    💡 使用 get_job_log({j['id']}) 查看執行日誌"""
        except GitLabAPIError as e:
            return f"取得 Job 失敗: {str(e)}"
  • The underlying gitlab client method that makes the API request to fetch job details.
    def get_job(self, project_id: int | str, job_id: int) -> dict:
        """GET /projects/:id/jobs/:job_id"""
        pid = self._resolve_project_id(project_id)
        return self._get_json(f"/projects/{pid}/jobs/{job_id}")
  • Registration of the get_job tool using @mcp.tool().
    @mcp.tool()
    def get_job(project_id: int | str, job_id: int) -> str:

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