gitlab_get_job_logs
Retrieve job execution logs from GitLab CI/CD pipelines to monitor build status and debug failures.
Instructions
Gets logs for a specific job.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | The path of the GitLab project. | |
| jobId | Yes | The ID of the job. |
Implementation Reference
- src/gitlab.service.ts:555-572 (handler)Implements the core logic for fetching GitLab CI/CD job logs by making a direct API request to the /jobs/{jobId}/trace endpoint and returning the log text.async getJobLogs(projectPath: string, jobId: number): Promise<string> { const encodedProjectPath = encodeURIComponent(projectPath); const url = `${this.config.url}/api/v4/projects/${encodedProjectPath}/jobs/${jobId}/trace`; const headers = { 'Private-Token': this.config.accessToken, }; try { const response = await fetch(url, { headers }); if (!response.ok) { throw new Error(`Failed to get job logs: ${response.status} - ${response.statusText}`); } return await response.text(); } catch (error) { console.error(`Failed to get job logs: ${error}`); throw error; } }
- src/index.ts:679-694 (schema)Defines the tool schema including input parameters: projectPath (string) and jobId (number).name: 'gitlab_get_job_logs', description: 'Gets logs for a specific job.', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'The path of the GitLab project.', }, jobId: { type: 'number', description: 'The ID of the job.', }, }, required: ['projectPath', 'jobId'], },
- src/index.ts:1824-1838 (registration)Registers the tool handler in the MCP server switch statement, dispatching to GitLabService.getJobLogs and returning the logs as text content.case 'gitlab_get_job_logs': { if (!gitlabService) { throw new Error('GitLab service is not initialized.'); } const { projectPath, jobId } = args as { projectPath: string; jobId: number }; const result = await gitlabService.getJobLogs(projectPath, jobId); return { content: [ { type: 'text', text: result, }, ], }; }