Skip to content

RFC: Agent cost MCP server — estimate, budget, and compare LLM spend per task #4772

Open

Description

@karmendra8386

Is this related to an existing feature request or issue?

No matching proposal found. Related existing servers: aws-pricing-mcp-server
and billing-cost-management-mcp-server cover AWS infrastructure pricing
and billing. Neither covers model spend — what LLM calls cost per task —
which is the gap this proposal fills.

Summary

I'd like to propose a new MCP server, agent-cost-mcp-server, that gives
agents and developers tools to estimate, budget, and compare the cost of LLM
work before and during a run:

  • estimate_run_cost — price an expected workload (model, input/output
    tokens) across models.
  • compare_models_for_task — rank models for a task profile by cost per
    successful task, not just cost per token.
  • record_spend / budget_status — keep a local per-task ledger: record a
    run's actual token usage, and check spend against a budget the caller sets.
  • price_usage — price a concrete usage record (as reported by a provider)
    under a given model's rates.

The server is self-contained: a maintained pricing snapshot ships with it, no
AWS account or API key is needed, and all state is local.

Use case

Agent frameworks decide for themselves how many model calls a task takes, so
the cost of a run is only visible after the bill arrives. Developers building
agents today cannot ask basic questions from inside their tooling: What will
this task cost on model A vs model B? Which model is cheapest per successful
outcome, not per token? Has this run already burned its budget?

AWS Cost Explorer and the AWS Pricing API answer these questions for
infrastructure. Nothing in this repo answers them for model spend, which for
agent workloads is often the larger and less predictable bill.

Proposal

Add src/agent-cost-mcp-server/ following the repo's existing server layout
(FastMCP, uv, README with tool reference, tests). Tools:

  1. estimate_run_cost(model_id, input_tokens, output_tokens) →
    {model, cost_usd} plus the same estimate for comparable models.
  2. compare_models_for_task(input_tokens, output_tokens, success_rates?) →
    models ranked by expected cost per successful task.
  3. record_spend(task_id, model_id, input_tokens, output_tokens) → appends
    to a local JSON ledger and returns the priced cost.
  4. budget_status(task_id, budget_usd) → {spent_usd, remaining_usd, calls} for the task.

Pricing data ships as a versioned JSON snapshot in the server (major Bedrock
and OpenAI-compatible models), documented so contributors can update it the
way other servers update their data files. No network calls at runtime.

I maintain tokenecon, an open-source
library for per-task agent cost accounting (paper:
https://doi.org/10.5281/zenodo.23195511), including a Strands integration that
prices live agent runs. The server's pricing and cost-per-success model would
be a port of that work, contributed under this repo's license and conventions.

Out of scope

  • AWS infrastructure pricing/billing (already covered by
    aws-pricing-mcp-server and billing-cost-management-mcp-server).
  • Enforcing budgets inside an agent loop (that belongs in the agent
    framework; this server supplies the numbers).
  • Hosted/multi-user ledger storage — the ledger is a local file by design.

Alternatives considered

  • Extending billing-cost-management-mcp-server: its domain is the AWS bill;
    model-spend tooling would blur both servers' scope.
  • No server, documentation only: the numbers change too often and need to be
    callable from agent tooling, not read from a page.

Activity

  1. karmendra8386 commented on Oct 20, 2026

    @karmendra8386
    Author

    Update: I've built the reference implementation proposed here and published it as a standalone repo: https://github.com/karmendra8386/agent-cost-mcp-server

    It implements the five tools from the RFC (estimate_run_cost, compare_models_for_task, record_spend, budget_status, price_usage) on top of tokenecon's pricing model, with a local JSON ledger and a versioned pricing snapshot — no AWS account or API key needed, no network calls at runtime. Tests are green (9/9).

    Happy to adapt the layout to this repo's server conventions (src/agent-cost-mcp-server/, uv, FastMCP) and open a PR here if the maintainers would like it contributed directly — or keep it standalone if you prefer it as an external reference implementation. Either way, feedback on the tool surface is welcome.

  2. karmendra8386 commented on Oct 20, 2026

    @karmendra8386
    Author

    Update: the agent-cost MCP server is now also submitted in-tree as #4807, following this repo's server layout and conventions (five tools from the RFC, versioned pricing snapshot, local ledger, 18 tests at 99% coverage). Happy to iterate on review feedback — tool surface, pricing snapshot format, or layout. The standalone repo (https://github.com/karmendra8386/agent-cost-mcp-server) remains as the reference implementation named in this RFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions