Skip to main content
Glama
CircleCI-Public

mcp-server-circleci

Official

get_build_failure_logs

Retrieve and analyze failure logs from CircleCI builds to identify and debug issues in your CI/CD pipelines.

Instructions

This tool helps debug CircleCI build failures by retrieving failure logs.

CRITICAL REQUIREMENTS:
1. Truncation Handling (HIGHEST PRIORITY):
   - ALWAYS check for <MCPTruncationWarning> in the output
   - When present, you MUST start your response with:
     "WARNING: The logs have been truncated. Only showing the most recent entries. Earlier build failures may not be visible."
   - Only proceed with log analysis after acknowledging the truncation

Input options (EXACTLY ONE of these THREE options must be used):

Option 1 - Project Slug and branch (BOTH required):
- projectSlug: The project slug obtained from listFollowedProjects tool (e.g., "gh/organization/project")
- branch: The name of the branch (required when using projectSlug)

Option 2 - Direct URL (provide ONE of these):
- projectURL: The URL of the CircleCI project in any of these formats:
  * Project URL: https://app.circleci.com/pipelines/gh/organization/project
  * Pipeline URL: https://app.circleci.com/pipelines/gh/organization/project/123
  * Legacy Job URL: https://circleci.com/pipelines/gh/organization/project/123
  * Workflow URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def
  * Job URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def/jobs/xyz

Option 3 - Project Detection (ALL of these must be provided together):
- workspaceRoot: The absolute path to the workspace root
- gitRemoteURL: The URL of the git remote repository
- branch: The name of the current branch

Recommended Workflow:
1. Use listFollowedProjects tool to get a list of projects
2. Extract the projectSlug from the chosen project (format: "gh/organization/project")
3. Use that projectSlug with a branch name for this tool

Additional Requirements:
- Never call this tool with incomplete parameters
- If using Option 1, make sure to extract the projectSlug exactly as provided by listFollowedProjects
- If using Option 2, the URLs MUST be provided by the user - do not attempt to construct or guess URLs
- If using Option 3, ALL THREE parameters (workspaceRoot, gitRemoteURL, branch) must be provided
- If none of the options can be fully satisfied, ask the user for the missing information before making the tool call

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNo

