Skip to main content
Glama

Agent Cost MCP Server

DOI License

An MCP server that gives agents and developers tools to estimate, budget, and compare the cost of LLM work before and during a run — the model-spend counterpart to AWS infrastructure cost tooling.

Agent frameworks decide for themselves how many model calls a task takes, so the cost of a run is usually only visible after the bill arrives. This server answers, from inside your tooling:

  • What will this task cost on model A vs model B?

  • Which model is cheapest per successful task, not per token?

  • Has this run already burned its budget?

The server is self-contained: a maintained pricing snapshot ships with it, no AWS account or API key is needed, all state is a local JSON ledger, and it makes no network calls at runtime.

Demo

agent-cost-mcp-server demo

A live MCP client session (Nov 9, 2026): the client connects over stdio, lists the five tools, prices a Sonnet 4.5 run at $0.063, re-ranks models by cost per successful task, records two spends to the ledger, and checks the task against its budget — $0.0784 of $0.10 spent. Full session output and the ledger it wrote are in demo/.

Related MCP server: CosTrack MCP

Works with

  • tokenecon — this server is built on tokenecon's cost model; compare_models_for_task is its cost-per-correct ranking exposed as a tool an agent can call mid-run.

  • Argus — the enforcement counterpart: this server supplies the numbers inside MCP tooling, while Argus enforces policy and budgets at the gateway — in Argus Chat, every answer through Argus carries a tokenecon receipt.

  • mcplens — the vetting counterpart: before any MCP server is trusted, mcplens grades what it actually does against what its descriptions claim.

The connected set — one thread through all of it: what an agent did, what it cost, and whether it should have been allowed. Argus · tokenecon · mcplens · agent-cost-mcp-server · Argus Lens · PersistAIBench · Argus-Bench

Tools

Tool

Arguments

Returns

price_usage

model_id, input_tokens, output_tokens

Input/output/total cost in USD for one concrete usage record

estimate_run_cost

model_id, input_tokens, output_tokens

The model's cost for one run, plus the same workload priced on every other model, cheapest first

compare_models_for_task

input_tokens, output_tokens, success_rates?

All models ranked by expected cost per successful task (cost per attempt ÷ success rate)

record_spend

task_id, model_id, input_tokens, output_tokens

The recorded ledger entry, priced at list rates

budget_status

task_id, budget_usd

{spent_usd, remaining_usd, over_budget, calls, models_used, by_model} for the task. by_model maps each model_id to {calls, input_tokens, output_tokens, spent_usd}

Cost per token is the wrong ranking for agent work: a cheap model that fails half its tasks costs more per success than a pricier, reliable one. Pass measured success rates to compare_models_for_task if you have them; models without a supplied rate are ranked on raw cost.

This server supplies the numbers. Enforcing a budget (stopping a run) belongs to the agent framework — see BudgetedModel in strands-agents/samples for that pattern.

Installation

The server is published on PyPI (current release 0.1.1) and listed on the Official MCP Registry as io.github.karmendra8386/agent-cost-mcp-server. Requires Python 3.10+; the uvx path needs uv.

Claude Code

claude mcp add agent-cost -- uvx agent-cost-mcp-server

Claude Desktop and Cursor

Add to the client's MCP configuration (Claude Desktop: claude_desktop_config.json; Cursor: .cursor/mcp.json):

{
  "mcpServers": {
    "agent-cost": {
      "command": "uvx",
      "args": [
        "agent-cost-mcp-server"
      ]
    }
  }
}

VS Code

Add to .vscode/mcp.json (VS Code uses a servers key):

{
  "servers": {
    "agent-cost": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "agent-cost-mcp-server"
      ]
    }
  }
}

pip

pip install agent-cost-mcp-server
agent-cost-mcp-server   # serves over stdio

From source (GitHub)

If you need the unreleased tip of master rather than the PyPI release:

pip install git+https://github.com/karmendra8386/agent-cost-mcp-server
agent-cost-mcp-server   # serves over stdio

