Skip to main content
Glama
Alosies
by Alosies

get_job_trace

Retrieve GitLab CI/CD job logs with options for partial output, tail viewing, and line limits to monitor pipeline execution.

Instructions

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

Input Schema

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

Implementation Reference

  • Main handler function that fetches job trace from GitLab API, processes it (line limits, tail, raw mode), formats response with metadata.
    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, }; } }
  • MCP tool definition including input JSON schema for validation and description.
    { 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'], }, },
  • src/server.ts:325-328 (registration)
    Server dispatch logic that maps tool name to the jobHandlers.getJobTrace method.
    case "get_job_trace": return await this.jobHandlers.getJobTrace( args as unknown as GetJobTraceParams );
  • TypeScript interface for input parameters used in handler signature.
    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