quota-mcp

quota-mcp

Tracks AI subscription quota (5h/day/week windows) and recommends which provider an agent should use, using local-first data and observed rate-limit events to veto providers.

Category
访问服务器

README

quota-mcp

How much of each AI subscription is left, and which provider should this agent use right now.

If you have ever woken up to an agent that burned the whole Claude weekly window overnight, or watched a batch job hammer a rate-limited provider for hours — this is for you. quota-mcp is a local-first MCP server and CLI that tracks subscription quota (the 5h/daily/weekly windows of your plans), not API spend. Cost meters tell you what you paid; quota-mcp tells you what you have left and whether to keep going.

How it trusts data (the important part)

Remote "usage APIs" for subscription plans are undocumented, unofficial, and they break. This project is built around that fact instead of pretending otherwise:

  1. The core is local-only. Tokens come from the OpenCode database on your disk. Limits come from a file you calibrate with real measured values (null = track only — numbers are never invented). No network, no credentials, works offline.
  2. Observed events beat estimates. When a provider actually rate-limits you, record it (observe). An observed rate_limit/balance/key_limit event always vetoes the provider — an estimate never does.
  3. Remote scrapers are community plugins. Each one is a registry entry with a status (core / community / broken). When a provider changes something and a scraper breaks, the community fixes it or flips it to broken — the core keeps working either way.
  4. Fail-open. A missing sensor (no DB, no calibrated limit) yields "use" with a warning. A gate never blocks because a sensor is absent.

Quickstart

uv tool install quota-mcp        # or: uvx --from quota-mcp quota-mcp
quota-mcp status                 # tokens per provider, windows 5h/day/week
quota-mcp serve                  # MCP stdio server

MCP client configuration

Claude Code:

claude mcp add quota -- uvx --from quota-mcp quota-mcp serve

Cursor / OpenCode / any stdio MCP client:

{
  "mcpServers": {
    "quota": { "command": "uvx", "args": ["--from", "quota-mcp", "quota-mcp", "serve"] }
  }
}

Tools exposed: get_all_usage, get_provider_usage, get_recommendation, observe.

CLI for orchestrators

The exit-code contract is stable and scriptable:

quota-mcp recommend --provider opencode   # exit 0 = use, 1 = wait, 4 = exhausted
MODEL=$(quota-mcp pick --tiers "free-model openrouter/deepseek/x claude:opus")
quota-mcp observe --kind rate_limit --model-ref "$MODEL"   # real event -> veto
quota-mcp limits --set opencode 5h 4000000                 # calibrate with a MEASURED value

pick walks the list in order and prints the first viable ref: it skips providers with a recently observed block event and providers above their calibrated limit. With QUOTA_MCP_MODEL_REGISTRY set, it also vetoes refs absent from your model registry and refs with a dead id_status.

Collectors

<!-- collectors-table:start -->

Collector Status Auth (env) Description Maintainer Last verified
opencode_db core none Tokens per provider from the local OpenCode database (~/.local/share/opencode/opencode.db), windows 5h/day/week. No network. @carl0sfelipe 2026-08-13
openrouter community OPENROUTER_API_KEY Key limit and usage from the official OpenRouter /key endpoint. Reads OPENROUTER_API_KEY or the OpenCode auth store. @carl0sfelipe 2026-08-13
claude_pro community none Claude Pro/Max subscription windows from Anthropic's oauth usage endpoint. Reuses the token Claude Code keeps fresh - never refreshes it (refresh is blocked by Cloudflare; the cache layer serves stale data on 429). @carl0sfelipe 2026-08-13
<!-- collectors-table:end -->

The table above is generated from registry.yaml — the registry is the source of truth. A scraper marked broken is skipped by the loader (force with allow_broken: true) until someone fixes it. See CONTRIBUTING.md to add or fix a collector; it is one module plus one registry entry plus one fixture test.

Configuration

Optional file at ~/.config/quota-mcp/config.yaml (or $QUOTA_MCP_CONFIG):

providers:
  opencode:
    collector: opencode_db
    enabled: true
  claude_pro:
    collector: claude_pro
    enabled: true
  openrouter:
    collector: openrouter
    enabled: true
engine:
  wait_pct: 85           # recommend "wait" above this percent
  obs_lookback_min: 15   # how long an observed event vetoes a provider

Environment overrides: QUOTA_MCP_OPENCODE_DB, QUOTA_MCP_LIMITS, QUOTA_MCP_OBS, QUOTA_MCP_MODEL_REGISTRY, QUOTA_MCP_WAIT_PCT, QUOTA_MCP_OBS_LOOKBACK_MIN.

Data lives in ~/.local/share/quota-mcp/ (limits.json, observations.jsonl, cache.db).

Development

uv sync
uv run pytest      # the whole suite runs with sockets disabled - no network, no keys

CI runs on Linux and macOS, blocks network access in tests, and refuses commits containing machine paths, third-party e-mails or phone numbers (scripts/check_public.sh).

License

Apache-2.0. See LICENSE and NOTICE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选