Example: what a tool call returns

compare_models_for_task for one attempt at a task using 10,000 input and 2,000 output tokens, with example success rates supplied for a few models (substitute your own measured rates; models without a supplied rate are ranked on raw cost):

{
  "input_tokens": 10000,
  "output_tokens": 2000,
  "success_rates": {
    "amazon.nova-micro": 0.2,
    "amazon.nova-lite": 0.6,
    "openai.gpt-5-nano": 0.4,
    "openai.gpt-4o-mini": 0.9,
    "anthropic.claude-haiku-3-5": 0.85,
    "anthropic.claude-sonnet-4-5": 0.95
  }
}

Response, captured from a live run of the server (pricing snapshot v1, 2026-10-20; first 5 of 18 ranked models):

{
  "input_tokens": 10000,
  "output_tokens": 2000,
  "ranked": [
    {
      "model": "amazon.nova-lite",
      "display_name": "Amazon Nova Lite",
      "cost_per_run_usd": 0.00108,
      "success_rate": 0.6,
      "cost_per_success_usd": 0.0018
    },
    {
      "model": "google.gemini-2.5-flash-lite",
      "display_name": "Gemini 2.5 Flash-Lite",
      "cost_per_run_usd": 0.0018,
      "success_rate": 1.0,
      "cost_per_success_usd": 0.0018
    },
    {
      "model": "openai.gpt-4o-mini",
      "display_name": "GPT-4o mini",
      "cost_per_run_usd": 0.0027,
      "success_rate": 0.9,
      "cost_per_success_usd": 0.003
    },
    {
      "model": "amazon.nova-micro",
      "display_name": "Amazon Nova Micro",
      "cost_per_run_usd": 0.00063,
      "success_rate": 0.2,
      "cost_per_success_usd": 0.00315
    },
    {
      "model": "openai.gpt-5-nano",
      "display_name": "GPT-5 nano",
      "cost_per_run_usd": 0.0013,
      "success_rate": 0.4,
      "cost_per_success_usd": 0.00325
    }
  ],
  "pricing_snapshot": "v1 (2026-10-20)"
}

Note the flip: Amazon Nova Micro is the cheapest model per run ($0.00063), but at a 20% success rate it ranks fourth per successful task ($0.00315 — roughly five attempts per success). Nova Lite costs 1.7× more per run and is the cheapest per success.

Pricing snapshot

Prices live in src/agent_cost_mcp_server/pricing.json — a versioned snapshot of list prices (USD per 1M tokens) for major Bedrock and OpenAI-compatible models, dated in the file. Prices change; verify against the provider's pricing page before making spending decisions. Updating the snapshot is a one-file change, and the server reads it at startup.

Ledger

record_spend appends to a local JSON ledger at ~/.agent-cost-mcp-server/ledger.json. Set AGENT_COST_LEDGER_PATH to use a different file. Nothing leaves the machine.

Background

The pricing and cost-per-success model are a port of tokenecon, an open-source library for per-task agent cost accounting (paper: doi.org/10.5281/zenodo.23195511), including a Strands integration that prices live agent runs. This server exposes the same math over MCP so any agent or IDE can call it.

Proposed for the awslabs/mcp collection in RFC #4772.

Development

uv sync --extra dev   # or: pip install -e ".[dev]"
pytest

Cite

If you use this software in your work, please cite the software itself — and, for the cost model and methods behind it, the companion preprint.

Software

