MCP Server
The Metrx MCP Server (@metrxbot/mcp-server) exposes cost intelligence tools via the Model Context Protocol that any MCP-compatible AI agent — Claude, GPT, Gemini, or custom agents — can call to track costs, optimize models, manage budgets, and see what each agent cost against what it produced.
Version: 0.5.0 · License: MIT · npm
The server runs on two transports, published from one source: the npm package over
stdio (npx @metrxbot/mcp-server) and the hosted streamable-HTTP endpoint at
https://metrxbot.com/api/mcp. Both expose the same tool registry, so everything on
this page applies to either one.
Scopes. On both transports, every tool’s description ends with the API-key scope it needs (
read,writeoradmin), except the public tools, whose description says instead that no key is needed (or thatorg: 'me'needs areadkey). Budget changes, publishing a job contract and creating or stopping an experiment need anadmin-scoped key, which an org owner or admin mints in Settings → Security → API Keys.
Quick Start
1. Get an API key
Sign up at app.metrxbot.com and copy your key from Settings → Security.
2. Test the connection
METRX_API_KEY=sk_live_xxx npx @metrxbot/mcp-server --test3. Add to your MCP client
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"metrx": {
"command": "npx",
"args": ["@metrxbot/mcp-server"],
"env": {
"METRX_API_KEY": "sk_live_your_key_here"
}
}
}
}Cursor (.cursor/mcp.json):
{
"mcpServers": {
"metrx": {
"command": "npx",
"args": ["@metrxbot/mcp-server"],
"env": {
"METRX_API_KEY": "sk_live_your_key_here"
}
}
}
}Windsurf (~/.codeium/windsurf/mcp_config.json):
{
"mcpServers": {
"metrx": {
"command": "npx",
"args": ["@metrxbot/mcp-server"],
"env": {
"METRX_API_KEY": "sk_live_your_key_here"
}
}
}
}Hosted endpoint (no install). Clients that speak streamable HTTP can point at
https://metrxbot.com/api/mcp directly and send the API key as
Authorization: Bearer <key>. The tool list is the same as over npx.
Environment Variables
| Variable | Required | Description |
|---|---|---|
METRX_API_KEY | Yes | Your Metrx API key (sk_live_* or sk_test_*). Not needed with --demo (see below) |
METRX_API_URL | No | Override API base URL (default: https://app.metrxbot.com/api) |
METRX_TELEMETRY | No | Set to 0 to turn off the CLI’s anonymous usage telemetry |
METRX_TELEMETRY_DISABLED | No | Set to 1 to turn off telemetry (same effect as METRX_TELEMETRY=0) |
DO_NOT_TRACK | No | Set to 1 to turn off telemetry (the Console Do Not Track convention) |
Without an API key
Three tools answer with no key at all, on both transports:
metrx_get_workforce_reviewwithorg: 'demo'(the default) reads the public Northwind sample review.org: 'me'reviews your own org and needs areadkey.metrx_draft_job_contractdrafts a job contract from a template. It reads nothing and stores nothing.metrx_check_vendor_billreconciles a vendor’s per-resolution bill against the ledger lines you pass. It also reads nothing and stores nothing.
Without a key, tools/list shows only those three; with a key it shows every tool. Keyless calls are rate-limited per IP at 30 requests per minute.
Over stdio, run the same keyless mode locally:
npx @metrxbot/mcp-server --demoOn the hosted endpoint, https://metrxbot.com/api/mcp?set=workforce narrows tools/list to the manager’s-desk set: the five Workforce tools plus metrx_get_job_contract, metrx_set_job_contract, metrx_get_decision_queue and metrx_get_cost_summary. It is the only named set; without ?set you get the full registry. The manager’s desk plugin and its skills, which subscribe to that set, are documented on the Manager’s Desk page.
Tools Reference
All tools are prefixed with metrx_ in MCP (e.g., metrx_get_cost_summary).
Dashboard
metrx_get_cost_summary
Get a comprehensive cost summary for the AI agents your organization runs.
| Parameter | Type | Default | Description |
|---|---|---|---|
days | number (1–90) | 30 | Number of days to include |
Returns total spend, call counts, error rates, agent breakdown, revenue attribution, and optimization opportunities.
metrx_list_agents
List all AI agents in your organization.
| Parameter | Type | Default | Description |
|---|---|---|---|
status | active | idle | error | archived | — | Filter by status |
category | string | — | Filter by category (e.g., “sales”, “support”) |
metrx_get_agent_detail
Get detailed information about a specific agent.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | required | The agent UUID to look up |
Optimization
metrx_get_optimization_recommendations
Get AI-powered cost optimization recommendations including model switching, token guardrails, provider arbitrage, and revenue intelligence insights. Read-only: it recommends, it does not change anything. To test a model switch, record an experiment with metrx_create_model_experiment.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | — | Specific agent to analyze (omit for every agent in the organization) |
include_revenue | boolean | true | Include revenue-side insights |
Budgets
metrx_get_budget_status
Get the current status of all budget configurations. Shows spending vs limits, warning/exceeded counts, and enforcement modes.
No parameters.
metrx_set_budget
Create or update a budget configuration for an agent or the entire organization.
Requires an org owner or admin. With an API key (how the MCP server authenticates) the key must hold the admin scope; a read or write key is refused with 403. The dashboard at https://app.metrxbot.com/settings/budgets works too.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | — | Agent to set budget for (omit for org-wide) |
period | daily | monthly | required | Budget period |
limit_dollars | number | required | Spending limit in dollars |
warning_pct | integer (1–99) | 80 | Percentage that triggers a warning |
enforcement_mode | alert_only | soft_block | hard_block | alert_only | How to enforce the limit |
metrx_update_budget_mode
Change the enforcement mode of an existing budget, pause it, or ask to resume it. Requires an org owner or admin, like metrx_set_budget: the API key must hold the admin scope, and other keys are refused with 403.
| Parameter | Type | Default | Description |
|---|---|---|---|
budget_id | UUID | required | Budget configuration ID |
enforcement_mode | alert_only | soft_block | hard_block | — | New enforcement mode |
paused | boolean | — | Pause or resume the budget |
Alerts
metrx_get_alerts
Get active alerts and notifications — cost spikes, error rate increases, budget warnings, and system health notifications.
| Parameter | Type | Default | Description |
|---|---|---|---|
severity | info | warning | critical | — | Filter by severity |
unread_only | boolean | true | Only return unread alerts |
limit | integer (1–100) | 25 | Maximum alerts to return |
metrx_acknowledge_alert
Mark one or more alerts as read/acknowledged.
| Parameter | Type | Default | Description |
|---|---|---|---|
alert_ids | UUID[] (1–50) | required | Alert IDs to acknowledge |
metrx_get_failure_predictions
Predictive failure analysis for one agent, computed from its last 7 days of calls against a 30-day baseline (GET /api/agents/{agent_id}/optimization/predictions) — upcoming risk of error rate breaches, latency degradation, cost overruns, and traffic anomalies. Predictions are computed on request, not stored; fewer than 20 calls in the window returns none, which means too little data, not a healthy agent.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | required | The agent to analyze |
severity | info | warning | critical | — | Filter by severity |
Experiments
These tools call the agent-scoped routes under /api/agents/{agent_id}/experiments.
metrx_create_model_experiment
Record a draft A/B experiment comparing an agent’s current model (control) with a candidate (treatment). Creating it does not route any traffic. Needs an API key with the admin scope.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | required | Agent the experiment is for |
name | string (1–100) | required | Human-readable experiment name |
treatment_model | string | required | Candidate model (e.g., “gpt-4o-mini”) |
traffic_pct | integer (1–50) | 10 | Planned share of traffic for the treatment |
control_model | string | — | Defaults to the model the agent ran most often in the last 90 days |
description | string (≤1000) | — | Free-text description |
metrx_get_experiment_results
List an agent’s experiments with sample counts, statistical significance and the winner when decided.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | required | The agent whose experiments to list |
status | draft | running | paused | completed | cancelled | — | Filter by status |
metrx_stop_experiment
Mark an experiment completed. Results are preserved; no model is switched. Needs an API key with the admin scope (stopping an experiment is as privileged as creating one). A completed or cancelled experiment cannot be restarted.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | required | The experiment’s agent |
experiment_id | UUID | required | Experiment ID to stop |
Cost Leak Detector
metrx_run_cost_leak_scan
Run a comprehensive cost leak audit. Identifies 7 types of cost inefficiencies: idle agents, model overprovisioning, missing caching, high error rates, context bloat, missing budgets, and cross-provider arbitrage opportunities.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | — | Scan a specific agent (omit for every agent in the organization) |
include_low_severity | boolean | false | Include low-severity findings |
output_format | text | json | text | Output format (json for CI/CD pipelines) |
Attribution
metrx_attribute_task
Link an agent task/event to a business outcome for ROI tracking.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | required | Agent to attribute |
event_id | string | — | Specific event/task ID |
outcome_type | revenue | cost_saving | efficiency | quality | required | Type of outcome |
outcome_source | stripe | calendly | hubspot | zendesk | webhook | manual | required | Source of the outcome data |
value_cents | integer | — | Outcome value in cents |
description | string | — | Description of the outcome |
metrx_get_task_roi
Calculate return on investment for an agent — total costs, total outcomes, ROI multiplier, and breakdown by model and outcome type.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | required | Agent to calculate ROI for |
days | integer (1–365) | 30 | Number of days to analyze |
metrx_get_attribution_report
Get an attribution report showing which agent actions led to business outcomes.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | UUID | — | Filter to specific agent |
days | integer (1–365) | 30 | Number of days to include |
model | direct | last_touch | first_touch | direct | Attribution model |
ROI Audit
metrx_generate_roi_audit
Generate a comprehensive ROI audit report for every agent in your organization. Includes per-agent cost/revenue breakdown, attribution confidence scores, optimization opportunities, and risk flags. Suitable for board reporting and compliance.
| Parameter | Type | Default | Description |
|---|---|---|---|
days | integer (7–365) | 30 | Analysis period |
include_methodology | boolean | true | Include methodology notes for auditors |
agent_ids | UUID[] | — | Specific agents (omit for every agent) |
Upgrade Justification
metrx_get_upgrade_justification
Generate an ROI report explaining why paying for Metrx makes sense based on current usage. Analyzes usage and optimization potential, then recommends Verify (a buyable per-verdict proof; no verdict, no charge) and Platform (priced to your managed LLM spend). Legacy Lite/Pro tiers are retired and never recommended.
| Parameter | Type | Default | Description |
|---|---|---|---|
days | integer (7–90) | 30 | Days to analyze |
Upgrade Business Case
metrx_get_upgrade_business_case
Generate a personalized ROI business case for paying for Metrx. Uses real usage data to quantify optimization potential, then recommends Verify and Platform (legacy Lite/Pro tiers are retired and never recommended). Ideal for agents that received a 402 and want a proposal for their operator. Returns structured data plus a report.
The savings estimate, ROI multiplier (x) and payback period are null when
the org has no current savings estimate; savings_unavailable_reason then says
why. A missing estimate is never reported as $0.
| Parameter | Type | Default | Description |
|---|---|---|---|
current_tier | starter | lite | pro | required | Current subscription tier |
monthly_spend | number | — | Known monthly LLM spend in cents |
agent_count | integer | — | Number of active agents |
primary_use_case | customer_support | data_processing | content_generation | code_assistant | — | Primary use case |
Health & Rankings
metrx_get_health_scores
Health score, grade, and data completeness for every agent in the organization. Scores are composite 0–100 values blending cost efficiency, ROI, error rate, quality drift, failure risk, and latency. Grades: A (80–100), B (60–79), C (40–59), D (20–39), F (0–19).
Takes no parameters.
metrx_get_rankings
Agents ranked by composite health score (0–1), with grade, data completeness and stale-score flags, plus an organization-wide average over agents that have data (GET /api/v1/agents/rankings). Use it to find top and bottom performers.
Takes no parameters.
Verify Billing
A verification is a causal verdict on whether a model switch holds quality on your own production traffic. The unit noun is “verification”. No verdict, no charge.
metrx_get_balance
How many verifications your organization has remaining. Free to call. Use it before metrx_verify_switch to know whether a purchase is needed first.
Takes no parameters.
metrx_buy_verification
Purchase one verification. Returns a Stripe checkout URL for a human (or payment-capable agent) to complete, plus claim instructions when the purchase is anonymous. This tool does not charge anything itself — payment happens on the returned URL.
| Parameter | Type | Default | Description |
|---|---|---|---|
callback_url | string (URL) | — | Optional post-checkout redirect base URL |
metrx_verify_switch
Start a purchased verification: would candidate_model hold quality against prod_model on your production traffic? Async — returns a request handle immediately and never blocks; verdicts complete after enough of your own traffic accrues. Poll GET /api/verify/requests/{id}. If the balance is 0 this returns purchase guidance instead of spending.
| Parameter | Type | Default | Description |
|---|---|---|---|
prod_model | string | required | Current production model |
candidate_model | string | required | Candidate model to verify against it |
agent_id | UUID | — | Agent to scope the verification to |
policy_id | UUID | — | Routing policy to attach to |
Loop Metrics
These tools return measured-value envelopes: every numeric leaf is
{value, ci_low, ci_high, method, data_through}. CI fields are populated only
where the source payload carries a real confidence interval — never fabricated.
Raw counts use method: "count".
metrx_get_signal_readiness
Org-scoped signal-readiness diagnostics — per-agent event coverage, label lag, join rate, volume-vs-power (days to trial-ready at current volume), estimator eligibility with reasons, and blocked-on-signal proposals cross-linked to the failing readiness dimension: what still stands between the org and its first verified verdict.
Takes no parameters.
metrx_get_dashboard_headline
The three-number headline regime: measured spend, estimated savings, and
verified savings-with-CI — each with basis, provenance, and tone. Values are
micro-dollars (dollars = value / 1e6). Requires the optimization_model_v3
flag; while it is off the tool returns a clear next-step error.
The attributed_savings number is the engine’s stored savings estimate
(definition v2, per model slice, capped at measured spend) with
tone: 'estimate' and method stored_savings_total_v2_estimate. It is null
when the org has no current estimate; treat null as unknown, never $0.
| Parameter | Type | Default | Description |
|---|---|---|---|
days | 7 | 30 | 90 | 30 | Window in days |
metrx_get_report_snapshot
Fetch one frozen executive-report snapshot by its public share token (the token
is the capability). Returns the stored snapshot only — never recomputed — plus
its snapshot_hash and methodology_version integrity stamps.
| Parameter | Type | Default | Description |
|---|---|---|---|
share_token | string (16–64 hex) | required | The report share token |
metrx_get_verdicts
Org-scoped current causal-verdict summaries — per (agent, prod model,
candidate model, task category): verdict, evidence mode/regime, pair counts,
non-inferiority, savings CI, judge model, expiry. Observational (:value) rows
are flagged. Summaries only: no gate flags and no evidence-pack contents (those
remain dashboard-session-only). Read-only twin route (/api/loop-views/verdicts).
Takes no parameters.
metrx_get_trials
Org-scoped pre-registered trial plans: regime, primary metric, margin, the frozen sample plan (pre-registration), models, status (registered/concluded/voided) and the concluding verdict id. Read-only.
Takes no parameters.
metrx_get_proposals
Org-scoped current candidate proposals: action type/class, D-class, status
with blocked_reason, estimated impact, taxonomy axes. Config payloads
(config_diff, guardrails, rollback mechanics) are deliberately excluded.
Read-only.
Takes no parameters.
metrx_get_actuations
Org-scoped policy actuation records: action class, authority, actor and timing,
rollback state with reason, acknowledgement state. Config contents are
excluded. Requires the optimization_model_v3 flag (404 while off). Read-only.
Takes no parameters.
metrx_get_decision_queue
The operator decision queue, derived from real loop objects (approvable
verdicts, blocked proposals, breaker events, expiring evidence). Read-only:
approve/snooze/acknowledge actions remain dashboard-session-only and are not
exposed to API-key callers. Requires the optimization_model_v3 flag.
Takes no parameters.
metrx_kb_prior_lookup
Per-cell (task verb × domain) summary of your own org’s current causal
verdicts — the knowledge-base read side, v0. Strictly org-local: it never reads
another org’s data, so a zero means your org has no stamped verdicts in that
cell yet (unstamped_verdicts counts evidence that predates the taxonomy). Per
cell: verdict counts by evidence mode (holdout_confirmed is the causal tier),
observational (:value) counts, and the latest verdict summary with its
savings CI. Allocation labels are deliberately absent in v0 — there is no
cost-weight data to compute them from, so none are invented. If the org has
more verdicts than the read bound, the response says it is truncated.
Read-only twin route (/api/loop-views/kb-priors); needs the read scope.
Takes no parameters.
Job Contracts
A job contract is the per-agent statement of what the agent is for, what one unit of work is, what counts as acceptable, and what it may spend. Versions are append-only: publishing a new one supersedes the previous active version for the same workload. The contract is recorded, not enforced at runtime; nothing blocks spend or traffic on it.
metrx_get_job_contract
Read an agent’s job contract: its current version per workload (objective, unit of work, acceptance criteria, KPI target, budget, owner) and the full version history. An agent with no contract returns an explicit empty state with the next action. Read-only.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_key | string | required | The agent_key (the X-Agent-ID string), not the UUID |
metrx_set_job_contract
Publish a new version of an agent’s job contract. Needs an API key with the admin scope; any other key is refused with 403. Workload-policy terms are inherited from the current version unless supplied in policy_terms. For an agent with no version yet, set policy_defaults.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_key | string | required | The agent_key (the X-Agent-ID string), not the UUID |
workload | string | required | Workload label the contract governs (e.g. extraction) |
objective | string | required | What this agent is for, in your words |
unit_of_work | string | required | The countable output (e.g. “one DDQ reviewed”) |
acceptance_criteria | object[] (1–20) | required | Each: metric, op (>=, >, <=, <, ==), threshold, window |
kpi_target | object | required | The number the agent is held to over a rolling window |
budget_dollars | number | required | Declared spend limit in dollars per period (recorded, not enforced; stored as micro-dollars) |
budget_period | daily | weekly | monthly | required | Budget period |
owner | string | required | User id or email accountable for this agent |
notes | string | — | Optional note recorded on this version |
policy_terms | object | — | Optional workload-policy terms (unit, eligible_traffic, primary_quality, permitted_actions, task_verb, domain, …). Omit to inherit |
policy_defaults | inherit_workload_policy | observe_only | — | First version only: inherit_workload_policy copies the org’s workload-level policy (refused when none exists); observe_only grants no authority and needs task_verb and domain in policy_terms |
Workforce (manager’s desk)
The Workforce tools read your AI agents the way a line manager reads a team: what each one’s job is, what it cost, what it produced, and what decision that calls for. Three of them are public (no API key needed); the plugin and skills built on this set are documented on the Manager’s Desk page.
metrx_get_workforce_review (public)
The weekly workforce review: every AI agent in the org as a line manager would read it (job, cost this window, outcomes, scorecard state, the candidate decision and why). org: 'demo' reads the public Northwind sample and needs no key; org: 'me' reads your own org and needs an API key with the read scope. Paged by cursor. Numbers are the same the review page shows.
| Parameter | Type | Default | Description |
|---|---|---|---|
org | demo | me | demo | Which org to review |
cursor | string | — | Next page: the cursor the previous page returned |
limit | integer (1–100) | 25 | Agents per page |
metrx_get_scorecard
One agent’s scorecard against its job contract: each acceptance criterion, the measured value, pass/fail, and the window it covers. Windows longer than your plan keeps are reported as insufficient, never shortened.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_key | string | required | The agent_key you registered (not the row id) |
metrx_draft_job_contract (public)
Draft a job contract for an AI agent from a template: objective, unit of work, acceptance criteria, budget, and the human baseline for ROI. Returns the body to publish plus validation errors and warnings. A pure function over your input: reads nothing, stores nothing, needs no key. Publishing the draft is a separate step (metrx_set_job_contract, admin scope).
| Parameter | Type | Default | Description |
|---|---|---|---|
template | support_triage | sdr_qualification | internal_assistant | coding_patch | required | Which job template to start from |
owner | string | required | The person accountable for this agent (name or email) |
agent_key | string | — | The agent the contract will be published for (informational) |
workload | string | — | Defaults to agent_key, else the template key |
objective | string | — | Override the template’s objective |
unit_of_work | string | — | What one unit is, e.g. “resolved ticket” |
budget_usd | number | — | Budget in dollars per period |
budget_period | daily | weekly | monthly | — | Budget period |
human_baseline | object | — | What the same unit costs when a person does it (needed for ROI) |
notes | string | — | Free-text note |
metrx_check_vendor_bill (public)
Reconcile an AI vendor’s per-resolution bill against your own records: which billed units your ledger shows as resolved, rejected, reopened, outside coverage, or unknown, and the disputed amount. A pure function over the lines you pass: reads nothing, stores nothing, needs no key.
| Parameter | Type | Default | Description |
|---|---|---|---|
period | object | required | The billing period (from < to) |
billed | object[] | required | The vendor’s bill lines: id, external_id, billed_at, cost_usd, tier_name |
resolved_ids | string[] | — | External ids your records show as resolved by the agent |
rejected_ids | string[] | — | External ids your records show as rejected (a person overturned it) |
ledger | object[] | — | Your ledger events: external_id, event_type (solved, closed, reopened, public_comment), occurred_at |
import_rejected_count | integer | 0 | Bill lines your import rejected before the check; echoed in the summary, and a nonzero value marks the result as withheld |
covered_spans | object[] | — | The spans your records cover (from, to); omitted means nothing is covered |
metrx_record_decision
Record a management decision about an agent (expand, re_specify, combine, retire) with a rationale. The record carries the governing contract version and the scorecard at decision time as evidence, and appears on the agent page. The same decision within 60 seconds is refused as a double submit; pass idempotency_key to make a retry return the first record. Needs an API key with the write scope.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_key | string | required | The agent the decision is about |
decision | expand | re_specify | combine | retire | required | The decision |
rationale | string (≥20 chars) | required | Why; stored on the record and shown on the agent page |
combined_into_agent_id | UUID | null | — | For combine only: the agent (row id) this one folds into |
idempotency_key | string | — | Retrying with the same key returns the first record instead of a second |
Guided Prompts
MCP prompts are interactive templates that walk agents through multi-step workflows. Use them from any MCP-compatible client.
analyze-costs
Step-by-step cost analysis: fetches cost summary → lists agents → gets optimization recommendations → returns a prioritized breakdown.
| Argument | Type | Description |
|---|---|---|
days | string (optional) | Number of days to analyze (default: “30”) |
find-savings
Discovers optimization opportunities: checks recommendations → runs cost leak scan → explains savings in dollars.
No arguments.
cost-leak-scan
Runs the 7-check waste audit: retry storms, oversized contexts, model mismatch, missing caching, idle agents, missing budgets, and arbitrage gaps.
| Argument | Type | Description |
|---|---|---|
agent_id | string (optional) | Scan a specific agent by UUID, or omit to scan all |
Rate Limiting
The stdio server enforces per-category rate limits (dashboard and agents 60 per minute, metrics 30, experiments, budgets, alerts and attribution 10, optimization 5, cost-leak scan 2 per 5 minutes, every other tool 30). The window is shared by all tools in a category. Hitting it returns an isError text result that names the tool and the seconds to wait. Keyless calls to the public tools are limited separately, per IP, at 30 requests per minute; a Metrx API key is not affected by that limit.
Error Handling
All tools return standardized error responses:
{
"content": [{ "type": "text", "text": "Error message" }],
"isError": true
}| Status | Meaning | Fix |
|---|---|---|
| 401 | Invalid or expired API key | Regenerate key |
| 403 | The key lacks the scope this tool needs | The error names the missing scope; mint a key with it in Settings → Security → API Keys |
| 404 | Resource not found | Use metrx_list_agents to get valid IDs |
| 429 | Rate limited | Wait the number of seconds the refusal names |
| 5xx | Server error | Retry with backoff |
Since 0.5.0 every refusal also carries a class, the same on both transports. Over MCP it is a JSON-RPC error whose data holds class, doc (the anchor on the Manager’s Desk page), user_message and, per class, retry_after_seconds, suggestions, fields or required_scope. Over the public HTTP routes it is an RFC 9457 problem body with the same facts.
| Class | JSON-RPC code | HTTP | Carries |
|---|---|---|---|
auth_required | -32001 | 401 | |
insufficient_scope | -32002 | 403 | required_scope |
rate_limited | -32003 | 429 | retry_after_seconds |
limiter_unavailable | -32004 | 503 | Retry-After header only |
demo_unavailable | -32005 | 503 | retry_after_seconds |
unknown_agent_key | -32006 | 404 | suggestions |
invalid_params | -32602 | 400 | fields |
transport_error | -32007 | 502 | |
review_unavailable | -32008 | 503 | retry_after_seconds |
Each class is explained, with its recovery, at /desk#errors.
Troubleshooting
“METRX_API_KEY not set” — Set the environment variable before starting:
export METRX_API_KEY=sk_live_your_key
npx @metrxbot/mcp-server“Rate limit exceeded” — Your calls filled the tool category’s window (60, 30, 10, 5 or 2 per window, see Rate Limiting above). The MCP client will retry automatically.
“Agent not found” — The agent_id doesn’t exist. Run metrx_list_agents to get valid IDs.
Connection test fails — Run npx @metrxbot/mcp-server --test to verify your API key and network connectivity.