Token导航 LogoToken导航TokenDH.com
LLM Pricing MCP Server logo
运维云端stdio官方级别未说明来源级核验

LLM Pricing MCP Server

MCP Server

一个为21家主要LLM提供商提供实时定价数据、成本估算和智能路由推荐的生产就绪型RESTful API服务,包含15个MCP工具和对话式AI代理。

工具数

15

提示词数

0

GitHub Stars

0

资源数

0
PythonClaude云端部署Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

skakumanu

提供方

skakumanu

最后核验

2026/5/17 20:22

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate

详细介绍

LLM定价MCP服务器

![CI/CD Pipeline](https://github.com/skakumanu/llm-pricing-mcp-server/actions) ![License: MIT](https://opensource.org/licenses/MIT)

生产准备就绪 模型上下文协议(MCP) LLM定价数据服务器。提供RESTful API(FastAPI), 15个MCP工具 通过STDIO和HTTP、会话式代理+RAG管道、基于浏览器的UI和自助计费仪表板——用于从 21家主要的法学硕士提供者.

住在: https://llm-pricing-api.fly.dev

______________________________________________________________________

特性

MCP接口(STDIO+HTTP)

  • 15个MCP工具: get_all_pricing, estimate_cost, compare_costs, get_performance_metrics, get_use_cases, 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
  • STDIO传输 --JSON-RPC 2.0通过STDIO实现本地Claude桌面集成
  • HTTP传输POST /mcp (JSON-RPC 2.0 over HTTP)用于远程MCP客户端,无需本地安装
  • MCP协议版本: 2024-11-05

RESTful API

  • 来自21家提供商(150多种型号)的实时定价,使用智能缓存的异步获取
  • 成本估算:单一模型(POST /cost-estimate)批量比较(POST /cost-estimate/batch)
  • 性能指标、用例建议、定价历史、趋势
  • 路由器推荐(POST /router/recommend)带反馈回路
  • OpenAI兼容代理(POST /v1/chat/completions)用于插入式SDK集成
  • 价格变化的Webhook警报(HMAC-SHA256签名)
  • 交互式文档: /docs (斯瓦格)和 /redoc

代理商+RAG管道

  • 可配置的LLM后端:OpenAI GPT-4o-mini(默认)或Anthropic Claude通过环境变量
  • ReAct循环代理 可以访问所有14个MCP工具
  • TF-IDF抹布 使用top-k检索对文档定价过高
  • 对话记忆:每个会话SQLite持久性,可配置的回合限制
  • 聊天界面/chat --streams实时回放进度
  • POST /agent/chat --阻止JSON响应
  • POST /agent/chat/stream --SSE流(thinking / tool_call / tool_result / answer / done)

浏览器UI

路径描述
/营销登录页面
/chat会话式AI代理
/calculator交互式成本计算器
/compare并排模型比较
/history定价历史图表(Chart.js)
/trends价格变动排行榜
/widget可嵌入定价表
/billing自助注册+升级仪表板
/conversations对话历史查看器
/admin服务器统计数据、速率限制、客户
/mcp-setupMCP集成中心
/api-docsAPI参考(Swagger/ReDoc)
/whats-new发布说明时间表

所有UI共享一致的暗设计系统(CSS变量, 'Segoe UI' 字体, #0f1117 背景 #7c6af7 口音),并且具有粘性汉堡导航栏的完全移动响应。

SaaS计费(条纹)

  • 免费会员注册: POST /billing/signup (电子邮件→ API密钥,不需要条纹)
  • 通过Stripe Checkout支付等级(专业/企业)→ 自动更新速率限制
  • 自助门户: GET /billing/portal
  • 使用情况仪表板: GET /billing/me (路由器呼叫、节省、接受率)
  • 条纹webhook处理程序: POST /billing/webhook

API关键层和速率限制

  • 自由:30个要求/分钟· 专业版:120次/分钟· 企业:600需求/分钟
  • 从帐单数据库(客户API密钥)自动检测的层或 X-Api-Key-Tier 头球
  • GET /rate-limits/tiers --公共端点列表层详细信息

安全与质量

  • 大多数端点都是公开的(只读定价数据、UI、MCP工具)
  • 受保护的端点(/billing/me, /router/recommend, /router/feedback, /billing/portal)需要帐单API密钥或全局 MCP_API_KEY
  • 每个客户端IP+层桶的速率限制
  • 请求大小限制(默认1MB)
  • 625项测试通过,每个PR上都有CI/CD(测试→ lint → 强盗→ OSV → gitleaks→ 部署)

部署

  • 主要的,重要的: Fly.io --共享cpu-1x,512MB,约3.40美元/月
  • CI/CD:GitHub操作--测试→ 部署于 master
  • 蓝绿色部署支持,优雅关机(SIGTERM/SIGINT)
  • 健康探头: /health, /health/live, /health/ready, /health/detailed

______________________________________________________________________

目录

______________________________________________________________________

快速入门(克劳德桌面版)

选项A——远程(无需安装)

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "llm-pricing": {
      "url": "https://llm-pricing-api.fly.dev/mcp"
    }
  }
}

