Repository navigation
RFC: Agent cost MCP server — estimate, budget, and compare LLM spend per task #4772
Description
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:
estimate_run_cost(model_id, input_tokens, output_tokens)→
{model, cost_usd}plus the same estimate for comparable models.compare_models_for_task(input_tokens, output_tokens, success_rates?)→
models ranked by expected cost per successful task.record_spend(task_id, model_id, input_tokens, output_tokens)→ appends
to a local JSON ledger and returns the priced cost.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-serverandbilling-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.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTo triage
Activity
karmendra8386 commentedon Oct 20, 2026
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.
karmendra8386 commentedon Oct 20, 2026
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.