CosTrack MCP
Allows cost tracking and budget management for Google's Gemini models (2.5 Pro, 2.5 Flash, 2.0 Flash) by logging LLM calls and generating reports.
Allows cost tracking and budget management for Meta's Llama models (4 Scout, 4 Maverick) by logging LLM calls and generating reports.
Allows cost tracking and budget management for OpenAI models (GPT-4o, GPT-4 Turbo, o1) by logging LLM calls and generating reports.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@CosTrack MCPcompare costs of gpt-4o and sonnet for last month"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
CosTrack MCP — Agent Cost Control Layer
Lightweight MCP server that gives any AI agent or developer instant cost tracking, spend analysis, budget enforcement, and model cost optimization for LLM operations.
What It Does
CosTrack sits between simple price-lookup tools and full observability platforms. It's an MCP-native cost control layer — log costs, get reports, check budgets, compare models — all via tool calls.
Related MCP server: l6e-mcp
Tools
Tool | Description |
| Record a cost event for an LLM call or agent operation |
| Generate cost summary with breakdowns by model, agent, task |
| Compare costs side-by-side for models, agents, or periods |
| Check spend vs budget with end-of-period projection |
| Estimate cost for planned calls with cheaper alternatives |
| Get current pricing data for 17+ supported models |
Supported Models
Anthropic: Claude Opus 4, Opus 4.6, Sonnet 4, Sonnet 4.6, Haiku 4
OpenAI: GPT-4o, GPT-4o Mini, GPT-4 Turbo, o1, o1-mini
Google: Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 2.0 Flash
Meta: Llama 4 Scout, Llama 4 Maverick
DeepSeek: DeepSeek V3, DeepSeek R1
Model names are automatically normalized — use aliases like sonnet, gpt-4o, haiku etc.
Quick Start
Connect via Claude Desktop / Claude Code
Add to your MCP server configuration:
{
"mcpServers": {
"costrack": {
"url": "https://costrack-mcp.<your-subdomain>.workers.dev/mcp"
}
}
}Example Usage
Log a cost event:
cost_log(model: "claude-sonnet-4", input_tokens: 1500, output_tokens: 800, agent_id: "my-agent")
→ { cost_usd: 0.0165, running_session_total: 1.23 }Check budget:
budget_check(budget_usd: 100, scope: "all", period: "30d")
→ { current_spend_usd: 65.0, status: "PROJECTED_OVERAGE", projected_end_of_period_spend_usd: 130.1 }Estimate before calling:
cost_estimate(model: "claude-opus-4", estimated_input_tokens: 5000, estimated_output_tokens: 2000)
→ { cost_per_call_usd: 0.225, alternatives: [{ model: "anthropic/claude-sonnet-4", savings_percent: 90.0 }] }Features
Model Normalization —
sonnet,claude-sonnet-4,anthropic/claude-sonnet-4all resolve to the same modelIdempotency — Pass
idempotency_keyto prevent duplicate cost loggingHard Limit Signaling — Set
hard_limit_usdto get alerts when spend exceeds threshold (fail-safe, not fail-stop)Price Snapshots — Each event stores the price at time of logging; historical costs never change
Budget Projection — Predicts end-of-period spend based on daily average
Alternative Suggestions —
cost_estimaterecommends cheaper models in same capability tier
Deployment
Prerequisites
Node.js 18+
Cloudflare account with Workers enabled
Wrangler CLI (
npm install -g wrangler)
Deploy
# Install dependencies
npm install
# Login to Cloudflare
wrangler login
# Create KV namespace
wrangler kv:namespace create COSTRACK_EVENTS
# Update wrangler.toml with the returned namespace ID
# Deploy
wrangler deployLocal Development
npm run devType Check
npm run buildArchitecture
Runtime: Cloudflare Workers (TypeScript)
Storage: Hybrid — Durable Objects (real-time aggregations) + KV (raw event audit trail)
Protocol: MCP (Model Context Protocol) over Streamable HTTP
Pricing: Built-in table, single-file source of truth (
src/pricing/pricing-table.ts)
Configuration
Edit wrangler.toml to set:
COSTRACK_EVENTSKV namespace ID (Rich fills in afterwrangler kv:namespace create)Production environment variables
Project Structure
costrack-mcp/
├── src/
│ ├── tools/ # 6 tool implementations
│ ├── pricing/ # Pricing data + model aliases
│ ├── normalize/ # Model name normalization
│ ├── storage/ # Durable Object + KV + DO client
│ ├── utils/ # Cost calculator, tier check
│ ├── types/ # Shared TypeScript types
│ ├── index.ts # MCP server core
│ └── worker.ts # Cloudflare Workers entry point
├── wrangler.toml # CF Workers config
├── package.json
├── tsconfig.json
└── README.mdLicense
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceProvides 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.Last updated
- Alicense-qualityCmaintenanceEnables AI coding agents to set budgets per task, check costs before expensive operations, and halt when budget is exhausted, with support for calibration and cloud sync.Last updated4MIT
- AlicenseAqualityDmaintenanceTracks AI agent token usage and spending in real time, with budget alerts, per-task cost breakdown, and a visual dashboard.Last updated61MIT
Related MCP Connectors
See, price, and control every tool call your AI agents make: policy checks, cost, and audit tools.
Budget & cost control for AI agents — per-agent spend caps + rate limits before each call.
Agent Cost Allocator MCP — multi-tenant LLM cost attribution for chargeback billing. Companion to
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nexussquad300/costrack-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server