重新启动克劳德桌面。所有15种定价工具均可立即使用。

选项B——本地STDIO

  1. 克隆并安装:
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.txt
  1. 添加 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" }
    }
  }
}

docs/CLAUDE_INTEGRATION.md 有关详细设置、Windows路径和疑难解答。

______________________________________________________________________

快速启动(API)

运行服务器

python src/main.py
# or
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000

公共端点(无身份验证)

# 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"}]}'

受保护的端点(计费API密钥或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: " \
  http://localhost:8000/billing/me

curl -X POST http://localhost:8000/router/recommend \
  -H "x-api-key: " \
  -H "Content-Type: application/json" \
  -d '{"max_cost_per_1m_tokens": 5}'

代理流媒体

curl -X POST http://localhost:8000/agent/chat/stream \
  -H "Content-Type: application/json" \
  -d '{"message": "Compare GPT-4o vs Claude Sonnet pricing"}' \
  --no-buffer

活动: thinkingtool_calltool_resultanswerdone

______________________________________________________________________

HTTP MCP传输

服务器在以下位置公开JSON-RPC 2.0端点 POST /mcp 支持HTTP上的MCP协议(协议版本 2024-11-05).

支持的方法

方法说明
initialize握手--返回服务器信息和功能
initialized通知--返回204
tools/list列出所有15个具有输入模式的工具
tools/call执行工具

示例

# 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 返回服务器信息和配置代码段。完整的交互式文档,请访问 /docs (Swagger用户界面)和 /redoc.

______________________________________________________________________

API 参考

公共端点

方法路径描述
得到/登录页面(HTML)
得到/pricing所有型号定价(?provider= 过滤器)
得到/models所有可用型号
得到/performance吞吐量、延迟、上下文窗口、质量分数
得到/use-cases模型用例建议
得到/telemetry服务器使用指标和分析
得到/admin/stats聚合服务器统计信息
得到/admin/rate-limits当前速率限制状态
得到/rate-limits/tiersAPI层定义
得到/pricing/history历史定价快照
得到/pricing/trends价格变动排行榜
得到/pricing/public公开定价(未经认证,嵌入安全)
得到/pricing/history/exportCSV/JSON导出
职位/cost-estimate单模型成本估算
职位/cost-estimate/batch多模型成本比较
职位/agent/chat阻止代理聊天
职位/agent/chat/stream流媒体代理聊天(SSE)
得到/agent/conversations列出对话
删除/agent/conversations/{id}删除对话
得到/api/versionsAPI版本信息
得到/pricing/alerts/signing-infoWebhook签名密钥信息
职位/v1/chat/completionsOpenAI兼容路由代理
得到/mcpHTTP MCP服务器信息
职位/mcpHTTP MCP JSON-RPC 2.0
职位/billing/signup免费会员注册→ API密钥
得到/billing账单仪表板(HTML)
职位/billing/webhook条纹webhook
得到/health健康检查
得到/health/liveKubernetes活性探测
得到/health/readyKubernetes就绪性探测
得到/health/detailed详细的健康状况和服务状态

受保护的端点(计费API密钥或MCP_API_key)

方法路径描述
职位/router/recommend智能模型路由推荐
职位/router/recommend/stream流媒体路由器(SSE)
职位/router/feedback提交路线反馈
得到/telemetry/savings路由器节省报告
职位/billing/checkout条纹结账会话
得到/billing/portal条纹计费门户
得到/billing/me使用情况仪表板
职位/pricing/alerts注册价格更改webhook
得到/pricing/alerts列出警报
删除/pricing/alerts/{id}删除警报

关键请求/响应示例

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..."
}

______________________________________________________________________

配置

环境变量

# 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.dev

切换LLM提供商 只需要更改env-var,无需修改代码:

供应商AGENT_LLM_PROVIDERAGENT_MODEL估计费用
OpenAI(默认)openaigpt-4o-mini约0.73美元/月
OpenAI(强大)openaigpt-4o约8美元/月
人类学anthropicclaude-sonnet-4-6约15美元/月
拟人化(快速)anthropicclaude-haiku-4-5-20251001约2美元/月

______________________________________________________________________

发展

项目结构

llm-pricing-mcp-server/
├── src/
│   ├── __init__.py                  # Version (1.39.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
│   ├── server_azure.py              # STDIO server proxying remote API
│   └── tools/                       # 14 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/                           # 625 tests
├── docs/                            # Extended documentation
├── .github/workflows/ci-cd.yml      # CI/CD pipeline
├── Dockerfile
├── fly.toml                         # Fly.io deployment config
└── requirements.txt

添加新提供者

  1. 创建 `src/services/

_pricing.py 实施 BasePricingProvider`

  1. 注册于 src/services/pricing_aggregator.py
  2. 在中为可选的API密钥添加env var src/config/settings.py
  3. 在中添加测试 tests/

