Skip to main content
Glama
Alosies
by Alosies

get_job_trace

Retrieve GitLab CI/CD job execution logs with options to limit lines, view tail output, and access raw log data for debugging and monitoring purposes.

Instructions

Get job trace with options for partial logs, tail mode, and line limits

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYesJob ID
lines_limitNoMaximum number of lines to return (default: 1000)
project_idYesProject ID or path
rawNoReturn raw log without formatting
tailNoGet the last N lines instead of first N lines

Implementation Reference

  • Core handler function that fetches job trace from GitLab API, applies line limits and tail options, formats the output with metadata, and handles errors.
    async getJobTrace(args: GetJobTraceParams) { try { const logContent = await this.client.get(`/projects/${encodeURIComponent(args.project_id)}/jobs/${args.job_id}/trace`); const linesLimit = args.lines_limit || 1000; if (typeof logContent === 'string' && logContent) { const lines = logContent.split('\n'); const totalLines = lines.length; // Apply line limiting let processedLines: string[]; if (args.tail) { // Get last N lines processedLines = lines.slice(-linesLimit); } else { // Get first N lines processedLines = lines.slice(0, linesLimit); } const processedContent = processedLines.join('\n'); // Prepare response with metadata let responseText: string; if (args.raw) { responseText = processedContent; } else { const metadata = [ `πŸ“‹ Job Trace Summary`, `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`, `πŸ“Š Total lines: ${totalLines}`, `πŸ“„ Showing: ${processedLines.length} lines ${args.tail ? '(last)' : '(first)'}`, `πŸ”— Project: ${args.project_id}`, `πŸš€ Job ID: ${args.job_id}`, ``, `πŸ“ Log Content:`, `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`, processedContent ]; if (totalLines > linesLimit) { metadata.push('', `⚠️ Log truncated. Total lines: ${totalLines}, Showing: ${processedLines.length}`); if (args.tail) { metadata.push(`πŸ’‘ Use tail:false to see the beginning of the log`); } else { metadata.push(`πŸ’‘ Use tail:true to see the end of the log`); } } responseText = metadata.join('\n'); } return { content: [ { type: 'text', text: responseText, }, ], }; } else { return { content: [ { type: 'text', text: `No log content available for job ${args.job_id} in project ${args.project_id}`, }, ], }; } } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text', text: `Failed to retrieve job trace: ${errorMessage}`, }, ], isError: true, }; } }
  • src/server.ts:325-328 (registration)
    Dispatch registration in the MCP server switch statement that routes 'get_job_trace' calls to the JobHandlers.getJobTrace method.
    case "get_job_trace": return await this.jobHandlers.getJobTrace( args as unknown as GetJobTraceParams );
  • Tool registration definition including name, description, and input schema, exported as part of jobTools array.
    { name: 'get_job_trace', description: 'Get job trace with options for partial logs, tail mode, and line limits', inputSchema: { type: 'object', properties: { project_id: { type: 'string', description: 'Project ID or path', }, job_id: { type: 'number', description: 'Job ID', }, lines_limit: { type: 'number', description: 'Maximum number of lines to return (default: 1000)', default: 1000, }, tail: { type: 'boolean', description: 'Get the last N lines instead of first N lines', default: false, }, raw: { type: 'boolean', description: 'Return raw log without formatting', default: false, }, }, required: ['project_id', 'job_id'], }, },
  • TypeScript interface defining the input parameters for the get_job_trace tool, used in handler and server.
    export interface GetJobTraceParams { project_id: string; job_id: number; lines_limit?: number; tail?: boolean; raw?: boolean; }

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

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