Skip to main content
Glama

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
NameRequiredDescriptionDefault
projectPathYesThe path of the GitLab project.
jobIdYesThe ID of the job.

Implementation Reference

  • 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; } }
  • 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, }, ], }; }

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

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