______________________________________________________________________

测试

# Run all 625 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 -v

测试文件

文件它涵盖了什么
test_api.py核心API端点
test_agent_endpoint.py代理聊天+流媒体
test_billing_endpoints.py注册、结账、webhook、我
test_billing_service.py计费服务单元测试
test_mcp_http.pyHTTP MCP传输
test_router.py路由器推荐+反馈
test_security.py身份验证中间件
test_admin_dashboard.py管理端点
test_history_tools.py定价历史+趋势
test_rag.pyTF-IDF RAG管道
test_agent.pyReAct代理单元测试

______________________________________________________________________

部署

Fly.io(主要)

应用程序部署在 Fly.io 并在每次推送时自动部署 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.dev

配置在 fly.toml.持续体积 /app/data/ 存储所有SQLite数据库。

GitHub操作CI/CD

.github/workflows/ci-cd.yml 管道:

  1. 在每个PR上运行所有625个测试
  2. 部署到Fly.io master 推(通过 FLY_API_TOKEN 秘密)
  3. 部署后执行健康检查

健康检查端点

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 statuses

蓝绿部署

支持优雅关机和请求排放。看 docs/BLUE_GREEN_DEPLOYMENT.md.

______________________________________________________________________

实时数据

服务器使用带有智能缓存的网络抓取从官方公开定价页面获取定价数据。定价数据不需要提供程序API密钥。

  • 缓存TTL:定价2小时,性能指标5分钟
  • 后备方案:静态硬编码数据(如果实时源不可用)
  • 提供商:OpenAI、Anthropic、谷歌、Cohere、Mistral AI、Groq、Together AI、Fireworks AI、困惑AI、AI21 Labs、Anyscale、亚马逊基岩

可选提供程序API密钥(OPENAI_API_KEY, ANTHROPIC_API_KEY等等)提高了模型列表的新鲜度,但不是必需的。

______________________________________________________________________

贡献

docs/CONTRIBUTING.md。此回购使用 Git流:

feature/  →  develop (PR)  →  master (PR)  →  Fly.io auto-deploy
  • 永远不要直接承诺 developmaster
  • 分支机构名称: feature/-v (例如。 feature/stripe-billing-v1.37.0)
  • 公开公关 develop维护者促进发展→ 发布主控

______________________________________________________________________

许可证

麻省理工学院——见 许可证.

______________________________________________________________________

路线图

完成

  • \[x\] v1.39.0--OpenAPI标签+分组Swagger UI;第15个MCP工具(ask_agent)
  • \[x\] v1.38.6-MCP服务器修复:初始化所有服务,注册 ask_agent 工具,初始化定价警报服务
  • \[x\] v1.38.5--登录页MCP集成指南(克劳德桌面、VS代码、光标)
  • \[x\] v1.38.4--计费测试版用户体验:即将推出拷贝,禁用付费按钮,优雅503
  • \[x\] v1.38.3--黑暗主题+聊天和对话页面的共享导航
  • \[x\] v1.38.2--跨所有9个UI标准化的设计系统(管理员作为规范参考)
  • \[x\] v1.38.1--UI主题一致性传递
  • \[x\] v1.38.0--HTTP MCP传输(POST /mcp, GET /mcp)对于远程客户端
  • \[x\] v1.37.3--移动响应式用户界面,所有页面导航一致
  • \[x\] v1.37.2--在Fly.io卷挂载上自动创建SQLite目录
  • \[x\] v1.37.1--营销登录页面位于 /
  • \[x\] v1.37.0--Stripe SaaS计费:免费注册、专业/企业级、自助门户
  • \[x\] v1.36.0-API关键层(免费/专业/企业)、路由器反馈回路、流式路由器、Fly.io迁移
  • \[x\] v1.35.0--质量价值指数、基准服务、模型路由器、节省跟踪器
  • \[x\] v1.33.0--将默认LLM后端切换到GPT-4o-mini(约便宜20倍)
  • \[x\] v1.27.0–v1.32.0--管理仪表板、小部件、比较UI、计算器、价格警报、历史导出
  • \[x\] v1.10.0–v1.26.0--代理+RAG管道、流媒体、对话记忆、定价历史
  • \[x\] v1.5.1-12个提供商,87+个模型,实时数据获取
  • \[x\] v1.6.0--完整的MCP协议(STDIO JSON-RPC 2.0),克劳德桌面集成

即将到来的

  • \[\]Stripe产品实时设置(配置产品+设置Fly.io机密)
  • \[\]关闭Azure应用服务(目前并行运行,每月约27美元)
  • \[\]自定义域
  • \[\]其他LLM后端(Groq直销,Ollama本地)
  • \[\]WebSocket支持实时价格订阅

目录标签

目录标签

PythonClaude云端部署LLM定价本地部署成本估算智能路由RESTfulAPI对话式AI

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

api-key

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

15

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdioapi-key部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP