Skip to main content
Glama

apply_fixes

Execute package upgrade commands to fix CVEs by modifying package files. Always confirm with users after reviewing commands first.

Instructions

Execute package upgrade commands to fix CVEs. IMPORTANT: This is a DESTRUCTIVE action that modifies package files. ALWAYS call get_fix_commands first and confirm with the user before calling this. Returns the command output for each fix applied.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the project directory.
packagesYesPackage names to fix. Must be explicit — never fix all without user confirmation.
dry_runNoIf true, print commands without executing. Useful for final confirmation step.

Implementation Reference

  • The handler function 'handleApplyFixes' which executes the upgrade commands.
    async function handleApplyFixes({ path: dir = '.', packages, dry_run = false }) {
      const absDir = resolve(dir);
      const result = await scanService(absDir, { noOsv: false });
    
      const fixable = getFixableGroups(result.vulns, packages);
      const requested = packages.map(p => p.toLowerCase());
      const toApply = fixable.filter(f => requested.includes(f.name.toLowerCase()));
    
      if (toApply.length === 0) {
        return err(`No fix commands found for: ${packages.join(', ')}. Run get_fix_commands to see available fixes.`);
      }
    
      const outputs = [];
    
      for (const f of toApply) {
        if (dry_run) {
          outputs.push(`[DRY RUN] Would run: ${f.command}`);
          continue;
        }
    
        try {
          const stdout = execSync(f.command, { cwd: absDir, timeout: 60000 }).toString().trim();
          outputs.push(`✅ ${f.name}: upgraded to ${f.fixVersion} (fixes ${f.cveCount} CVE${f.cveCount > 1 ? 's' : ''})\n   $ ${f.command}\n   ${stdout.slice(0, 200)}`);
        } catch (e) {
          outputs.push(`❌ ${f.name}: command failed\n   $ ${f.command}\n   ${e.message.slice(0, 200)}`);
        }
      }
    
      const summary = dry_run
        ? `## Dry run — commands that would be executed\n\n${outputs.join('\n\n')}`
        : `## Fix results\n\n${outputs.join('\n\n')}\n\n> Run \`scan_project\` again to verify CVEs are resolved.`;
    
      return ok(summary);
    }
  • MCP tool definition for 'apply_fixes'.
    name: 'apply_fixes',
    description:
      'Execute package upgrade commands to fix CVEs. ' +
      'IMPORTANT: This is a DESTRUCTIVE action that modifies package files. ' +
      'ALWAYS call get_fix_commands first and confirm with the user before calling this. ' +
      'Returns the command output for each fix applied.',
  • Tool call dispatch logic invoking 'handleApplyFixes'.
    case 'apply_fixes': return await handleApplyFixes(args);
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. It explicitly states this is a 'DESTRUCTIVE action that modifies package files,' which is crucial for a mutation tool. It also describes the return behavior ('Returns the command output for each fix applied') and includes a safety note about user confirmation.

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

Conciseness5/5

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

The description is front-loaded with the core purpose, followed by critical warnings and usage guidelines. Every sentence adds value: the first states the action, the second highlights destructiveness and prerequisites, and the third explains the return. There is no wasted text.

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

Completeness4/5

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

For a destructive tool with no annotations and no output schema, the description is largely complete: it covers purpose, behavioral risks, usage workflow, and return format. However, it could slightly enhance completeness by mentioning potential side effects (e.g., system downtime) or error handling, though the current level is adequate given the schema coverage.

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?

Schema description coverage is 100%, so the schema already documents all parameters. The description does not add specific meaning beyond the schema (e.g., it doesn't elaborate on 'path' or 'packages' formats). However, it reinforces the importance of explicit packages ('Must be explicit — never fix all without user confirmation'), which aligns with but doesn't exceed schema guidance.

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 specific action ('Execute package upgrade commands') and resource ('to fix CVEs'), distinguishing it from siblings like 'get_fix_commands' (which only retrieves commands) and 'scan_project' (which only identifies issues). It goes beyond the tool name 'apply_fixes' by specifying the exact mechanism.

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?

Explicit guidance is provided: 'ALWAYS call get_fix_commands first and confirm with the user before calling this.' This directly addresses when to use this tool versus the sibling 'get_fix_commands' and includes a prerequisite workflow. The description also implies when not to use it (e.g., without confirmation).

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/toan203/osv-ui'

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