Implementation Reference

  • The main ToolCallback handler function that parses input parameters, identifies the CircleCI project slug, fetches pipeline job logs, and formats them for output.
    export const getBuildFailureLogs: ToolCallback<{
      params: typeof getBuildFailureOutputInputSchema;
    }> = async (args) => {
      const {
        workspaceRoot,
        gitRemoteURL,
        branch,
        projectURL,
        projectSlug: inputProjectSlug,
      } = args.params ?? {};
    
      let projectSlug: string | undefined;
      let pipelineNumber: number | undefined;
      let branchFromURL: string | undefined;
      let jobNumber: number | undefined;
    
      if (inputProjectSlug) {
        if (!branch) {
          return mcpErrorOutput(
            'Branch not provided. When using projectSlug, a branch must also be specified.',
          );
        }
        projectSlug = inputProjectSlug;
      } else if (projectURL) {
        projectSlug = getProjectSlugFromURL(projectURL);
        pipelineNumber = getPipelineNumberFromURL(projectURL);
        branchFromURL = getBranchFromURL(projectURL);
        jobNumber = getJobNumberFromURL(projectURL);
      } else if (workspaceRoot && gitRemoteURL && branch) {
        projectSlug = await identifyProjectSlug({
          gitRemoteURL,
        });
      } else {
        return mcpErrorOutput(
          'Missing required inputs. Please provide either: 1) projectSlug with branch, 2) projectURL, or 3) workspaceRoot with gitRemoteURL and branch.',
        );
      }
    
      if (!projectSlug) {
        return mcpErrorOutput(`
              Project not found. Ask the user to provide the inputs user can provide based on the tool description.
    
              Project slug: ${projectSlug}
              Git remote URL: ${gitRemoteURL}
              Branch: ${branch}
              `);
      }
    
      const logs = await getPipelineJobLogs({
        projectSlug,
        branch: branchFromURL || branch,
        pipelineNumber,
        jobNumber,
      });
    
      return formatJobLogs(logs);
    };
  • Zod input schema defining optional parameters: projectSlug, branch, projectURL, workspaceRoot, gitRemoteURL with detailed descriptions.
    export const getBuildFailureOutputInputSchema = z.object({
      projectSlug: z.string().describe(projectSlugDescription).optional(),
      branch: z.string().describe(branchDescription).optional(),
      projectURL: z
        .string()
        .describe(
          'The URL of the CircleCI project. Can be any of these formats:\n' +
            '- Project URL with branch: https://app.circleci.com/pipelines/gh/organization/project?branch=feature-branch\n' +
            '- Pipeline URL: https://app.circleci.com/pipelines/gh/organization/project/123\n' +
            '- Workflow URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def\n' +
            '- Job URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def/jobs/xyz',
        )
        .optional(),
      workspaceRoot: z
        .string()
        .describe(
          'The absolute path to the root directory of your project workspace. ' +
            'This should be the top-level folder containing your source code, configuration files, and dependencies. ' +
            'For example: "/home/user/my-project" or "C:\\Users\\user\\my-project"',
        )
        .optional(),
      gitRemoteURL: z
        .string()
        .describe(
          'The URL of the remote git repository. This should be the URL of the repository that you cloned to your local workspace. ' +
            'For example: "https://github.com/user/my-project.git"',
        )
        .optional(),
    });
  • Tool specification object defining the name 'get_build_failure_logs', detailed description, and references the input schema. Exported for registration.
    export const getBuildFailureLogsTool = {
      name: 'get_build_failure_logs' as const,
      description: `
        This tool helps debug CircleCI build failures by retrieving failure logs.
    
        CRITICAL REQUIREMENTS:
        1. Truncation Handling (HIGHEST PRIORITY):
           - ALWAYS check for <MCPTruncationWarning> in the output
           - When present, you MUST start your response with:
             "WARNING: The logs have been truncated. Only showing the most recent entries. Earlier build failures may not be visible."
           - Only proceed with log analysis after acknowledging the truncation
    
        Input options (EXACTLY ONE of these THREE options must be used):
    
        ${option1DescriptionBranchRequired}
    
        Option 2 - Direct URL (provide ONE of these):
        - projectURL: The URL of the CircleCI project in any of these formats:
          * Project URL: https://app.circleci.com/pipelines/gh/organization/project
          * Pipeline URL: https://app.circleci.com/pipelines/gh/organization/project/123
          * Legacy Job URL: https://circleci.com/pipelines/gh/organization/project/123
          * Workflow URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def
          * Job URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def/jobs/xyz
    
        Option 3 - Project Detection (ALL of these must be provided together):
        - workspaceRoot: The absolute path to the workspace root
        - gitRemoteURL: The URL of the git remote repository
        - branch: The name of the current branch
        
        Recommended Workflow:
        1. Use listFollowedProjects tool to get a list of projects
        2. Extract the projectSlug from the chosen project (format: "gh/organization/project")
        3. Use that projectSlug with a branch name for this tool
    
        Additional Requirements:
        - Never call this tool with incomplete parameters
        - If using Option 1, make sure to extract the projectSlug exactly as provided by listFollowedProjects
        - If using Option 2, the URLs MUST be provided by the user - do not attempt to construct or guess URLs
        - If using Option 3, ALL THREE parameters (workspaceRoot, gitRemoteURL, branch) must be provided
        - If none of the options can be fully satisfied, ask the user for the missing information before making the tool call
        `,
      inputSchema: getBuildFailureOutputInputSchema,
    };
  • Registration of the getBuildFailureLogsTool in the main CCI_TOOLS array for MCP toolset.
    export const CCI_TOOLS = [
      getBuildFailureLogsTool,
      getFlakyTestLogsTool,
      getLatestPipelineStatusTool,
      getJobTestResultsTool,
      configHelperTool,
      createPromptTemplateTool,
      recommendPromptTemplateTestsTool,
      runPipelineTool,
      listFollowedProjectsTool,
      runEvaluationTestsTool,
      rerunWorkflowTool,
      downloadUsageApiDataTool,
      findUnderusedResourceClassesTool,
      analyzeDiffTool,
      runRollbackPipelineTool,
      listComponentVersionsTool,
    ];
  • Mapping of tool name 'get_build_failure_logs' to its handler function in the CCI_HANDLERS object.
    export const CCI_HANDLERS = {
      get_build_failure_logs: getBuildFailureLogs,
      find_flaky_tests: getFlakyTestLogs,
      get_latest_pipeline_status: getLatestPipelineStatus,
      get_job_test_results: getJobTestResults,
      config_helper: configHelper,
      create_prompt_template: createPromptTemplate,
      recommend_prompt_template_tests: recommendPromptTemplateTests,
      run_pipeline: runPipeline,
      list_followed_projects: listFollowedProjects,
      run_evaluation_tests: runEvaluationTests,
      rerun_workflow: rerunWorkflow,
      download_usage_api_data: downloadUsageApiData,
      find_underused_resource_classes: findUnderusedResourceClasses,
      analyze_diff: analyzeDiff,
      run_rollback_pipeline: runRollbackPipeline,
      list_component_versions: listComponentVersions,
    } satisfies ToolHandlers;
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure and does so comprehensively. It reveals critical behavioral traits including truncation handling requirements (checking for <MCPTruncationWarning>, required warning message), input validation rules (exactly one of three options, parameter completeness requirements), and workflow dependencies (recommends using listFollowedProjects first). This goes well beyond what a basic description would provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (CRITICAL REQUIREMENTS, Input options, Recommended Workflow, Additional Requirements) but is quite lengthy. While every sentence earns its place by providing essential guidance, the front-loading could be improved - the core purpose appears early, but critical behavioral details are buried in later sections. The structure helps navigation but the length reduces conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (multiple input options, truncation handling, workflow dependencies) and the absence of both annotations and output schema, the description provides complete contextual information. It covers purpose, usage scenarios, parameter semantics, behavioral constraints, error handling, and integration with other tools. No additional information would be needed for an agent to use this tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite having 0% schema description coverage (the schema has descriptions but they're not counted in coverage), the description provides extensive parameter semantics that fully compensate. It explains the three distinct parameter options, their relationships (mutual exclusivity, required combinations), specific format requirements (e.g., projectSlug format from listFollowedProjects), and practical usage examples. This adds substantial meaning beyond the basic schema properties.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'retrieving failure logs' to 'debug CircleCI build failures'. It specifies the exact resource (failure logs) and verb (retrieve), and distinguishes it from siblings like get_job_test_results or get_latest_pipeline_status by focusing specifically on failure logs rather than test results or status.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit, detailed guidance on when and how to use this tool versus alternatives. It outlines three distinct input options with clear requirements, specifies that exactly one option must be used, and provides a recommended workflow starting with the listFollowedProjects tool. It also includes explicit exclusions ('Never call this tool with incomplete parameters') and prerequisites for each option.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/CircleCI-Public/mcp-server-circleci'

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