Skip to main content
Glama
CircleCI-Public

mcp-server-circleci

Official

analyze_diff

Analyze git diffs against IDE rules to identify code violations before committing changes. Use speed mode for faster analysis or filters to focus on specific issues.

Instructions

This tool is used to analyze a git diff (unstaged, staged, or all changes) against IDE rules to identify rule violations. By default, the tool will use the staged changes, unless the user explicitly asks for unstaged or all changes.

Parameters:

  • params: An object containing:

    • speedMode: boolean - A mode that can be enabled to speed up the analysis. Default value is false.

    • filterBy: enum - "Violations" | "Compliants" | "Human Review Required" | "None" - A filter that can be applied to set the focus of the analysis. Default is None.

    • diff: string - A git diff string.

    • rules: string - Rules to use for analysis, found in the rules subdirectory of the IDE workspace settings. Combine all rules from multiple files by separating them with ---

Returns:

  • A list of rule violations found in the git diff.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNo

Implementation Reference

  • Main handler function implementing the core logic of the analyze_diff tool. It uses CircletClient to review git diff against provided rules and returns violations or compliance message.
    export const analyzeDiff: ToolCallback<{
      params: typeof analyzeDiffInputSchema;
    }> = async (args) => {
      const { diff, rules, speedMode, filterBy } = args.params ?? {};
      const circlet = new CircletClient();
      if (!diff) {
        return {
          content: [
            {
              type: 'text',
              text: 'No diff found. Please provide a diff to analyze.',
            },
          ],
        };
      }
    
      if (!rules) {
        return {
          content: [
            {
              type: 'text',
              text: 'No rules found. Please add rules to your repository.',
            },
          ],
        };
      }
    
      const response = await circlet.circlet.ruleReview({
        diff,
        rules,
        filterBy,
        speedMode,
      });
    
      if (!response.isRuleCompliant) {
        return {
          content: [
            {
              type: 'text',
              text: response.relatedRules.violations
                .map((violation) => {
                  return `Rule: ${violation.rule}\nReason: ${violation.reason}\nConfidence Score: ${violation.confidenceScore}`;
                })
                .join('\n\n'),
            },
          ],
        };
      }
    
      return {
        content: [
          {
            type: 'text',
            text: `All rules are compliant.`,
          },
        ],
      };
    };
  • Zod input schema defining parameters for analyze_diff: speedMode, filterBy, diff, rules.
    export const analyzeDiffInputSchema = z.object({
      speedMode: z
        .boolean()
        .default(false)
        .describe('The status of speed mode. Defaults to false.'),
      filterBy: z
        .nativeEnum(FilterBy)
        .default(FilterBy.none)
        .describe(`Analysis filter. Defaults to ${FilterBy.none}`),
      diff: z
        .string()
        .describe(
          'Git diff content to analyze. Defaults to staged changes, unless the user explicitly asks for unstaged changes or all changes.',
        ),
      rules: z
        .string()
        .describe(
          'Rules to use for analysis, found in the rules subdirectory of the IDE workspace settings. Combine all rules from multiple files by separating them with ---',
        ),
    });
  • Tool object registration defining name 'analyze_diff', description, and inputSchema.
    export const analyzeDiffTool = {
      name: 'analyze_diff' as const,
      description: `
      This tool is used to analyze a git diff (unstaged, staged, or all changes) against IDE rules to identify rule violations.
      By default, the tool will use the staged changes, unless the user explicitly asks for unstaged or all changes.
    
      Parameters:
      - params: An object containing:
        - speedMode: boolean - A mode that can be enabled to speed up the analysis. Default value is false.
        - filterBy: enum - "${FilterBy.violations}" | "${FilterBy.compliants}" | "${FilterBy.humanReviewRequired}" | "${FilterBy.none}" - A filter that can be applied to set the focus of the analysis. Default is ${FilterBy.none}.
        - diff: string - A git diff string.
        - rules: string - Rules to use for analysis, found in the rules subdirectory of the IDE workspace settings. Combine all rules from multiple files by separating them with ---
    
      Returns:
      - A list of rule violations found in the git diff.
      `,
      inputSchema: analyzeDiffInputSchema,
    };
  • analyzeDiffTool is included in the CCI_TOOLS array for MCP tool registration.
    export const CCI_TOOLS = [
      getBuildFailureLogsTool,
      getFlakyTestLogsTool,
      getLatestPipelineStatusTool,
      getJobTestResultsTool,
      configHelperTool,
      createPromptTemplateTool,
      recommendPromptTemplateTestsTool,
      runPipelineTool,
      listFollowedProjectsTool,
      runEvaluationTestsTool,
      rerunWorkflowTool,
      downloadUsageApiDataTool,
      findUnderusedResourceClassesTool,
      analyzeDiffTool,
      runRollbackPipelineTool,
      listComponentVersionsTool,
    ];
  • Handler for 'analyze_diff' is mapped to analyzeDiff function in CCI_HANDLERS.
    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;
Behavior3/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the analysis process and default behavior for diff selection, but lacks details on permissions, rate limits, error handling, or output format beyond 'a list of rule violations.' For a tool with no annotations, this leaves gaps in understanding its operational behavior.

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 and appropriately sized. It starts with the core purpose, adds usage context, then details parameters and returns. Each sentence adds value, with no redundant information. A minor deduction because the parameter explanations could be slightly more concise, but overall it's efficient and front-loaded.

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

Completeness3/5

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

Given the tool's complexity (analyzing git diffs with configurable rules) and the absence of annotations and output schema, the description is adequate but incomplete. It covers the purpose, parameters, and basic return type, but lacks details on error cases, performance implications of speedMode, or examples of rule violation outputs. For a tool with no structured behavioral data, more context would be helpful.

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

Parameters4/5

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

The description adds significant meaning beyond the input schema. The schema has 0% description coverage (no parameter descriptions), but the tool description explains all four parameters (speedMode, filterBy, diff, rules) with practical context, including default behaviors and usage notes (e.g., 'Combine all rules from multiple files by separating them with ---'). This compensates well for the schema's lack of documentation.

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: 'analyze a git diff against IDE rules to identify rule violations.' It specifies the verb ('analyze'), resource ('git diff'), and scope ('against IDE rules'), distinguishing it from sibling tools like config_helper or run_pipeline which have unrelated functions. The description is specific and unambiguous.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool: 'analyze a git diff (unstaged, staged, or all changes) against IDE rules.' It also specifies default behavior: 'By default, the tool will use the staged changes, unless the user explicitly asks for unstaged or all changes.' However, it does not mention when NOT to use this tool or explicitly name alternatives among siblings, which prevents a score of 5.

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