Skip to main content
Glama
metrxbots

Metrx MCP Server

by metrxbots

Get Upgrade Justification

metrx_get_upgrade_justification
Read-onlyIdempotent

Generate ROI reports to justify upgrading from Free to paid tiers by analyzing usage patterns, calculating optimization potential, and projecting monthly savings.

Instructions

Generate an ROI report explaining why an upgrade from Free to Lite/Pro tier makes sense. Analyzes current usage patterns, calculates optimization potential at higher tiers, and provides a structured upgrade recommendation with projected monthly savings. Do NOT use if already on Lite or Pro tier — not relevant for paid users.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
period_daysNoNumber of days to analyze for upgrade justification (default: 30)

Implementation Reference

  • The main handler function for metrx_get_upgrade_justification that fetches dashboard data, handles errors, and returns the formatted justification report.
      async ({ period_days }) => {
        // Get dashboard summary for the period
        const result = await client.get<DashboardSummary>('/dashboard', {
          period_days: period_days ?? 30,
        });
    
        if (result.error) {
          return {
            content: [{ type: 'text', text: `Error fetching upgrade data: ${result.error}` }],
            isError: true,
          };
        }
    
        const data = result.data!;
        const text = formatUpgradeJustification(data, period_days ?? 30);
    
        return {
          content: [{ type: 'text', text }],
        };
      }
    );
  • Main tool registration and handler function. The tool is registered as 'get_upgrade_justification' and includes the async handler that fetches dashboard data and formats it as an upgrade justification report.
    export function registerUpgradeJustificationTools(server: McpServer, client: MetrxApiClient): void {
      // ── get_upgrade_justification ──
      server.registerTool(
        'get_upgrade_justification',
        {
          title: 'Get Upgrade Justification',
          description:
            'Generate an ROI report explaining why an upgrade from Free to Lite/Pro tier makes sense. ' +
            'Analyzes current usage patterns, calculates optimization potential at higher tiers, ' +
            'and provides a structured upgrade recommendation with projected monthly savings. ' +
            'Do NOT use if already on Lite or Pro tier — not relevant for paid users.',
          inputSchema: {
            period_days: z
              .number()
              .int()
              .min(7)
              .max(90)
              .default(30)
              .describe('Number of days to analyze for upgrade justification (default: 30)'),
          },
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
          },
        },
        async ({ period_days }) => {
          // Get dashboard summary for the period
          const result = await client.get<DashboardSummary>('/dashboard', {
            period_days: period_days ?? 30,
          });
    
          if (result.error) {
            return {
              content: [{ type: 'text', text: `Error fetching upgrade data: ${result.error}` }],
              isError: true,
            };
          }
    
          const data = result.data!;
          const text = formatUpgradeJustification(data, period_days ?? 30);
    
          return {
            content: [{ type: 'text', text }],
          };
        }
      );
    }
  • Input schema definition using zod for the tool. Validates the period_days parameter (number, integer, 7-90 range, default 30).
      period_days: z
        .number()
        .int()
        .min(7)
        .max(90)
        .default(30)
        .describe('Number of days to analyze for upgrade justification (default: 30)'),
    },
  • Tool registration with schema definition including input validation (period_days), tool metadata, and the handler implementation.
    server.registerTool(
      'get_upgrade_justification',
      {
        title: 'Get Upgrade Justification',
        description:
          'Generate an ROI report explaining why an upgrade from Free to Lite/Pro tier makes sense. ' +
          'Analyzes current usage patterns, calculates optimization potential at higher tiers, ' +
          'and provides a structured upgrade recommendation with projected monthly savings. ' +
          'Do NOT use if already on Lite or Pro tier — not relevant for paid users.',
        inputSchema: {
          period_days: z
            .number()
            .int()
            .min(7)
            .max(90)
            .default(30)
            .describe('Number of days to analyze for upgrade justification (default: 30)'),
        },
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ period_days }) => {
        // Get dashboard summary for the period
        const result = await client.get<DashboardSummary>('/dashboard', {
          period_days: period_days ?? 30,
        });
    
        if (result.error) {
          return {
            content: [{ type: 'text', text: `Error fetching upgrade data: ${result.error}` }],
            isError: true,
          };
        }
    
        const data = result.data!;
        const text = formatUpgradeJustification(data, period_days ?? 30);
    
        return {
          content: [{ type: 'text', text }],
        };
      }
    );
  • Helper function formatUpgradeJustification that transforms dashboard data into a structured upgrade justification report with ROI projections, tier comparisons, and recommendations.
    function formatUpgradeJustification(summary: DashboardSummary, periodDays: number): string {
      const lines: string[] = ['## Upgrade Justification Report', ''];
    
      // Current tier (assumed Free if no optimization data)
      lines.push('### Current Status');
      lines.push(`**Analysis Period**: Last ${periodDays} days`);
      lines.push(`**Current Tier**: Free`);
      lines.push(`**Active Agents**: ${summary.agents.active} / ${summary.agents.total}`);
      lines.push(`**Total LLM Calls**: ${summary.cost.total_calls.toLocaleString()}`);
      lines.push(`**Current Monthly Cost**: ${formatCents(summary.cost.total_cost_cents)}`);
      lines.push(`**Error Rate**: ${formatPct(summary.cost.error_rate)}`);
      lines.push('');
    
      // Optimization potential (available in Free tier but limited)
      const currentSavings = summary.optimization?.total_savings_cents || 0;
      const currentSavingsMontly = (currentSavings / periodDays) * 30;
    
      lines.push('### Optimization Potential');
      lines.push(
        `**Available Optimizations**: ${summary.optimization?.suggestion_count || 0} suggestions`
      );
      lines.push(
        `**Identified Monthly Savings**: ${formatCents(currentSavingsMontly)} (without upgrade)`
      );
      lines.push('');
    
      // Tier comparison and upgrade benefits
      lines.push('### Upgrade Benefits (Lite Tier)');
      lines.push('The Lite tier includes:');
      lines.push('- Advanced optimization recommendations (10x more suggestions)');
      lines.push('- Real-time failure prediction');
      lines.push('- Model routing experiments');
      lines.push('- Revenue attribution (if enabled)');
      lines.push('- Priority API rate limits (300 req/min vs 30)');
      lines.push('');
    
      // Calculate projected ROI
      const monthlyCost = (summary.cost.total_cost_cents / periodDays) * 30;
      const liteTierPrice = 29900; // $299/month in cents
      const upgratedSavings = currentSavingsMontly * 1.5; // Estimate 50% more optimization with Lite
    
      lines.push('### ROI Projection');
      lines.push(`**Projected Monthly LLM Cost**: ${formatCents(monthlyCost)}`);
      lines.push(`**Lite Tier Subscription**: ${formatCents(liteTierPrice)}`);
      lines.push(`**Additional Savings with Lite**: ${formatCents(upgratedSavings)}`);
      lines.push('');
    
      const netBenefit = upgratedSavings - (liteTierPrice - (currentSavingsMontly / 100) * 100000); // simplified calculation
      const breakEven =
        netBenefit > 0
          ? 'Upgrade pays for itself immediately'
          : `Breakeven in ${Math.ceil((liteTierPrice / upgratedSavings) * 30)} days`;
    
      lines.push('### Recommendation');
      if (summary.cost.total_calls > 100000) {
        lines.push(
          `🟢 **Strongly Recommended**: Your volume (${summary.cost.total_calls.toLocaleString()} calls) qualifies for Lite tier.`
        );
        lines.push(`${breakEven}`);
        if (summary.optimization && summary.optimization.suggestion_count > 5) {
          lines.push(
            `You have ${summary.optimization.suggestion_count} active optimization opportunities that Lite tier can fully leverage.`
          );
        }
      } else if (summary.cost.total_calls > 50000) {
        lines.push(`🟡 **Consider Lite**: Your volume is growing and you have optimization potential.`);
        lines.push(
          'Upgrade once you hit 100k calls/month or if you need real-time failure prediction.'
        );
      } else {
        lines.push(`⚠️ **Not Yet Recommended**: Free tier is sufficient for your current volume.`);
        lines.push('Revisit this when you reach 50,000+ calls per month.');
      }
    
      lines.push('');
      lines.push('---');
      lines.push(
        '*Run `get_cost_summary` periodically to track growth and identify when upgrade becomes beneficial.*'
      );
    
      return lines.join('\n');
    }
  • Helper function that formats the upgrade justification report, calculating ROI, tier comparisons, and generating recommendations based on usage patterns.
    function formatUpgradeJustification(summary: DashboardSummary, periodDays: number): string {
      const lines: string[] = ['## Upgrade Justification Report', ''];
    
      // Current tier (assumed Free if no optimization data)
      lines.push('### Current Status');
      lines.push(`**Analysis Period**: Last ${periodDays} days`);
      lines.push(`**Current Tier**: Free`);
      lines.push(`**Active Agents**: ${summary.agents.active} / ${summary.agents.total}`);
      lines.push(`**Total LLM Calls**: ${summary.cost.total_calls.toLocaleString()}`);
      lines.push(`**Current Monthly Cost**: ${formatCents(summary.cost.total_cost_cents)}`);
      lines.push(`**Error Rate**: ${formatPct(summary.cost.error_rate)}`);
      lines.push('');
    
      // Optimization potential (available in Free tier but limited)
      const currentSavings = summary.optimization?.total_savings_cents || 0;
      const currentSavingsMontly = (currentSavings / periodDays) * 30;
    
      lines.push('### Optimization Potential');
      lines.push(
        `**Available Optimizations**: ${summary.optimization?.suggestion_count || 0} suggestions`
      );
      lines.push(
        `**Identified Monthly Savings**: ${formatCents(currentSavingsMontly)} (without upgrade)`
      );
      lines.push('');
    
      // Tier comparison and upgrade benefits
      lines.push('### Upgrade Benefits (Lite Tier)');
      lines.push('The Lite tier includes:');
      lines.push('- Advanced optimization recommendations (10x more suggestions)');
      lines.push('- Real-time failure prediction');
      lines.push('- Model routing experiments');
      lines.push('- Revenue attribution (if enabled)');
      lines.push('- Priority API rate limits (300 req/min vs 30)');
      lines.push('');
    
      // Calculate projected ROI
      const monthlyCost = (summary.cost.total_cost_cents / periodDays) * 30;
      const liteTierPrice = 29900; // $299/month in cents
      const upgratedSavings = currentSavingsMontly * 1.5; // Estimate 50% more optimization with Lite
    
      lines.push('### ROI Projection');
      lines.push(`**Projected Monthly LLM Cost**: ${formatCents(monthlyCost)}`);
      lines.push(`**Lite Tier Subscription**: ${formatCents(liteTierPrice)}`);
      lines.push(`**Additional Savings with Lite**: ${formatCents(upgratedSavings)}`);
      lines.push('');
    
      const netBenefit = upgratedSavings - (liteTierPrice - (currentSavingsMontly / 100) * 100000); // simplified calculation
      const breakEven =
        netBenefit > 0
          ? 'Upgrade pays for itself immediately'
          : `Breakeven in ${Math.ceil((liteTierPrice / upgratedSavings) * 30)} days`;
    
      lines.push('### Recommendation');
      if (summary.cost.total_calls > 100000) {
        lines.push(
          `🟢 **Strongly Recommended**: Your volume (${summary.cost.total_calls.toLocaleString()} calls) qualifies for Lite tier.`
        );
        lines.push(`${breakEven}`);
        if (summary.optimization && summary.optimization.suggestion_count > 5) {
          lines.push(
            `You have ${summary.optimization.suggestion_count} active optimization opportunities that Lite tier can fully leverage.`
          );
        }
      } else if (summary.cost.total_calls > 50000) {
        lines.push(`🟡 **Consider Lite**: Your volume is growing and you have optimization potential.`);
        lines.push(
          'Upgrade once you hit 100k calls/month or if you need real-time failure prediction.'
        );
      } else {
        lines.push(`⚠️ **Not Yet Recommended**: Free tier is sufficient for your current volume.`);
        lines.push('Revisit this when you reach 50,000+ calls per month.');
      }
    
      lines.push('');
      lines.push('---');
      lines.push(
        '*Run `get_cost_summary` periodically to track growth and identify when upgrade becomes beneficial.*'
      );
    
      return lines.join('\n');
    }
  • Type definition for DashboardSummary which is the primary data structure used by the upgrade justification tool to analyze cost, agents, and optimization potential.
    export interface DashboardSummary {
      is_preview: boolean;
      stage: string;
      period_days: number;
      agents: { total: number; active: number };
      agents_list: AgentSummary[];
      cost: {
        total_calls: number;
        total_cost_cents: number;
        error_calls: number;
        error_rate: number;
      };
      attribution?: {
        total_outcomes: number;
        total_revenue_cents: number;
        net_value_cents: number;
        roi_multiplier: number;
      };
      optimization?: {
        total_savings_cents: number;
        suggestion_count: number;
        top_suggestion?: string;
      };
    }
  • Call to registerUpgradeJustificationTools in the server factory, which registers all tools including the upgrade justification tool.
    registerUpgradeJustificationTools(server, apiClient);
  • src/index.ts:44-44 (registration)
    Import statement that brings in the registerUpgradeJustificationTools function.
    import { registerUpgradeJustificationTools } from './tools/upgrade-justification.js';
  • The wrapper that adds the 'metrx_' prefix to all tool names, transforming 'get_upgrade_justification' to 'metrx_get_upgrade_justification'.
    // Register with metrx_ prefix (primary name only — no deprecated aliases)
    const prefixedName = name.startsWith(METRX_PREFIX) ? name : `${METRX_PREFIX}${name}`;
    originalRegisterTool(prefixedName, config, wrappedHandler);
  • src/index.ts:113-113 (registration)
    Call to registerUpgradeJustificationTools that registers the tool with the MCP server and applies the 'metrx_' namespace prefix.
    registerUpgradeJustificationTools(server, apiClient);
