quota-router MCP Server
Routes OpenAI-compatible chat/completions and responses requests to configured upstream pools with quota-aware model selection, SSE passthrough, and pre-first-byte failover.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
quota-router
English | 简体中文
Universal quota-aware LLM router, zero-dependency local streaming proxy, and MCP control plane for AI coding harnesses.
Supports Antigravity (agy), Hermes Agent, OpenAI Codex, Claude Code (cc), DSH, OpenCode, and any OpenAI- or Anthropic-compatible client.
Why quota-router?
Developers who juggle multiple AI subscriptions and API plans frequently run into three issues:
One plan's short-term rolling window gets rate-limited while another plan's monthly quota sits unused and expires.
Switching plans manually breaks flow, risks breaking harness configs, or invalidates a long-context prompt cache mid-session.
Heavy cross-protocol gateways frequently drop
usage, corrupt reasoning fields, or fail silently with 502s.
quota-router solves this with a dual-plane, zero-dependency architecture:
Data plane: Local HTTP/1.1 streaming proxy (
/v1/chat/completions,/v1/responses,/v1/messages,/v1/models,/readyz,/_status,/_dashboard) with same-protocol passthrough and pre-first-byte failover.Control plane: Stdio JSON-RPC 2.0 MCP server, CLI, and universal
SKILL.mdsharing the same SQLite state store and Tiered Pacing engine so closed OAuth/App pools participate in unified scheduling.
Related MCP server: MAGDA-MCP
Key Features
Zero mandatory dependencies: Pure Python 3.11+ standard library (
tomllib,sqlite3,http.client,ssl). OptionalPyYAMLextra for.yamlconfigs.Protocol-preserving passthrough: Routes strictly to upstreams supporting the incoming protocol; relays SSE chunk-by-chunk, preserves
usage, and supports opt-in error-code normalization.Tiered Pacing & EWMA burn-rate engine: Group models into task tiers (
auto:long,auto:fast,auto:boss, orauto). Candidates are ranked by multi-window pace gap, expiring-plan urgency, EWMA time-to-wall prediction, and peak-hour multipliers.Tiered session stickiness: Sticky tiers (
auto:long) pin each conversation to protect prompt cache; burst tiers (auto:fast) balance dynamically per request.Pre-first-byte failover: Automatically fails over on
429 / 5xx / empty stream / connection dropbefore the first chunk is written; passes through400/413/422directly; returns503withRetry-Afterif all pools are exhausted.Three-tier quota sensing: Background Pull probes (CLI/HTTP adapters), local SQLite metering +
Retry-After/*-ratelimit-*header feedback (metering), and CLI/MCP calibration for closed pools (manual).Safe harness integration: Zero-invasion
qrouter run <harness>launcher +--dry-run/backup/revertpersistent integrators foragy,hermes, andcodex.Built-in observability:
qrouter status/watch, zero-build Web Dashboard at/_dashboard, SQLite telemetry, and redacted JSONL audit logs.Credentials by reference only: Config files never store plaintext API keys—only
env,env_file, orcommandreferences.
Quickstart
# Install from GitHub or local checkout (Python 3.11+)
uv tool install git+https://github.com/mmqfans/quota-router.git
# or locally: uv tool install -e .
# Initialize starter config and check credentials/probes
qrouter init
qrouter doctor --probe
# Start background proxy and check live status
qrouter start
qrouter statusOpen http://localhost:41580/_dashboard in your browser for the live quota dashboard.
Connect Harnesses
# Zero-invasion trial (does not modify any config file)
qrouter run codex --tier long
qrouter run claude --tier fast
# Preview persistent integration (dry-run by default)
qrouter integrate agy
qrouter integrate hermes
qrouter integrate codex
# Apply with automatic backup (revert anytime via `qrouter revert <harness>`)
qrouter integrate codex --applyCLI Reference
Command | Description |
| Create starter |
| Validate config, credential presence (masked), and probe health |
| Manage background proxy daemon |
| Run proxy in foreground |
| Show pool quotas, 5h burn rates, cooldowns, and tier picks |
| Live refreshing terminal dashboard |
| Inspect exact pacing scores for a model or |
| Calibrate closed/manual pools or mark throttling |
| Zero-invasion harness launcher with auto-start |
| Preview or apply harness integration ( |
| Restore original harness config from latest backup |
| Start stdio JSON-RPC 2.0 MCP server |
| Generate optional macOS LaunchAgent plist |
Documentation
Security
Binds to loopback (
127.0.0.1) by default. Non-loopback hosts refuse to start unlessserver.auth_token_envis configured.Plaintext API keys are never written to config files, SQLite, JSONL audit logs,
/_status, or MCP responses.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Hosted MCP for Conductor Relay: a verifier-backed agent work exchange and cold marketplace.
Streamable HTTP MCP gateway for NV oOS fleets — one API key, namespaced tools, quotas and policy.
Public MCP for agent verification, work discovery and governed interoperability.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables MCP clients to analyze call graphs, run Grover-ranked code searches, generate boundary test cases, get refactoring suggestions, and inspect quantum backends through stdio JSON-RPC tools.2-
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to connect to a running MAGDA instance over stdio and access its native composition tools, resources, and resource templates, while providing instance discovery, fixed-instance connection, credential recovery, diagnostics, and compatibility checks.MIT
- AlicenseBqualityBmaintenanceExposes the six-echelon quality pipeline over stdio JSON-RPC 2.0, enabling MCP clients to manage frozen baselines, HMAC-approved gates, phase role isolation, safe rollback, independent verification, W3C PROV-DM audit chains, and CAPA consolidation.101MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to delegate analytics questions, sample-size calculation, knowledge retrieval, and metric listing to a deterministic statistical engine over stdio JSON-RPC.MIT