Skip to main content
Glama

gitlab_get_pipeline_details

Retrieve detailed pipeline information from GitLab projects to monitor CI/CD status and troubleshoot build processes.

Instructions

Gets detailed information about a specific pipeline.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesThe path of the GitLab project.
pipelineIdYesThe ID of the pipeline.

Implementation Reference

  • Core handler implementation: GitLabService.getPipelineDetails fetches the pipeline details by calling the GitLab API endpoint for the specific project and pipeline ID.
    async getPipelineDetails(projectPath: string, pipelineId: number): Promise<any> {
      const encodedProjectPath = encodeURIComponent(projectPath);
      return this.callGitLabApi<any>(
        `projects/${encodedProjectPath}/pipelines/${pipelineId}`,
      );
    }
  • src/index.ts:643-658 (registration)
    Tool registration: Defines the 'gitlab_get_pipeline_details' tool including its name, description, and input schema in the allTools array used by the MCP server.
    name: 'gitlab_get_pipeline_details',
    description: 'Gets detailed information about a specific pipeline.',
    inputSchema: {
      type: 'object',
      properties: {
        projectPath: {
          type: 'string',
          description: 'The path of the GitLab project.',
        },
        pipelineId: {
          type: 'number',
          description: 'The ID of the pipeline.',
        },
      },
      required: ['projectPath', 'pipelineId'],
    },
  • MCP tool call handler: The switch case in the CallToolRequestSchema handler that extracts arguments, calls GitLabService.getPipelineDetails, and formats the response as MCP content.
    case 'gitlab_get_pipeline_details': {
      if (!gitlabService) {
        throw new Error('GitLab service is not initialized.');
      }
      const { projectPath, pipelineId } = args as { projectPath: string; pipelineId: number };
      const result = await gitlabService.getPipelineDetails(projectPath, pipelineId);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Helper method: callGitLabApi is the private utility used by getPipelineDetails to make authenticated HTTP requests to the GitLab API.
    private async callGitLabApi<T>(
      endpoint: string,
      method: string = 'GET',
      body?: object,
    ): Promise<T> {
      const url = `${this.config.url}/api/v4/${endpoint}`;
      const headers = {
        'Private-Token': this.config.accessToken,
        'Content-Type': 'application/json',
      };
    
      const options: any = {
        method,
        headers,
        body: body ? JSON.stringify(body) : undefined,
      };
    
      try {
        const response = await fetch(url, options);
        if (!response.ok) {
          const errorText = await response.text();
          console.error(`GitLab API Error: ${response.status} - ${errorText}`);
          throw new Error(`GitLab API Error: ${response.status} - ${errorText}`);
        }
        return response.json() as Promise<T>;
      } catch (error) {
        console.error(`Failed to call GitLab API: ${error}`);
        throw error;
      }
    }

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