Skip to main content
Glama
ekamal22
by ekamal22

model-cost-mcp

A small MCP server that lets an AI agent answer "which model should I use, and what will it cost?" for image, video, audio and 3D generation, with prices that are exact and errors the agent can recover from.

The catalog is sample data: the models and prices are invented for the demo. It is not affiliated with any provider. Replace src/catalog.ts with a real catalog before relying on the numbers.

Tools

Tool

What it does

list_models

Lists models with billing unit, price and a "use when" note. Filter by modality or maximum unit price.

estimate_cost

Exact cost of one job on one model. Handles per-image, per-second and per-run pricing.

compare_models

Ranks every model of one modality, cheapest first, and lists the ones it had to skip, with reasons.

Related MCP server: CloudCost MCP Server

Design choices

  • Money is integers. Prices are stored in millionths of a dollar, so there is no floating-point drift. The billed amount rounds the exact cost up to the next whole cent, so any surface that computes from the same inputs shows the same number.

  • Per-second models bill every started second, and the response says when it rounded.

  • Errors tell the agent what to do next. An invalid call returns a code, a message, a hint with an example call, and for unknown model ids the closest valid ids. Nothing throws an opaque exception.

  • Tool descriptions are written for model selection. Each says when to call it and what it needs, and every catalog entry carries a use_when line.

Run

npm install
npm test          # 9 tests, in-memory MCP client against the real server
npm run typecheck
npm start         # stdio server

Add it to an MCP client such as Claude Desktop:

{
  "mcpServers": {
    "model-cost": {
      "command": "npx",
      "args": ["tsx", "/absolute/path/to/model-cost-mcp/src/index.ts"]
    }
  }
}

Example

estimate_cost { "model_id": "demo/video-draft", "quantity": 3, "seconds": 4.2 }
-> 3 clips x 5s = 15 billable seconds, exact $0.750000, billed $0.75
   note: "Every started second is billed, so 4.2s is billed as 5s."

estimate_cost { "model_id": "demo/video-cinema", "quantity": 2 }
-> error seconds_required
   hint: Call again with seconds, for example {"model_id": "demo/video-cinema", "quantity": 2, "seconds": 5}.

Not done yet

  • The catalog is a hard-coded list, not a live source.

  • stdio only; no HTTP transport or authentication.

  • No currency conversion, taxes or volume discounts.

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
    A
    maintenance
    Enables AI agents to parse multi-cloud infrastructure-as-code files, query real-time pricing from AWS, Azure, and GCP, and generate cost estimates and comparison reports.
    111 npm
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables assistants to access up-to-date LLM pricing, context windows, and model identifiers, with tools to estimate costs, find cheapest models, and check scheduled price changes.
    30 npm
    MIT