LLM Pricing MCP Server
Provides pricing data and cost estimation for Google LLM models, and can audit codebases for Google LLM SDK call sites.
Provides pricing data, cost estimation, and usage tracking for OpenAI models. Can use OpenAI GPT-4o-mini as the LLM backend for its conversational agent, and offers an OpenAI-compatible proxy endpoint for drop-in SDK integration.
Integrates with Stripe for SaaS billing, enabling paid tier subscriptions via Stripe Checkout, a self-serve customer portal, and webhook handling for subscription updates.
Click on "Deploy 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., "@LLM Pricing MCP Serverwhich is cheaper for 1M tokens: GPT-4o or Claude Sonnet?"
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.
LLM Pricing MCP Server
Most LLM pricing tools are a static lookup table. This one checks its own numbers against a live, independently-maintained price registry and tells you when they disagree, routes to a model by cost and quality instead of just quoting a price, and tracks what you actually spent — not just what you might. All of that is backed by a RESTful API (FastAPI), 29 MCP tools over STDIO and HTTP, a conversational Agent + RAG pipeline, browser-based UIs, and a self-serve billing dashboard, for pricing data from 26 major LLM providers.
Live at: https://llm-pricing-api.fly.dev
Why this one
Prices you can verify, not just trust —
check_price_driftandget_data_qualitycompare every curated price against a live external registry and withhold (never silently serve) anything that's drifted more than 5%, with a singleconfirmed_pcttrust score for the whole catalogue.Routes, doesn't just quote —
recommend_modelandoptimize_workloadpick a model by cost and quality for your actual task, flagging it when a cheaper pick trades away quality rather than silently recommending it.Tracks what you spent, not just what you might —
record_usage,analyze_session_usage, andimport_session_usagerecord and analyze real spend, including backfilling a coding-agent session that wasn't instrumented to track usage live.More than an MCP server — the same pricing engine also powers a REST API, browser UIs (calculator, side-by-side comparison, history/trends), and a self-serve billing dashboard.
Related MCP server: AgentCost MCP Server
Features
MCP Interface (STDIO + HTTP)
29 MCP Tools:
get_all_pricing,estimate_cost,compare_costs,predict_cost,optimize_workload,recommend_model,check_price_drift,get_data_quality,get_performance_metrics,get_use_cases,get_ide_pricing,get_telemetry,get_pricing_history,get_pricing_trends,register_price_alert,list_price_alerts,delete_price_alert,get_pricing_export_url,list_conversations,delete_conversation,ask_agent,record_usage,get_usage_summary,register_budget_alert,list_budget_alerts,delete_budget_alert,get_cache_stats,analyze_session_usage,import_session_usageSTDIO transport — JSON-RPC 2.0 over STDIO for local Claude Desktop integration
HTTP transport —
POST /mcp(JSON-RPC 2.0 over HTTP) for remote MCP clients — no local install neededMCP Protocol version:
2024-11-05
RESTful API
Real-time pricing from 26 providers (150+ models), async fetching with smart caching
Cost estimation: single model (
POST /cost-estimate) and batch comparison (POST /cost-estimate/batch)Performance metrics, use-case recommendations, pricing history, trends
Router recommendation (
POST /router/recommend) with feedback loop;GET /cache-statsreports process-lifetime hit/miss stats for its ~5-minute recommendation cacheActual usage/spend tracking (
POST /usage,GET /usage/summary) — the real-cost counterpart to/cost-estimate; tag events withsession_idand analyze one session on demand (GET /usage/session/{session_id}) for a grounded recommendation with estimated savingsOpenAI-compatible proxy (
POST /v1/chat/completions) for drop-in SDK integrationWebhook alerts for price changes and budget-spend thresholds (
POST /usage/alerts, HMAC-SHA256 signed)Interactive docs:
/docs(Swagger) and/redoc
Repo Cost Auditor (scripts/audit_repo.py)
Statically scans a Python codebase for LLM SDK call sites (OpenAI, Anthropic, Google, LangChain), no credentials or network calls to your code required
Estimates per-call-site cost using the same pricing data and token math as
predict_costRecommends cheaper models, prompt caching, Batch API (for calls in a loop or an offline-looking path), and task-based right-sizing (flagship model on a simple task) — plus flags the same prompt duplicated across call sites — see
python scripts/audit_repo.py --helpStatic estimates only (assumes a configurable calls/month) — pair with
POST /usage's actual recorded spend once deployed for real numbers
AI-Native SDLC Pipeline (/release-feature, for contributors using Claude Code)
Runs a feature request through dedicated phase agents instead of one agent doing everything at once: Spec → Design → Code → Review → Test & Release
Spec fixes what the feature does (requirements, acceptance criteria, non-goals) with zero implementation detail; Design fixes how it's built (approach, version bump, branch name) given a fixed Spec — neither phase re-derives the other's decision
Review fans out to three parallel agents (correctness, security, simplification) over the diff; Test & Release checks the result against the Spec's acceptance criteria, triages Review's findings, runs this repo's full release checklist, and is the only phase that commits, pushes, and opens the PR
Defined in
.claude/agents/phase-*.md(five phase agents) and.claude/workflows/release-feature.js(the Code→Review→Test orchestrator) — seeCLAUDE.md's "AI-Native SDLC Pipeline" sectionEnds at an open PR against
develop; merging is still a human decision
Agent + RAG Pipeline
Configurable LLM backend: OpenAI GPT-4o-mini (default) or Anthropic Claude via env vars
ReAct loop agent with access to 26 of the 29 MCP tools (excludes
ask_agent,get_telemetry, andget_cache_stats)TF-IDF RAG over pricing docs with top-k retrieval
Conversation memory: per-session SQLite persistence, configurable turn limit
Chat UI at
/chat— streams ReAct progress in real timePOST /agent/chat— blocking JSON responsePOST /agent/chat/stream— SSE stream (thinking/tool_call/tool_result/answer/done)
Browser UIs
Path | Description |
| Marketing landing page |
| Conversational AI agent |
| Interactive cost calculator |
| Side-by-side model comparison |
| Pricing history charts (Chart.js) |
| Price-change leaderboard |
| Embeddable pricing table |
| Self-serve signup + upgrade dashboard |
| Conversation history viewer |
| Server stats, rate limits, customers |
| MCP integration hub |
| API reference (Swagger/ReDoc) |
| Release notes timeline |
All UIs share a consistent dark design system (CSS variables, 'Segoe UI' font, #0f1117 background, #7c6af7 accent) and are fully mobile-responsive with a sticky hamburger navigation bar.
SaaS Billing (Stripe)
Free tier signup:
POST /billing/signup(email → API key, no Stripe required)Paid tiers (Pro/Enterprise) via Stripe Checkout → auto-updates rate limits
Self-serve portal:
GET /billing/portalUsage dashboard:
GET /billing/me(router calls, savings, acceptance rate)Stripe webhook handler:
POST /billing/webhook
API Key Tiers & Rate Limiting
Free: 30 req/min · Pro: 120 req/min · Enterprise: 600 req/min
Tier auto-detected from billing DB (customer API key) or
X-Api-Key-TierheaderGET /rate-limits/tiers— public endpoint listing tier details
Security & Quality
Most endpoints are public (read-only pricing data, UIs, MCP tools)
Protected endpoints (
/billing/me,/router/recommend,/router/feedback,/billing/portal) require a billing API key or the globalMCP_API_KEYRate limiting per client IP + tier bucket
Request size limit (1MB default)
1205 passing tests, CI/CD on every PR (test → lint → bandit → OSV → gitleaks → deploy)
Deployment
Primary: Fly.io — shared-cpu-1x, 512MB, ~$3.40/mo
CI/CD: GitHub Actions — test → deploy on
masterpushBlue-green deployment support, graceful shutdown (SIGTERM/SIGINT)
Health probes:
/health,/health/live,/health/ready,/health/detailed
Table of Contents
Quick Start (Claude Desktop)
One-click links above open Cursor/VS Code directly (best-effort — deep-link support varies by client version). Every other client uses the copy-paste config below, which always works.
Option A — Remote (no install needed)
Add to your claude_desktop_config.json:
{
"mcpServers": {
"llm-pricing": {
"url": "https://llm-pricing-api.fly.dev/mcp"
}
}
}Restart Claude Desktop. All 29 pricing tools are immediately available.
Option B — STDIO via npx (no clone, no Python)
For clients that only support command-based STDIO servers (no direct remote/HTTP config support). This runs a zero-dependency npm package that bridges stdin/stdout to the hosted server above — nothing to clone, no Python or pip install needed.
{
"mcpServers": {
"llm-pricing": {
"command": "npx",
"args": ["-y", "llm-pricing-mcp"]
}
}
}Restart Claude Desktop. See npm/llm-pricing-mcp/README.md for configuration options (self-hosting, timeouts).
Option C — Local STDIO, fully offline
Clone and install:
git clone https://github.com/skakumanu/llm-pricing-mcp-server.git
cd llm-pricing-mcp-server
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtAdd to
claude_desktop_config.json:
{
"mcpServers": {
"llm-pricing": {
"command": "python",
"args": ["/absolute/path/to/mcp/server.py"],
"cwd": "/absolute/path/to/llm-pricing-mcp-server",
"env": { "PYTHONUNBUFFERED": "1" }
}
}
}See docs/CLAUDE_INTEGRATION.md for detailed setup, Windows paths, and troubleshooting.
Quick Start (API)
Running the Server
python src/main.py
# or
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000Public Endpoints (no auth)
# Get all pricing
curl http://localhost:8000/pricing
# Estimate cost
curl -X POST http://localhost:8000/cost-estimate \
-H "Content-Type: application/json" \
-d '{"model_name": "gpt-4o", "input_tokens": 1000, "output_tokens": 500}'
# Chat with the agent
curl -X POST http://localhost:8000/agent/chat \
-H "Content-Type: application/json" \
-d '{"message": "What is the cheapest model for RAG pipelines?"}'
# OpenAI-compatible routing proxy
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4", "messages": [{"role": "user", "content": "hi"}]}'Protected Endpoints (billing API key or MCP_API_KEY)
# Get your API key via free signup
curl -X POST http://localhost:8000/billing/signup \
-H "Content-Type: application/json" \
-d '{"email": "you@example.com"}'
# Use the returned api_key for protected endpoints
curl -H "x-api-key: <your-api-key>" \
http://localhost:8000/billing/me
curl -X POST http://localhost:8000/router/recommend \
-H "x-api-key: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{"max_cost_per_1m_tokens": 5}'Agent Streaming
curl -X POST http://localhost:8000/agent/chat/stream \
-H "Content-Type: application/json" \
-d '{"message": "Compare GPT-4o vs Claude Sonnet pricing"}' \
--no-bufferEvents: thinking → tool_call → tool_result → answer → done
HTTP MCP Transport
The server exposes a JSON-RPC 2.0 endpoint at POST /mcp supporting the MCP protocol over HTTP (protocol version 2024-11-05).
Supported methods
Method | Description |
| Handshake — returns server info and capabilities |
| Notification — returns 204 |
| List all 29 tools with input schemas |
| Execute a tool |
Example
# List tools
curl -X POST https://llm-pricing-api.fly.dev/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
# Call a tool
curl -X POST https://llm-pricing-api.fly.dev/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0", "id": 2, "method": "tools/call",
"params": {
"name": "estimate_cost",
"arguments": {"model_name": "gpt-4o", "input_tokens": 1000, "output_tokens": 500}
}
}'GET /mcp returns server info and a config snippet. Full interactive docs at /docs (Swagger UI) and /redoc.
API Reference
Public Endpoints
Method | Path | Description |
GET |
| Landing page (HTML) |
GET |
| All model pricing ( |
GET |
| All available models |
GET |
| Throughput, latency, context window, quality scores |
GET |
| Model use-case recommendations |
GET |
| Server usage metrics and analytics |
GET |
| Aggregated server statistics |
GET |
| Current rate-limit state |
GET |
| API tier definitions |
GET |
| Historical pricing snapshots |
GET |
| Price-change leaderboard |
GET |
| Public pricing (unauthenticated, embed-safe) |
GET |
| CSV/JSON export |
POST |
| Single model cost estimate |
POST |
| Multi-model cost comparison |
POST |
| Blocking agent chat |
POST |
| Streaming agent chat (SSE) |
GET |
| List conversations |
DELETE |
| Delete a conversation |
GET |
| API version info |
GET |
| Webhook signing key info |
POST |
| OpenAI-compatible routing proxy |
GET |
| HTTP MCP server info |
POST |
| HTTP MCP JSON-RPC 2.0 |
POST |
| Free tier signup → API key |
GET |
| Billing dashboard (HTML) |
POST |
| Stripe webhook |
GET |
| Health check |
GET |
| Kubernetes liveness probe |
GET |
| Kubernetes readiness probe |
GET |
| Detailed health with service statuses |
Protected Endpoints (billing API key or MCP_API_KEY)
Method | Path | Description |
POST |
| Smart model routing recommendation |
POST |
| Streaming router (SSE) |
POST |
| Submit routing feedback |
GET |
| Router savings report |
POST |
| Record one actual usage event (cost computed server-side) |
POST |
| Record multiple usage events at once |
GET |
| Actual spend summary by model/provider, per org |
POST |
| Stripe Checkout session |
GET |
| Stripe billing portal |
GET |
| Usage dashboard |
POST |
| Register price-change webhook |
GET |
| List alerts |
DELETE |
| Delete alert |
Key Request/Response Examples
POST /cost-estimate
// Request
{"model_name": "gpt-4o", "input_tokens": 1000, "output_tokens": 500}
// Response
{
"model_name": "gpt-4o", "provider": "OpenAI",
"input_tokens": 1000, "output_tokens": 500,
"input_cost": 0.0000025, "output_cost": 0.000005,
"total_cost": 0.0000075, "currency": "USD"
}POST /billing/signup
// Request
{"email": "you@example.com"}
// Response
{
"api_key": "abc123...", "org_id": "org-xyz...",
"tier": "free", "message": "Welcome! Your free API key is ready."
}POST /router/recommend
// Request (x-api-key header required)
{"max_cost_per_1m_tokens": 5, "task_type": "code"}
// Response
{
"recommended": {"model_name": "gpt-4o-mini", "provider": "OpenAI", ...},
"alternatives": [...],
"reason": "Best quality/cost ratio for code tasks under $5/1M tokens",
"routing_id": "uuid4..."
}Configuration
Environment Variables
# LLM Backend (Agent)
AGENT_LLM_PROVIDER=openai # "openai" (default) or "anthropic"
AGENT_MODEL=gpt-4o-mini # Model name
OPENAI_API_KEY=sk-... # Required when AGENT_LLM_PROVIDER=openai
ANTHROPIC_API_KEY=sk-ant-... # Required when AGENT_LLM_PROVIDER=anthropic
# Server
SERVER_HOST=0.0.0.0
SERVER_PORT=8000
DEBUG=false
# Security
MCP_API_KEY=your-strong-random-key # Global admin key (optional — billing keys work too)
RATE_LIMIT_PER_MINUTE=60 # Default rate limit (overridden by tier)
# Billing (Stripe)
STRIPE_SECRET_KEY=sk_live_... # Optional — free signup works without this
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PRICE_ID_PRO=price_...
STRIPE_PRICE_ID_ENTERPRISE=price_...
BILLING_DB_PATH=/app/data/billing.db
BILLING_BASE_URL=https://llm-pricing-api.fly.devSwitching LLM providers requires only env var changes — no code modifications:
Provider |
|
| Estimated cost |
OpenAI (default) |
|
| ~$0.73/mo |
OpenAI (powerful) |
|
| ~$8/mo |
Anthropic |
|
| ~$15/mo |
Anthropic (fast) |
|
| ~$2/mo |
Development
Project Structure
llm-pricing-mcp-server/
├── src/
│ ├── __init__.py # Version (1.48.0)
│ ├── main.py # FastAPI app + all endpoints
│ ├── config/settings.py # Pydantic settings
│ ├── models/ # Pydantic models (pricing, billing, router, …)
│ └── services/ # Business logic
│ ├── pricing_aggregator.py # Multi-provider pricing aggregator
│ ├── billing_service.py # SQLite billing / customer DB
│ ├── router.py # Model routing engine
│ ├── savings_tracker.py # Router savings analytics
│ ├── benchmark_service.py # Quality scores + HF API
│ ├── pricing_history.py # Historical snapshot DB
│ └── …
├── mcp/
│ ├── server.py # STDIO JSON-RPC 2.0 server
│ └── tools/ # 29 MCP tool implementations
│ ├── tool_manager.py
│ ├── get_all_pricing.py
│ ├── estimate_cost.py
│ └── …
├── agent/
│ ├── pricing_agent.py # ReAct loop agent
│ ├── llm_backend.py # OpenAI + Anthropic backends
│ └── tools.py # Agent tool wrappers
├── static/ # Browser UIs (one dir per page)
│ ├── landing/ # / (marketing page)
│ ├── chat/ # /chat (agent UI)
│ ├── calculator/ # /calculator
│ ├── compare/ # /compare
│ ├── history/ # /history
│ ├── trends/ # /trends
│ ├── widget/ # /widget
│ ├── billing/ # /billing
│ └── admin/ # /admin
├── tests/ # 667 tests
├── docs/ # Extended documentation
├── .github/workflows/ci-cd.yml # CI/CD pipeline
├── Dockerfile
├── fly.toml # Fly.io deployment config
└── requirements.txtAdding a New Provider
Create
src/services/<provider>_pricing.pyimplementingBasePricingProviderRegister in
src/services/pricing_aggregator.pyAdd env var for optional API key in
src/config/settings.pyAdd tests in
tests/
Testing
# Run all 667 tests
pytest
# With coverage
pytest --cov=src --cov-report=term-missing
# Specific suites
pytest tests/test_api.py -v
pytest tests/test_billing_endpoints.py -v
pytest tests/test_mcp_http.py -v # HTTP MCP transport
pytest tests/test_router.py -vTest Files
File | What it covers |
| Core API endpoints |
| Agent chat + streaming |
| Signup, checkout, webhook, me |
| BillingService unit tests |
| HTTP MCP transport |
| Router recommendation + feedback |
| Auth middleware |
| Admin endpoints |
| Pricing history + trends |
| TF-IDF RAG pipeline |
| ReAct agent unit tests |
Deployment
Fly.io (Primary)
The app is deployed on Fly.io and auto-deploys on every push to master.
# Install flyctl
# https://fly.io/docs/getting-started/installing-flyctl/
# Deploy manually
flyctl deploy
# Set secrets
flyctl secrets set \
MCP_API_KEY=... \
OPENAI_API_KEY=... \
AGENT_LLM_PROVIDER=openai \
AGENT_MODEL=gpt-4o-mini
# Set Stripe secrets (optional — free tier works without)
flyctl secrets set \
STRIPE_SECRET_KEY=sk_live_... \
STRIPE_WEBHOOK_SECRET=whsec_... \
STRIPE_PRICE_ID_PRO=price_... \
STRIPE_PRICE_ID_ENTERPRISE=price_... \
BILLING_BASE_URL=https://llm-pricing-api.fly.devConfiguration in fly.toml. Persistent volume at /app/data/ stores all SQLite databases.
GitHub Actions CI/CD
The .github/workflows/ci-cd.yml pipeline:
Runs all 667 tests on every PR
Deploys to Fly.io on
masterpush (viaFLY_API_TOKENsecret)Performs a health check after deploy
Health Check Endpoints
GET /health → {"status":"healthy","version":"1.39.0"}
GET /health/live → {"alive":true}
GET /health/ready → {"ready":true,"checks":{...}}
GET /health/detailed → detailed environment + service statusesBlue-Green Deployment
Graceful shutdown with request draining is supported. See docs/BLUE_GREEN_DEPLOYMENT.md.
Live Data
The server fetches pricing data from official public pricing pages using web scraping with smart caching. No provider API keys are required for pricing data.
Cache TTL: 2 hours for pricing, 5 minutes for performance metrics
Fallback: Static hardcoded data if live sources are unavailable
Providers: OpenAI, Anthropic, Google, Cohere, Mistral AI, Groq, Together AI, Fireworks AI, Perplexity AI, AI21 Labs, Anyscale, Amazon Bedrock
Optional provider API keys (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.) improve model-list freshness but are not required.
Contributing
See docs/CONTRIBUTING.md. This repo uses Git Flow:
feature/<name> → develop (PR) → master (PR) → Fly.io auto-deployNever commit directly to
developormasterBranch names:
feature/<topic>-v<version>(e.g.feature/stripe-billing-v1.37.0)Open PRs against
develop; maintainers promote develop → master for releases
License
MIT — see LICENSE.
Roadmap
Completed
v1.39.0 — OpenAPI tags + grouped Swagger UI; 15th MCP tool (
ask_agent)v1.38.6 — MCP server fixes: initialize all services, register
ask_agenttool, init PricingAlertServicev1.38.5 — Landing page MCP integration guide (Claude Desktop, VS Code, Cursor)
v1.38.4 — Billing beta UX: coming-soon copy, disabled paid buttons, graceful 503
v1.38.3 — Dark theme + shared nav for chat and conversations pages
v1.38.2 — Design system standardized across all 9 UIs (admin as canonical reference)
v1.38.1 — UI theme consistency pass
v1.38.0 — HTTP MCP transport (
POST /mcp,GET /mcp) for remote clientsv1.37.3 — Mobile-responsive UI, consistent nav across all pages
v1.37.2 — SQLite directory auto-creation on Fly.io volume mount
v1.37.1 — Marketing landing page at
/v1.37.0 — Stripe SaaS billing: free signup, Pro/Enterprise tiers, self-serve portal
v1.36.0 — API key tiers (free/pro/enterprise), router feedback loop, streaming router, Fly.io migration
v1.35.0 — Quality value index, benchmark service, model router, savings tracker
v1.33.0 — Switched default LLM backend to GPT-4o-mini (~20× cheaper)
v1.27.0–v1.32.0 — Admin dashboard, widget, compare UI, calculator, price alerts, history export
v1.10.0–v1.26.0 — Agent + RAG pipeline, streaming, conversation memory, pricing history
v1.5.1 — 12 providers, 87+ models, live data fetching
v1.6.0 — Full MCP protocol (STDIO JSON-RPC 2.0), Claude Desktop integration
Upcoming
Stripe products live setup (configure products + set Fly.io secrets)
Shut down Azure App Service (currently running in parallel at ~$27/mo)
Custom domain
Additional LLM backends (Groq direct, Ollama local)
WebSocket support for live price subscriptions
This server cannot be deployed
Maintenance
Related MCP Connectors
Sourced AI-model pricing and capability data — compare and route to the cheapest capable model.
Enforce AI budgets before the model call and track cost per customer across 10 providers.
Find AI model pricing, estimate token costs and compare offers. No API key required.
Live registry of AI model specs, context windows, and per-token pricing.
Related MCP Servers
AlicenseNot gradedqualityDmaintenanceProvides cost intelligence and a reputation scoring system to help AI agents optimize spending through smart model selection and local-to-cloud routing. It enables real-time cost tracking and rewards agents for making efficient, high-credibility decisions across various LLM providers.Apache 2.0- FlicenseNot gradedqualityDmaintenanceProvides 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-
- AlicenseAqualityDmaintenanceEnables AI agents to discover, compare, and select the best AI models across multiple providers based on pricing, performance, and capabilities, with real-time cost estimation and benchmarking.93,520 npm1MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI cost calculation, comparison, and optimization across major providers like Anthropic, OpenAI, Google, Meta, and Mistral. Supports cost estimation, budget-aware model finding, and token estimation through a simple API and MCP integration.-