MCP Tool request - CI-CD Artifacts

Note

Before picking up this work: this issue adds an MCP tool. Please follow the Adding a new tool guidance first. That includes creating an MCP Tool Proposal, using verb_object naming (get_ / list_ / save_ / delete_), and the shared resource-identification input base classes.

Summary

Agents need the ability to access CI/CD artifacts (files uploaded by jobs during pipeline execution) to analyze test results, code coverage reports, build outputs, and other job-generated data. This capability is foundational for enabling AI-powered test intelligence and build analysis workflows.

Currently, GitLab Duo agents cannot access CI artifacts, which limits their ability to:

  • Analyze test results and identify failure patterns
  • Review code coverage reports and suggest improvements
  • Debug build failures using detailed logs
  • Compare outputs across pipeline runs
  • Provide insights on test quality and performance

Proposed Solution

Build MCP tools that enable agents to access CI artifacts.

Backing API per tool

  • list_ci_artifacts → GraphQL (Base::GraphqlTool + Base::GraphqlService). CiJob.artifacts (Types::Ci::JobArtifactType) and Pipeline.jobArtifacts expose name, size, fileType (JobArtifactFileTypeEnum), downloadPath, expireAt, expired. Reach them via project → pipeline/job. Filter by artifact_type client-side (the connection has no file-type arg).
  • get_ci_artifact_content → REST (Base::ApiTool). GraphQL only yields a download URL, not file bytes or path-scoped reads; artifact file content is served by Workhorse (GET /projects/:id/jobs/:job_id/artifacts/*artifact_path). No GraphQL equivalent.
  • search_ci_artifactssplit out of this issue into #612116 to decide the implementation approach. Not part of this initial build (list_ci_artifacts + get_ci_artifact_content).

1. list_ci_artifacts

Purpose: List all artifacts for a given job or pipeline

Parameters:

  • project_id (required) - Project identifier
  • pipeline_id (optional) - Pipeline to get artifacts from
  • job_id (optional) - Specific job to get artifacts from
  • artifact_type (optional) - Filter by type (e.g., "archive", "junit", "coverage")

Returns:

  • List of artifacts with metadata:
    • Artifact name
    • File size
    • Upload timestamp
    • Job that created it
    • Download URL/identifier

Example use:

Agent: "List all artifacts from pipeline 12345"
Tool returns: ["test_results.xml", "coverage_report.html", "performance_logs.csv"]

2. get_ci_artifact_content

Purpose: Download and read artifact contents

Parameters:

  • project_id (required) - Project identifier
  • job_id (required) - Job that created the artifact
  • artifact_path (required) - Path to specific file within artifact archive
  • max_size (optional) - Maximum bytes to read (default: 1MB, prevent large file issues)

Returns:

  • File contents (as text or base64 if binary)
  • File metadata (size, mime type)

Example use:

Agent: "Get contents of test_results.xml from job 789"
Tool returns: <XML content of test results>

Use Cases

Primary Use Cases

  1. Test result analysis
    • Analyze CSV logs with execution times, function names, line numbers
    • Identify performance bottlenecks in embedded systems
    • Detect patterns in test failures
  2. Test intelligence agent
    • "Why is this test flaky?" → Analyze test results across multiple runs
    • "What's my code coverage?" → Read coverage artifacts and explain gaps
    • "What changed between passing and failing runs?" → Compare artifacts
  3. Build debugging
    • Analyze build logs and error outputs
    • Compare successful vs failed build artifacts
    • Identify dependency or configuration issues
  4. Performance monitoring
    • Track performance metrics over time
    • Identify performance regressions
    • Benchmark comparisons across commits

Secondary Use Cases

  1. Security scan analysis
    • Review security scan results
    • Prioritize vulnerabilities
    • Suggest remediation
  2. Compliance & audit
    • Review build provenance
    • Analyze compliance reports
    • Generate audit summaries

Acceptance Criteria

  • Tools work with both MCP Server (external AIs) and DAP (GitLab Duo agents)
  • Tools available and documented
Edited by 🤖 GitLab Bot 🤖