Skip to main content
Glama

compare_results

Compare two Semgrep scan result files (old and new JSON) to detect changes in findings, track issue resolution, and monitor code quality improvements over time.

Instructions

Compares two scan results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
old_resultsYesAbsolute path to older JSON results file
new_resultsYesAbsolute path to newer JSON results file

Implementation Reference

  • Main handler for the 'compare_results' tool. Reads old and new JSON scan result files, compares findings using a composite key (check_id:path:line:col), and returns added/removed/unchanged findings with a summary.
    private async handleCompareResults(args: any) {
      if (!args.old_results || !args.new_results) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'old_results and new_results are required'
        );
      }
    
      const oldResultsFile = validateAbsolutePath(args.old_results, 'old_results');
      const newResultsFile = validateAbsolutePath(args.new_results, 'new_results');
    
      try {
        const [oldContent, newContent] = await Promise.all([
          readFile(oldResultsFile, 'utf-8'),
          readFile(newResultsFile, 'utf-8'),
        ]);
    
        const oldResults = getSemgrepFindings(parseSemgrepResults(oldContent));
        const newResults = getSemgrepFindings(parseSemgrepResults(newContent));
    
        const oldFindings = new Set(oldResults.map((r: any) =>
          `${r.check_id}:${r.path}:${r.start?.line}:${r.start?.col}`
        ));
    
        const comparison = {
          total_old: oldResults.length,
          total_new: newResults.length,
          added: [] as any[],
          removed: [] as any[],
          unchanged: [] as any[]
        };
    
        newResults.forEach((finding: any) => {
          const key = `${finding.check_id}:${finding.path}:${finding.start?.line}:${finding.start?.col}`;
          if (oldFindings.has(key)) {
            comparison.unchanged.push(finding);
          } else {
            comparison.added.push(finding);
          }
        });
    
        const newKeys = new Set(newResults.map((r: any) =>
          `${r.check_id}:${r.path}:${r.start?.line}:${r.start?.col}`
        ));
        oldResults.forEach((finding: any) => {
          const key = `${finding.check_id}:${finding.path}:${finding.start?.line}:${finding.start?.col}`;
          if (!newKeys.has(key)) {
            comparison.removed.push(finding);
          }
        });
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              summary: {
                old_findings: comparison.total_old,
                new_findings: comparison.total_new,
                added: comparison.added.length,
                removed: comparison.removed.length,
                unchanged: comparison.unchanged.length
              },
              details: comparison
            }, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{ type: 'text', text: `Error comparing results: ${error.message}` }],
          isError: true
        };
      }
    }
  • Input schema for 'compare_results' tool, defining required parameters 'old_results' and 'new_results' (both absolute file paths).
    {
      name: 'compare_results',
      description: 'Compares two scan results',
      inputSchema: {
        type: 'object',
        properties: {
          old_results: { type: 'string', description: 'Absolute path to older JSON results file' },
          new_results: { type: 'string', description: 'Absolute path to newer JSON results file' }
        },
        required: ['old_results', 'new_results']
      }
    }
  • src/index.ts:371-395 (registration)
    The tool registration in the CallToolRequestSchema handler. Routes 'compare_results' to handleCompareResults method.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      await this.ensureSemgrepAvailable();
    
      switch (request.params.name) {
      case 'scan_directory':
        return await this.handleScanDirectory(request.params.arguments);
      case 'list_rules':
        return await this.handleListRules(request.params.arguments);
      case 'analyze_results':
        return await this.handleAnalyzeResults(request.params.arguments);
      case 'create_rule':
        return await this.handleCreateRule(request.params.arguments);
      case 'filter_results':
        return await this.handleFilterResults(request.params.arguments);
      case 'export_results':
        return await this.handleExportResults(request.params.arguments);
      case 'compare_results':
        return await this.handleCompareResults(request.params.arguments);
      default:
        throw new McpError(
          ErrorCode.MethodNotFound,
          `Unknown tool: ${request.params.name}`
        );
      }
    });
Behavior2/5

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

The description is minimal ('Compares two scan results') and provides no behavioral details beyond the name. With no annotations, it fails to disclose whether the tool is read-only, its side effects, return behavior, or required permissions.

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 a single sentence with no extra words, making it concise. However, it could be restructured to front-load more critical information without increasing length significantly.

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

Completeness2/5

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

For a tool with no output schema and only two string parameters, the description does not explain what the comparison produces (e.g., diff output, boolean, list of changes). This leaves the agent unsure of the return value and behavior, making it incomplete.

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

Parameters3/5

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

Both parameters are described in the input schema ('Absolute path to older JSON results file' and 'Absolute path to newer JSON results file'), achieving 100% schema coverage. The description adds no additional meaning beyond the schema, so baseline 3 is appropriate.

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

Purpose4/5

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

The description 'Compares two scan results' uses a verb ('compares') and resource ('scan results'), clearly indicating the tool's function. It is distinct from siblings like 'analyze_results' and 'filter_results', but lacks specificity on what the comparison entails (e.g., differences, similarities).

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives such as 'analyze_results' or 'filter_results'. There is no mention of prerequisites, when-not-to-use, or explicit context.

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/VetCoders/mcp-server-semgrep'

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