Skip to main content
Glama

export_results

Export Semgrep scan results to JSON, SARIF, or text format for integration with other tools and reporting systems.

Instructions

Exports scan results in various formats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
results_fileYesAbsolute path to JSON results file
output_fileYesAbsolute path to output file
formatNoOutput format (json, sarif, text)text

Implementation Reference

  • src/index.ts:339-355 (registration)
    Tool registration/definition for 'export_results' - declares the tool name, description, and input schema (results_file, output_file, format) in the ListToolsRequestSchema handler.
    {
      name: 'export_results',
      description: 'Exports scan results in various formats',
      inputSchema: {
        type: 'object',
        properties: {
          results_file: { type: 'string', description: 'Absolute path to JSON results file' },
          output_file: { type: 'string', description: 'Absolute path to output file' },
          format: {
            type: 'string',
            description: 'Output format (json, sarif, text)',
            default: 'text'
          }
        },
        required: ['results_file', 'output_file']
      }
    },
  • Case routing in CallToolRequestSchema switch statement that dispatches 'export_results' to handleExportResults.
    case 'export_results':
      return await this.handleExportResults(request.params.arguments);
  • The handleExportResults method - the core handler that reads a JSON results file, formats it (json/sarif/text), and writes the output to a specified file.
    private async handleExportResults(args: any) {
      if (!args.results_file || !args.output_file) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'results_file and output_file are required'
        );
      }
    
      const resultsFile = validateAbsolutePath(args.results_file, 'results_file');
      const outputFile = validateAbsolutePath(args.output_file, 'output_file');
      const format = args.format || 'text';
    
      try {
        const fileContent = await readFile(resultsFile, 'utf-8');
        const results = parseSemgrepResults(fileContent);
        const findings = getSemgrepFindings(results);
    
        let output = '';
        switch (format) {
        case 'json':
          output = JSON.stringify(results, null, 2);
          break;
        case 'sarif': {
          const sarifOutput = {
            $schema: 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json',
            version: '2.1.0',
            runs: [{
              tool: {
                driver: {
                  name: 'semgrep',
                  rules: findings.map((r: any) => ({
                    id: r.check_id,
                    name: r.check_id,
                    shortDescription: { text: r.extra?.message ?? '' },
                    defaultConfiguration: {
                      level: r.extra?.severity === 'ERROR' ? 'error' : 'warning'
                    }
                  }))
                }
              },
              results: findings.map((r: any) => ({
                ruleId: r.check_id,
                message: { text: r.extra?.message ?? '' },
                locations: [{
                  physicalLocation: {
                    artifactLocation: { uri: r.path },
                    region: {
                      startLine: r.start?.line,
                      startColumn: r.start?.col,
                      endLine: r.end?.line,
                      endColumn: r.end?.col
                    }
                  }
                }]
              }))
            }]
          };
          output = JSON.stringify(sarifOutput, null, 2);
          break;
        }
        case 'text':
        default:
          output = findings.map((r: any) =>
            `[${r.extra?.severity ?? 'unknown'}] ${r.check_id}\n` +
            `File: ${r.path}\n` +
            `Lines: ${r.start?.line}-${r.end?.line}\n` +
            `Message: ${r.extra?.message ?? ''}\n` +
            '-------------------'
          ).join('\n');
          break;
        }
    
        await writeFile(outputFile, output, 'utf-8');
        return {
          content: [{ type: 'text', text: `Results successfully exported to ${outputFile}` }]
        };
      } catch (error: any) {
        return {
          content: [{ type: 'text', text: `Error exporting results: ${error.message}` }],
          isError: true
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It fails to mention whether the tool overwrites existing files, requires network access, or produces any side effects. The agent cannot infer safety or error conditions from the description alone.

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 structure. It does not front-load critical information like required parameters or output behavior. The brevity is acceptable but not optimal for usability.

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 no output schema, the description should indicate what the tool returns (e.g., success message, file path). It also does not mention error handling or performance implications. The tool is simple, but the description remains incomplete for fully autonomous invocation.

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?

All 3 parameters are described in the schema with high coverage (100%). The description adds no extra context beyond 'exports scan results in various formats'—it does not elaborate on parameter constraints like valid file paths or format specifics. Baseline 3 is appropriate since schema does the work.

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 'Exports scan results in various formats' clearly indicates the action (export) and resource (scan results) and mentions format variability. However, it does not differentiate from sibling tools like analyze_results or compare_results, which might also output results. The description could be more specific about the exact nature of the export.

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 are no mentions of prerequisites or context in which export is appropriate. The agent is left without decision support.

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