
AI Tools
v0.2.0
active
llm-cost-router-mcp
io.github.talkingape/llm-cost-router-mcp
OpenRouter cost-optimal router, $0 free-tier scanner, and OpenAI gateway probe MCP server.
Documentation
LLM Cost-Router & AI Gateway Pulse MCP
Zero-dependency MCP Server (JSON-RPC 2.0 over stdio) + OpenRouter Cost-Optimal Router + OpenAI-Compatible Gateway Health Probe (sub2api / new-api / LiteLLM) with SQLite metering, HMAC-SHA256 / Payhip v2 licensing, and dual-chain x402 Native USDC support (X Layer eip155:196 + Base eip155:8453).
- Companion Raycast Extension:
AI Gateway Pulse(probes/v1/modelslatency, scans$0high-context text models on OpenRouter, and copies MCP client config). - MCP Tools Exposed:
list_free_high_context_models,recommend_cost_optimal_route,probe_openai_gateway,get_savings_and_entitlement. - Quickstart:
python3 mcp_server.py --demoorpython3 -m unittest discover -s . -p "test_*.py" -v.
Commercial Pro License ($29) & Starter Kit ($49)
- Cost-Router MCP Pro (
$29lifetime · PayPal / Card instant license key): https://payhip.com/b/AgDFy - PayGate MCP Commercial Starter Kit (
$49· reusable Python MCP monetization boilerplate): https://payhip.com/b/TaM7u - Dual-Chain Native USDC x402 (
0.01 USDC/ 100 extra routes)payTo:0x13523bEBaf8d054beB8470911F5A6d5275E7E60a- Primary: X Layer Mainnet (
eip155:196, Circle Native USDC0x74b7f16337b8972027f6196a17a631ac6de26d22) - Fallback: Base Mainnet (
eip155:8453, Circle Native USDC0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
- Primary: X Layer Mainnet (
- Activate Key: Pass your
MCR1or Payhip key viaMCR_LICENSE_KEYenvironment variable or the tool argumentlicense_key.
零第三方依赖的 MCP Server + 成本最优路由引擎 + OpenAI 兼容网关(sub2api / new-api / LiteLLM)健康探针 + Payhip(PayPal) / OKX Web3(x402) 商业化闸门。
文件结构
router_core.py:OpenRouter 实时定价加载与缓存、纯文本高上下文限免扫描、:free/:batch价差分析、成本最优路由计算、OpenAI 兼容网关/v1/models只读探测、SQLite 配额计量 +MCR1离线签名 Key(含可选过期校验)+ Payhip v2 在线校验与 SQLite 缓存 + HTTP 402 / x402 闸门。generate_payhip_keys.py:Payhip 批量制卡 CLI,生成可直接粘贴/导入 Payhip「License Keys」的txt(每行 1 个签名 Key)或审计csv文件,并与服务端校验完全兼容。mcp_server.py:标准 MCP JSON-RPC 2.0 over stdio 服务端(暴露list_free_high_context_models、recommend_cost_optimal_route、probe_openai_gateway、get_savings_and_entitlement4 个工具),附带--demo一键实测模式。test_mvp.py:自动化单测与集成测试套件(含本地网关探测、Payhip v2 在线校验与缓存、HTTP 402/x402 与钱包地址校验、批量制卡 CLI、子进程 MCP stdio 往返、OpenRouter 实时联网烟雾测试)。pyproject.toml/glama.json/server.json:标准 MCP Registry、Glama 与 Python 包生态索引清单。
环境变量配置(运维说明)
| 变量名 | 说明 | 默认值 / 示例 |
|---|---|---|
MCR_LICENSE_SECRET | MCR1 离线签名密钥(部署时务必通过环境变量注入强随机密钥) | 开发演示默认值 |
MCR_LICENSE_KEY | 客户持有的 MCR1... 或 Payhip License Key | 空 |
MCR_PAYHIP_CHECKOUT_URL | Payhip Pro 结账链接(PayPal / Card 即时发卡) | https://payhip.com/b/AgDFy |
MCR_PAYHIP_PRODUCT_SECRET | Payhip 商品高级设置中的 product-secret-key(开启在线校验与退款吊销) | 空 |
MCR_X402_RECIPIENT | OKX Web3 自托管钱包 EVM 收款地址(支持 X Layer + Base 双链原生 USDC,可通过环境变量覆盖) | 0x13523bEBaf8d054beB8470911F5A6d5275E7E60a |
x402 双链原生 USDC 支持
HTTP 402 回包同时输出 accepts 数组:
- 首选 X Layer Mainnet(
network: "xlayer-mainnet",chainId: "eip155:196", Circle Native USDC0x74b7f16337b8972027f6196a17a631ac6de26d22") - 备选 Base Mainnet(
network: "base-mainnet",chainId: "eip155:8453", Circle Native USDC0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913")
一键运行与测试
1. 运行自动化测试套件
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s . -p "test_*.py" -v
2. 批量生成可导入 Payhip 的签名 License Key
MCR_LICENSE_SECRET="your-production-secret" \
python3 generate_payhip_keys.py \
--count 100 --tier pro --prefix payhip --format txt --output payhip_keys.txt
如需生成 30 天订阅版或导出审计表,可加 --days 30 与 --format csv。
3. 运行实时联网端到端演示
PYTHONDONTWRITEBYTECODE=1 python3 mcp_server.py --demo
客户端挂载配置(Claude Code / Cursor / Raycast MCP)
{
"mcpServers": {
"llm-cost-router": {
"command": "python3",
"args": [
"/path/to/llm-cost-router-mcp/mcp_server.py"
],
"env": {
"MCR_LICENSE_KEY": "",
"MCR_PAYHIP_CHECKOUT_URL": "https://payhip.com/b/AgDFy",
"MCR_X402_RECIPIENT": "0x13523bEBaf8d054beB8470911F5A6d5275E7E60a"
}
}
}
}
MCPB
https://github.com/talkingape/llm-cost-router-mcp/releases/download/v0.2.0/llm-cost-router-mcp.mcpbInstall Command
# mcpb: https://github.com/talkingape/llm-cost-router-mcp/releases/download/v0.2.0/llm-cost-router-mcp.mcpb