# AI API Cost Calculator

> AI API Cost Calculator is an open-source MCP server for ai models and llm tooling. Estimates OpenAI, Claude and Gemini API costs, margins and break-even price for SaaS. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, API, macOS, Windows, Linux
- **Website:** https://aisaaswithmustafa.com/tools/ai-api-cost-calculator.html
- **Repository:** https://github.com/m-mustufa/mustafa-portfolio/tree/HEAD/mcp/ai-api-cost-mcp
- **MCP Registry name:** io.github.m-mustufa/ai-api-cost-mcp
- **Categories:** [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm)
- **Listing updated:** 2026-11-27

## About

Planning a model budget for an AI feature usually means juggling token rates, cache assumptions and subscription revenue in a spreadsheet. This server lets an AI assistant run those numbers directly, returning monthly token spend, cost per request, gross margin and the price needed to break even.

It works from the same rate table and formulas as the companion web calculator, so answers match what a visitor would see in the browser. Each workload can start from a preset for chat, support, summarizing or document processing, and any value such as user count, token volume or fixed overhead can be overridden. Responses state which numbers came from the preset.

It suits founders and developers pricing an AI add-on, comparing providers before committing to one, or checking whether a usage-based plan stays profitable. Results cover token cost only, not output quality or latency.

## Features

- **Monthly cost estimation:** Calculates total token spend per month from users, requests and input and output token counts.
- **Cross-provider comparison:** Runs one workload against every model or a single provider and ranks them by monthly cost.
- **Margin and break-even:** Shows gross profit, margin, break-even price per user and break-even user count.
- **Cached input handling:** Prices uncached input, cached input and output tokens separately.
- **Workload presets:** Starts from chat, support, summarizer or documents presets that can be overridden field by field.
- **Custom rate overrides:** Accepts your own per-million token rates when a provider's pricing differs from the table.

## Good for

- Estimating the monthly API bill for an AI chat feature before launch
- Comparing OpenAI, Claude and Gemini costs for the same support bot workload
- Setting a subscription price that keeps gross margin above a target
- Checking how many users a plan can support before token costs erode profit

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add ai-api-cost-mcp -- npx -y ai-api-cost-mcp
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add ai-api-cost-mcp -- npx -y ai-api-cost-mcp
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.ai-api-cost-mcp]
command = "npx"
args = ["-y", "ai-api-cost-mcp"]
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Or run: gemini mcp add -s user ai-api-cost-mcp npx -- -y ai-api-cost-mcp

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "ai-api-cost-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "ai-api-cost-mcp"
      ]
    }
  }
}
```

## Tools

From the tool list in its README, going by the names, 1 of 3 tools reads data; 2 names don't say. From the server's own tool labels and tool names; not verified by us.

- `list_models` (name suggests: reads): Current rates per million input, cached input and output tokens for each model, with official pricing sources.
- `estimate_cost`: Full monthly estimate for one model or custom rates, including cost breakdown, margin and break-even.
- `compare_models`: Runs one workload against every model or one provider and ranks them by monthly API cost.

## FAQ

### Does AI API Cost Calculator need an API key from the model providers?

No. It performs local calculations on the rate table and does not call provider APIs.

### Can I work offline?

Yes. Setting AI_API_COST_MCP_OFFLINE to 1 skips the live rates download and uses only the bundled rates.

### Which clients can use AI API Cost Calculator?

Installation examples are given for Claude Desktop, Claude Code and Cursor, using npx to run the npm package.

### Are the results billing guarantees?

No. They are planning estimates covering token cost only.

### How do I add AI API Cost Calculator to Claude Code?

Run this command in your terminal: claude mcp add ai-api-cost-mcp -- npx -y ai-api-cost-mcp

### What are the best alternatives to AI API Cost Calculator?

The closest alternatives to AI API Cost Calculator are AI Rate Card, ComparEdge LLM Cost, Ai Economics, LLM API Pricing and Automation Tools by shurco.ai and AI-Cost-CLI.

## Where this comes from

- Description: written from the project's README, the project's website and its MCP Registry entry.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [AI Rate Card](https://ai-powered.com/mcp/ai-rate-card): AI Rate Card is a free MCP server for ai models and llm tooling.
- [ComparEdge LLM Cost](https://ai-powered.com/mcp/comparedge-llm-cost): ComparEdge LLM Cost is an open-source MCP server for ai models and llm tooling.
- [Ai Economics](https://ai-powered.com/mcp/ai-economics): Ai Economics is an open-source MCP server for ai models and llm tooling.
- [LLM API Pricing and Automation Tools by shurco.ai](https://ai-powered.com/mcp/llm-api-pricing-and-automation-tools-by-shurco-ai): LLM API Pricing and Automation Tools by shurco.ai is a free MCP server for ai models and llm tooling.
- [AI-Cost-CLI](https://ai-powered.com/mcp/ai-cost-cli): AI-Cost-CLI is an open-source MCP server for design and media.
- [AICostBudget AI API Pricing](https://ai-powered.com/mcp/aicostbudget-ai-api-pricing): AICostBudget AI API Pricing is a free MCP server for ai models and llm tooling.
- [AI Price Index](https://ai-powered.com/mcp/ai-price-index): AI Price Index is an open-source MCP server for ai models and llm tooling.
- [Kingy AI Facts](https://ai-powered.com/mcp/kingy-ai-facts): Kingy AI Facts is a free MCP server for ai models and llm tooling.

---
Source: https://ai-powered.com/mcp/ai-api-cost-calculator