@software{pandey_agent_cost_mcp_server_2026,
  author = {Pandey, Karmendra},
  title = {agent-cost-mcp-server},
  version = {0.1.1},
  doi = {10.5281/zenodo.23680824},
  url = {https://github.com/karmendra8386/agent-cost-mcp-server},
  date = {2026-10-26}
}

Companion preprint

K. Pandey, "Token-Economics for Agentic AI: A Cost Model and Tiered Routing Reference," Zenodo, DOI 10.5281/zenodo.23195511, Oct. 2026.

@misc{pandey_tokeneconomics_2026,
  author = {Pandey, Karmendra},
  title = {Token-Economics for Agentic AI: A Cost Model and Tiered Routing Reference},
  doi = {10.5281/zenodo.23195511},
  url = {https://zenodo.org/records/23195511},
  publisher = {Zenodo},
  date = {2026-10}
}

A CITATION.cff is included for automated citation tooling.

License

Apache-2.0 — see LICENSE.

Copyright 2026 Karmendra Pandey.

Available Tools

5 tools
budget_statusA

Check a task's recorded spend against a budget.

Args: task_id: The task identifier used with record_spend. budget_usd: The budget for the task, in USD.

Returns spent, remaining, call count, and whether the task is over budget. This server supplies the numbers; enforcing the budget (stopping a run) belongs to the agent framework.

Inputs: task_id (required), budget_usd (required).

compare_models_for_taskA

Rank models for a task by expected cost per successful task.

Cost per token is the wrong ranking for agent work: a cheap model that fails half its tasks costs more per success than a pricier, reliable one. Pass measured success rates (0-1 per model_id) if you have them; models without a supplied rate are ranked on raw cost.

Args: input_tokens: Input tokens for one attempt at the task. output_tokens: Output tokens for one attempt at the task. success_rates: Optional map of model_id to success rate in (0, 1].

Inputs: input_tokens (required), output_tokens (required), success_rates.

estimate_run_costB

Estimate what one run of a workload will cost on a model.

Args: model_id: Model to price the workload on. input_tokens: Expected input tokens for one run. output_tokens: Expected output tokens for one run.

Returns the model's cost plus the same workload priced on every other model in the snapshot, cheapest first.

Inputs: model_id (required), input_tokens (required), output_tokens (required).

price_usageA

Price a concrete usage record at a model's list rates.

Args: model_id: Model identifier from the pricing snapshot, e.g. "anthropic.claude-sonnet-4-5" or "openai.gpt-5-mini". input_tokens: Input (prompt) tokens consumed. output_tokens: Output (completion) tokens consumed.

Returns the input/output/total cost in USD.

Inputs: model_id (required), input_tokens (required), output_tokens (required).

record_spendA

Record a run's actual token usage in the local per-task ledger.

Args: task_id: Caller-chosen identifier grouping one task's runs. model_id: Model the run used. input_tokens: Actual input tokens consumed. output_tokens: Actual output tokens consumed.

Returns the recorded entry, priced at the model's list rates.

Inputs: task_id (required), model_id (required), input_tokens (required), output_tokens (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 5 tools

    Disambiguation4/5

    price_usage and estimate_run_cost both price input/output tokens and could be momentarily confused, but the descriptions clearly separate a concrete recorded usage from a projected single run with cross-model comparison. compare_models_for_task (success-rate ranking), record_spend (ledger write), and budget_status (ledger read) each target a distinct concern.

    Naming Consistency4/5

    Four names follow a clean verb_noun snake_case pattern (price_usage, estimate_run_cost, compare_models_for_task, record_spend). budget_status is a noun_noun query name, a minor deviation, but the set remains readable and predictable.

    Tool Count5/5

    Five tools is well-scoped for a cost estimation server: price, estimate, compare, record, and check budget. No tool is redundant and none feels like filler.

    Completeness4/5

    The pricing, projection, ranking, recording, and budget-checking lifecycle is covered, with estimate_run_cost implicitly exposing the model snapshot. Minor gaps remain: no explicit tool to list available models or model_ids, and no way to read back or clear ledger entries beyond budget_status.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides real-time AI model pricing, cost estimation, and budget management tools to help agents understand and optimize their spending. It enables agents to compare costs across multiple providers and select the most cost-effective models for specific tasks.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Estimates, compares, and controls LLM API costs before agents spend tokens, with tools for cost estimation, model comparison, and budget checking.
      58 npm
      MIT