Behavior4/5

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

The description adds valuable behavioral context beyond annotations: it specifies the tool generates an ROI report with analysis of usage patterns, optimization calculations, and structured recommendations. Annotations already indicate it's read-only, non-destructive, and idempotent, so the description doesn't contradict them but enriches understanding of what the tool produces.

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 concise and front-loaded, stating the core purpose in the first sentence, followed by key analyses and a critical usage restriction. Every sentence adds value without redundancy, making it efficient for an AI agent to parse.

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?

Given the tool's complexity (analysis and reporting) and lack of an output schema, the description provides good context on what the tool does and when to use it. However, it doesn't detail the report format or output structure, which could be helpful for an agent expecting specific data. Annotations cover safety aspects well.

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 description does not mention the 'period_days' parameter, but the input schema has 100% description coverage, providing a clear default and range. With only one parameter well-documented in the schema, the description's lack of parameter details is acceptable, aligning with the baseline score for high schema coverage.

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's purpose with specific verbs ('Generate an ROI report', 'Analyzes current usage patterns', 'calculates optimization potential', 'provides a structured upgrade recommendation') and resources ('upgrade from Free to Lite/Pro tier'). It distinguishes from siblings by focusing on upgrade justification rather than other analytics or management functions.

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?

The description provides explicit usage guidance with 'Do NOT use if already on Lite or Pro tier — not relevant for paid users,' establishing clear exclusion criteria. It implicitly suggests this is for Free-tier users considering upgrades, though it doesn't name specific alternative tools for paid users.

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/metrxbots/metrx-mcp-server'

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