Skip to main content
Glama

analyze_results

Identify security vulnerabilities and code quality issues by analyzing Semgrep scan results from a JSON file.

Instructions

Analyzes scan results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
results_fileYesAbsolute path to JSON results file (must be within an allowed workspace root)

Implementation Reference

  • Handler function for analyze_results tool. Reads a Semgrep JSON results file, parses it, and produces a summary with total findings, breakdown by severity, and breakdown by rule.
    private async handleAnalyzeResults(args: any) {
      if (!args.results_file) {
        throw new McpError(ErrorCode.InvalidParams, 'Results file is required');
      }
    
      const resultsFile = validateAbsolutePath(args.results_file, 'results_file');
    
      try {
        const fileContent = await readFile(resultsFile, 'utf-8');
        const results = parseSemgrepResults(fileContent);
        const findings = getSemgrepFindings(results);
    
        const summary = {
          total_findings: findings.length,
          by_severity: {} as Record<string, number>,
          by_rule: {} as Record<string, number>
        };
    
        for (const finding of findings) {
          const severity = finding.extra?.severity || 'unknown';
          const rule = finding.check_id || 'unknown';
          summary.by_severity[severity] = (summary.by_severity[severity] || 0) + 1;
          summary.by_rule[rule] = (summary.by_rule[rule] || 0) + 1;
        }
    
        return {
          content: [{ type: 'text', text: JSON.stringify(summary, null, 2) }]
        };
      } catch (error: any) {
        return {
          content: [{ type: 'text', text: `Error analyzing results: ${error.message}` }],
          isError: true
        };
      }
    }
  • Schema/registration for analyze_results tool. Defines the input schema requiring a 'results_file' string property.
    name: 'analyze_results',
    description: 'Analyzes scan results',
    inputSchema: {
      type: 'object',
      properties: {
        results_file: {
          type: 'string',
          description: 'Absolute path to JSON results file (must be within an allowed workspace root)'
        }
      },
      required: ['results_file']
    }
  • src/index.ts:379-380 (registration)
    Tool handler dispatch - routes 'analyze_results' tool calls to handleAnalyzeResults method.
    case 'analyze_results':
      return await this.handleAnalyzeResults(request.params.arguments);
  • Helper used by handleAnalyzeResults to parse the JSON file content into SemgrepResults object.
    export function parseSemgrepResults(fileContent: string): SemgrepResults {
      const parsedContent = JSON.parse(fileContent);
    
      if (!parsedContent || typeof parsedContent !== 'object' || Array.isArray(parsedContent)) {
        return {};
      }
    
      return parsedContent as SemgrepResults;
    }
  • Helper used by handleAnalyzeResults to extract the findings array from parsed results.
    function getSemgrepFindings(results: SemgrepResults): SemgrepFinding[] {
      return Array.isArray(results.results) ? results.results : [];
    }
Behavior2/5

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

With no annotations, the description carries full responsibility for behavioral disclosure. It only says 'Analyzes', implying a read operation, but does not state if results are modified, returned, or stored. No information about side effects, authorization needs, or output format is given.

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

Conciseness3/5

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

The description is a single sentence, which is concise but lacks structuring. It does not provide additional sections or details to aid understanding. The brevity is acceptable but not optimally informative.

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?

Given the absence of an output schema and the presence of sibling tools, the description is incomplete. It does not explain what the analysis returns or how it differs from compare_results or filter_results. The tool's functionality remains unclear.

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?

The schema provides a complete description for the single parameter (results_file) with context about allowed paths. Since schema coverage is 100%, the description's lack of parameter information is acceptable per guidelines. However, it adds no extra meaning beyond the schema.

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

Purpose2/5

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

The description states 'Analyzes scan results', which is a verb+resource, but it is vague. It does not specify what kind of analysis is performed (e.g., statistical, pattern detection, summary) and fails to distinguish from sibling tools like compare_results, filter_results, and export_results.

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?

There is no guidance on when to use this tool versus alternatives. No context, prerequisites, or exclusions are provided, leaving the agent without criteria for tool selection.

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