Skip to main content
Glama

upgrade_planner

Prioritize dependency upgrades by analyzing CVE severity, deprecation, and version distance to reduce security risks and technical debt.

Instructions

Ranked upgrade recommendations — prioritized by CVE severity, deprecation, version distance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function that executes the upgrade_planner tool logic. Fetches dependency data from live intelligence, checks vulnerabilities, deprecation, and version distance, then produces a ranked list of upgrade recommendations.
    export async function executeUpgradePlanner(
      _db: FourDADatabase,
      params: UpgradePlannerParams,
      liveIntel: LiveIntelligence | null,
    ): Promise<UpgradePlanResult> {
      if (!liveIntel || !liveIntel.isInitialized()) {
        return {
          generatedAt: new Date().toISOString(),
          projectPath: process.cwd(),
          totalDeps: 0,
          recommendations: [],
          summary: "No project detected. Run from a directory with package.json, Cargo.toml, pyproject.toml, or go.mod.",
          quickWins: 0,
          breakingChanges: 0,
        };
      }
    
      const includeDev = params.include_dev ?? false;
      let deps = liveIntel.getResolvedDeps();
      if (!includeDev) deps = deps.filter((d) => !d.isDev);
    
      // Fetch registry data
      const registryData = await liveIntel.fetchRegistryHealth(deps);
    
      // Get vulnerability data
      const vulnResult = liveIntel.getVulnerabilities();
      const vulnsByPackage = new Map<string, Array<{ severity: string; vulnId: string; summary: string; fixedVersion: string | null }>>();
      if (vulnResult) {
        for (const v of vulnResult.vulnerabilities) {
          if (!vulnsByPackage.has(v.package)) vulnsByPackage.set(v.package, []);
          vulnsByPackage.get(v.package)!.push({
            severity: v.severity,
            vulnId: v.vulnId,
            summary: v.summary,
            fixedVersion: v.fixedVersion,
          });
        }
      }
    
      // Build recommendations
      const recommendations: UpgradeRecommendation[] = [];
    
      for (const dep of registryData) {
        const reasons: string[] = [];
        let risk: UpgradeRecommendation["risk"] = "low";
        let targetVersion = dep.latestStableVersion || dep.latestVersion;
    
        // Check vulnerabilities
        const vulns = vulnsByPackage.get(dep.name);
        if (vulns && vulns.length > 0) {
          const hasCritical = vulns.some((v) => v.severity === "critical");
          const hasHigh = vulns.some((v) => v.severity === "high");
          if (hasCritical) risk = "critical";
          else if (hasHigh) risk = "high";
          else risk = "medium";
    
          reasons.push(`${vulns.length} known CVE${vulns.length !== 1 ? "s" : ""} (${vulns.map((v) => v.vulnId).join(", ")})`);
    
          // Use fixed version as target if available
          const fixedVersions = vulns.map((v) => v.fixedVersion).filter(Boolean);
          if (fixedVersions.length > 0 && !targetVersion) {
            targetVersion = fixedVersions[0];
          }
        }
    
        // Check deprecation
        if (dep.deprecated) {
          if (risk === "low") risk = "high";
          reasons.push(dep.deprecationMessage ? `Deprecated: ${dep.deprecationMessage}` : "Package is deprecated");
        }
    
        // Check version distance
        if (dep.versionsBehind) {
          const d = dep.versionsBehind;
          if (d.label === "major") {
            reasons.push(`${d.major} major version${d.major !== 1 ? "s" : ""} behind`);
            if (risk === "low") risk = "medium";
          } else if (d.label === "minor") {
            reasons.push(`${d.minor} minor version${d.minor !== 1 ? "s" : ""} behind`);
          } else if (d.label === "patch") {
            reasons.push(`${d.patch} patch${d.patch !== 1 ? "es" : ""} behind`);
          }
        }
    
        // Skip if no upgrade needed
        if (reasons.length === 0) continue;
        if (dep.versionsBehind?.label === "up-to-date" && !dep.deprecated && !vulns) continue;
    
        const label = dep.versionsBehind?.label;
        const upgradeType: UpgradeRecommendation["upgradeType"] =
          !label || label === "up-to-date" ? "patch" : label;
    
        recommendations.push({
          package: dep.name,
          ecosystem: dep.ecosystem,
          currentVersion: dep.currentVersion,
          targetVersion,
          upgradeType,
          risk,
          reasons,
          breaking: dep.versionsBehind?.label === "major",
          isDev: dep.isDev,
        });
      }
    
      // Filter by risk threshold
      const riskLevels: Record<string, number> = { low: 0, medium: 1, high: 2, critical: 3 };
      const threshold = params.risk_threshold ?? "all";
      const filtered = threshold === "all"
        ? recommendations
        : recommendations.filter((r) => riskLevels[r.risk] >= riskLevels[threshold]);
    
      // Sort: critical > high > medium > low, then by breaking (non-breaking first for quick wins)
      filtered.sort((a, b) => {
        const riskDiff = riskLevels[b.risk] - riskLevels[a.risk];
        if (riskDiff !== 0) return riskDiff;
        if (a.breaking !== b.breaking) return a.breaking ? 1 : -1;
        return 0;
      });
    
      const maxRecs = params.max_recommendations ?? 20;
      const limited = filtered.slice(0, maxRecs);
      const quickWins = limited.filter((r) => !r.breaking).length;
      const breakingChanges = limited.filter((r) => r.breaking).length;
    
      // Summary
      const parts: string[] = [];
      parts.push(`${limited.length} upgrade${limited.length !== 1 ? "s" : ""} recommended`);
      if (quickWins > 0) parts.push(`${quickWins} quick win${quickWins !== 1 ? "s" : ""} (patch/minor)`);
      if (breakingChanges > 0) parts.push(`${breakingChanges} breaking change${breakingChanges !== 1 ? "s" : ""} (major)`);
      const criticalCount = limited.filter((r) => r.risk === "critical").length;
      if (criticalCount > 0) parts.push(`${criticalCount} critical`);
    
      return {
        generatedAt: new Date().toISOString(),
        projectPath: process.cwd(),
        totalDeps: deps.length,
        recommendations: limited,
        summary: parts.join(". ") + ".",
        quickWins,
        breakingChanges,
      };
    }
  • Type definitions for input parameters (UpgradePlannerParams), individual recommendations (UpgradeRecommendation), and the overall result (UpgradePlanResult).
    export interface UpgradePlannerParams {
      include_dev?: boolean;
      max_recommendations?: number;
      risk_threshold?: "all" | "low" | "medium" | "high" | "critical";
    }
    
    interface UpgradeRecommendation {
      package: string;
      ecosystem: string;
      currentVersion: string | null;
      targetVersion: string | null;
      upgradeType: "patch" | "minor" | "major" | "unknown";
      risk: "low" | "medium" | "high" | "critical";
      reasons: string[];
      breaking: boolean;
      isDev: boolean;
    }
    
    interface UpgradePlanResult {
      generatedAt: string;
      projectPath: string;
      totalDeps: number;
      recommendations: UpgradeRecommendation[];
      summary: string;
      quickWins: number;
      breakingChanges: number;
    }
  • JSON Schema definition for the tool, including name, description, and input schema with properties for include_dev, max_recommendations, and risk_threshold.
    export const upgradePlannerTool = {
      name: "upgrade_planner",
      description:
        "Ranked upgrade recommendations for dependencies. Prioritizes by vulnerability severity, deprecation, and version distance. Shows quick wins (patch/minor) vs breaking changes (major).",
      inputSchema: {
        type: "object" as const,
        properties: {
          include_dev: {
            type: "boolean",
            description: "Include devDependencies. Default: false",
          },
          max_recommendations: {
            type: "number",
            description: "Max recommendations to return. Default: 20",
          },
          risk_threshold: {
            type: "string",
            enum: ["all", "low", "medium", "high", "critical"],
            description: "Only show upgrades at or above this risk level. Default: all",
          },
        },
      },
    };
  • Re-exports the tool definition and executor from the tools barrel module.
    export {
      upgradePlannerTool,
      executeUpgradePlanner,
    } from "./upgrade-planner.js";
  • Dispatch registration mapping the tool name 'upgrade_planner' to its executor function with live intelligence.
    upgrade_planner: (db, params) => executeUpgradePlanner(db, params, getLiveIntelligence()),
Behavior3/5

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

No annotations provided, so description must carry the burden. It mentions the prioritization criteria but lacks details on whether it is read-only, rate limits, or expected output format. Adequate but not comprehensive.

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?

Single sentence that is front-loaded with the core purpose. Every word adds value; no redundancy.

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 has no parameters and no output schema, the description is minimal but covers the basic purpose. However, it lacks context on expected output or how to use the recommendations effectively.

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 tool has zero parameters, and the schema has 100% coverage. With no parameters, the baseline is 4, and the description does not need to add param info.

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 provides 'ranked upgrade recommendations' with specific prioritization criteria (CVE severity, deprecation, version distance), which differentiates it from siblings like vulnerability_scan and dependency_health.

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 on when to use this tool over siblings or when not to use it. The description only states what it does without explicit usage 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/runyourempire/4DA'

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