Labsco
metrxbots logo

Metrx MCP Server

โ˜… 1

from metrxbots

Track AI agent costs, detect waste, optimize models, and prove ROI. 23 MCP tools for LLM cost tracking, provider arbitrage, budget enforcement, and revenue attribution.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredNeeds API keys

Metrx MCP Server

Smithery Glama

Your AI agents are wasting money. Metrx finds out how much, and fixes it.

The official MCP server for Metrx โ€” the AI Agent Cost Intelligence Platform. Give any MCP-compatible agent (Claude, GPT, Gemini, Cursor, Windsurf) the ability to track its own costs, detect waste, optimize model selection, and prove ROI.

Metrx Server MCP server

Why Metrx?

ProblemWhat Metrx Does
No visibility into agent spendReal-time cost dashboards per agent, model, and provider
Overpaying for LLM callsProvider arbitrage finds cheaper models for the same task
Runaway costsBudget enforcement with auto-pause when limits are hit
Wasted tokensCost leak scanner detects retry storms, context bloat, model mismatch
Can't prove AI ROIRevenue attribution links agent actions to business outcomes

23 Tools Across 10 Domains

Dashboard (3 tools)

ToolDescription
metrx_get_cost_summaryComprehensive cost summary โ€” total spend, call counts, error rates, and optimization opportunities
metrx_list_agentsList all agents with status, category, cost metrics, and health indicators
metrx_get_agent_detailDetailed agent info including model, framework, cost breakdown, and performance history

Optimization (4 tools)

ToolDescription
metrx_get_optimization_recommendationsAI-powered cost optimization recommendations per agent or fleet-wide
metrx_apply_optimizationOne-click apply an optimization recommendation to an agent
metrx_route_modelModel routing recommendation for a specific task based on complexity
metrx_compare_modelsCompare LLM model pricing and capabilities across providers

Budgets (3 tools)

ToolDescription
metrx_get_budget_statusCurrent status of all budget configurations with spend vs. limits
metrx_set_budgetCreate or update a budget with hard, soft, or monitor enforcement
metrx_update_budget_modeChange enforcement mode of an existing budget or pause/resume it

Alerts (3 tools)

ToolDescription
metrx_get_alertsActive alerts and notifications for your agent fleet
metrx_acknowledge_alertMark one or more alerts as read/acknowledged
metrx_get_failure_predictionsPredictive failure analysis โ€” identify agents likely to fail before it happens

Experiments (3 tools)

ToolDescription
metrx_create_model_experimentStart an A/B test comparing two LLM models with traffic splitting
metrx_get_experiment_resultsStatistical significance, cost delta, and recommended action
metrx_stop_experimentStop a running model routing experiment and lock in the winner

Cost Leak Detector (1 tool)

ToolDescription
metrx_run_cost_leak_scanComprehensive 7-check cost leak audit across your entire agent fleet

Attribution (3 tools)

ToolDescription
metrx_attribute_taskLink agent actions to business outcomes for ROI tracking
metrx_get_task_roiCalculate return on investment for an agent โ€” costs vs. attributed outcomes
metrx_get_attribution_reportMulti-source attribution report with confidence scores and top contributors

Alert Configuration (1 tool)

ToolDescription
metrx_configure_alert_thresholdSet cost or operational alert thresholds with email, webhook, or auto-pause

ROI Audit (1 tool)

ToolDescription
metrx_generate_roi_auditBoard-ready ROI audit report for your AI agent fleet

Upgrade Justification (1 tool)

ToolDescription
metrx_get_upgrade_justificationROI report for tier upgrades based on current usage patterns

Prompts

Pre-built prompt templates for common workflows:

PromptDescription
analyze-costsComprehensive cost overview โ€” spend breakdown, top agents, optimization opportunities
find-savingsDiscover optimization opportunities โ€” model downgrades, caching, routing
cost-leak-scanScan for waste patterns โ€” retry storms, oversized contexts, model mismatch

Examples

"How much am I spending?"

User: What was my AI cost this week?
โ†’ metrx_get_cost_summary(period_days=7)

Total Spend: $234.56 | Calls: 2,450 | Error Rate: 0.2%
โ”œโ”€โ”€ customer-support: $156.23 (1,800 calls)
โ””โ”€โ”€ code-generator: $78.33 (650 calls)

๐Ÿ’ก Switch customer-support from GPT-4 to Claude Sonnet: Save $42/week

"Find me savings"

User: Am I overpaying for my agents?
โ†’ metrx_compare_models(models=["gpt-4o", "claude-3-5-sonnet", "gemini-1.5-pro"])

Model Comparison (per 1M tokens):
โ”œโ”€โ”€ gpt-4o: $2.50 in / $10.00 out
โ”œโ”€โ”€ claude-3-5-sonnet: $3.00 in / $15.00 out
โ””โ”€โ”€ gemini-1.5-pro: $3.50 in / $10.50 out

"Test a cheaper model"

User: Test Claude 3.5 Sonnet against my GPT-4 setup
โ†’ metrx_create_model_experiment(agent_id="agent_123",
    model_a="gpt-4o", model_b="claude-3-5-sonnet-20241022", traffic_split=10)

Experiment started: 90% GPT-4o, 10% Claude 3.5 Sonnet
Check back in 14 days for statistical significance.

Companion Tool: Cost Leak Detector

This repo also includes @metrxbot/cost-leak-detector โ€” a free, offline CLI that scans your LLM API logs for wasted spend. No signup, no cloud, no data leaves your machine.

npx @metrxbot/cost-leak-detector demo

It runs 7 checks (idle agents, premium model overuse, missing caching, high error rates, context overflow, no budgets, arbitrage opportunities) and gives you a scored report in seconds. See the full docs.

Rate Limiting

60 requests per minute per tool. For higher limits, contact support@metrxbot.com.

Development

git clone https://github.com/metrxbots/mcp-server.git
cd mcp-server
npm install
npm run typecheck
npm test

A Note on Naming

The product is Metrx (metrxbot.com). The npm scope is @metrxbot and the Smithery listing is metrxbot/mcp-server. The GitHub organization is metrxbots (with an s) because metrxbot was already taken on GitHub. If you see metrxbot vs metrxbots across platforms, they're the same project โ€” just a GitHub namespace constraint.

๐Ÿ’ฌ Feedback

Did Metrx work for you? We'd love to hear it โ€” good or bad.

If you installed but hit a snag, tell us what happened โ€” we read every report.