Skip to main content

Quater

CI Coverage Python 3.11+ License: MIT Docs

PyPI Downloads

Most backend frameworks were designed for one main job: serve data to a frontend, then let humans click through that frontend to get work done.

That model still matters, but it is no longer enough. Moving ahead, more work is going to be done by AI agents. Asking those agents to use a product through screens, buttons, and forms is slow, fragile, and often the wrong level of access. Agents need a safe way to work with the backend directly.

That does not mean giving agents unlimited access. It means exposing the right operations, with clear inputs, clear descriptions, real auth, audit trails, and approval gates where the action is sensitive.

Quater is a Python backend framework built for this shift. You build a normal backend for people and services, and you can expose selected views directly to MCP Clients through MCP or to AI agents through the CLI. The same operation can serve the app, power an agent, and support production workflows without becoming three different pieces of code.

The goal is simple: make the backend usable by humans and operable by AI agents, without losing safety, structure, or ownership of the application logic.

Highlights

  • One view serves HTTP, MCP, and CLI. You annotate the route once and all three entry points share the same handler logic, while auth is configured per surface.
  • Exposing a view to AI agents takes a single flag. No extra service, no separate schema file, no adapter to maintain.
  • Request safety is on by default. Host checking, CORS, body limits, and request IDs run without you touching configuration; authentication is enabled per surface with AuthConfig, and surfaces without one are deliberately public.
  • Every request carries source and entrypoint metadata, so audit logs always know whether a human or an AI agent used your backend and how it arrived.
  • It gives slightly better performance than FastAPI for real workloads, with no measurable overhead when database I/O dominates.
  • It's simple to use, with a small API surface and no extra configuration required.

A Small App

from quater import AuthConfig, AuthContext, HTTPError, Quater, Request


async def authenticate(request: Request) -> AuthContext | None:
    if request.headers.get("authorization") != "Bearer admin-token":
        return None
    return AuthContext(subject="admin")


app = Quater(auth=[AuthConfig(authenticate, surfaces=["api", "mcp", "cli"])])

ORDERS: dict[str, dict[str, object]] = {
    "ord_1001": {"id": "ord_1001", "status": "paid", "total": 42.5}
}


@app.get("/health", public=True)
async def health() -> dict[str, bool]:
    return {"ok": True}


@app.get(
    "/orders/{order_id}",
    tool=True,
    cli=True,
    description="Fetch one order by id.",
)
async def get_order(order_id: str, request: Request) -> dict[str, object]:
    order = ORDERS.get(order_id)
    if order is None:
        raise HTTPError("Order not found", status_code=404)
    assert request.auth is not None
    return {
        **order,
        "subject": request.auth.subject,
        "source": request.context.source,
        "entrypoint": request.context.entrypoint,
    }

Run it:

python -m pip install quater
quater dev main.py

If you use uv, install with uv add quater instead.

Expected server output:

[INFO] Starting granian
[INFO] Listening at: http://127.0.0.1:8000
  1. Call HTTP:
curl -H "Authorization: Bearer admin-token" \
  http://127.0.0.1:8000/orders/ord_1001
{
  "id": "ord_1001",
  "status": "paid",
  "total": 42.5,
  "subject": "admin",
  "source": "api",
  "entrypoint": "server"
}
  1. Call the same handler as an MCP tool:
curl http://127.0.0.1:8000/mcp \
  -H "Authorization: Bearer admin-token" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_order","arguments":{"order_id":"ord_1001"}}}'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"id\":\"ord_1001\",\"status\":\"paid\",\"total\":42.5,\"subject\":\"admin\",\"source\":\"mcp\",\"entrypoint\":\"server\"}"
      }
    ],
    "isError": false
  }
}
  1. Call the same handler from the local CLI without a server round trip:
export QUATER_APP=main:app
export QUATER_TOKEN=admin-token
quater actions list
quater call get_order --order-id ord_1001
{
  "id": "ord_1001",
  "status": "paid",
  "total": 42.5,
  "subject": "admin",
  "source": "cli",
  "entrypoint": "local"
}
  1. For a hosted app, connect once and call the named remote, just like git:
quater connect store https://api.example.com --token admin-token
quater actions describe store get_order
quater call store get_order --order-id ord_1001

Production demo

If you want to see how an app built on Quater behaves in production, check out DevilsAutumn/frustrated. It is a demo Quater app that users can operate through their AI agents and MCP clients, along with normal HTTP routes. It's not 100% production-ready, but it serves as a good example of how Quater can be used in a real-world app.

Data flow diagram

flowchart TB
    caller["Caller\nperson, service, or AI agent"]
    http["HTTP request\nGET /orders/ord_1001"]
    mcp["MCP tool call\ntools/call get_order"]
    remote_cli["Remote CLI action\nquater call store get_order"]
    adapter["Server adapter\nRSGI / ASGI / WSGI"]
    checks["Framework checks\nhost, body limit, CORS, request id"]
    router["Route metadata\nmethod, path, public, resources"]
    auth["Per-surface Auth\none authenticator, by source,\nsharing the request scope"]
    handler["Your handler\nget_order(...)"]
    response["Serialized response\nJSON, text, bytes, stream"]

    caller --> http
    caller --> mcp
    caller --> remote_cli
    http --> adapter
    mcp --> adapter
    remote_cli --> adapter
    adapter --> checks
    checks --> router
    router -->|HTTP api| auth
    router -->|MCP| auth
    router -->|remote CLI| auth
    auth --> handler
    handler --> response

Why This Shape

Quater treats HTTP, MCP, and CLI as different ways to reach the same backend capability, not as three products you have to maintain.

  • For people and services: Quater gives you normal HTTP APIs with route decorators, OpenAPI, Swagger UI, request binding, response classes, route groups, middleware, and tests.
  • For MCP Clients: tool=True exposes selected routes through MCP with required descriptions, generated input schemas, per-surface transport auth, MCP docs, and audit hooks.
  • For AI agents: cli=True exposes selected routes as local or remote CLI actions with discovery, dry-run, approval hooks, and JSON output for scripts.
  • For the app itself: auth context, resources, app.state, lifespan hooks, and serialization stay attached to the handler instead of drifting into wrappers.
  • For performance: the request path stays deliberately small with Granian/RSGI, msgspec JSON, and a native route matcher.

Benchmarks

To measure performance, we ran benchmarks on an Apple M2 with an 8-core CPU, 16 GiB RAM, macOS 26.3, Python 3.11.12, and one worker per app. Quater performed slightly better than FastAPI when real database work was involved.

For very small endpoints without database access, FastAPI can be faster because the benchmark mostly measures framework overhead. Quater still runs built-in checks such as host validation, request IDs, body limits, and security headers on every request.

In the latest run, Quater used Granian/RSGI, while FastAPI used Uvicorn with uvloop and httptools. Full setup, commands, and CSV files are available in benchmarks.

No database throughput No database p95 latency
Postgres throughput Postgres p95 latency

Current Status

Quater is still moving quickly. Current versions are 0.x.x, and any release can potentially include breaking changes. Pin the exact version that works with your app, read the release notes before upgrading, and run your tests after each upgrade.

Documentation

Contributing

Quater is meant to be a community-driven project. Please read CONTRIBUTING.md before you start contributing.

Agent Skills

Quater ships two agent skills:

  • quater-apps: for operating applications built with Quater through MCP, CLI actions, and HTTP. The applications build on quater can have their own skills for operating their applications.
  • quater-framework: for building and debugging applications with Quater.

Install the app-operator skill:

npx -y skills add \
  https://github.com/DevilsAutumn/quater/tree/main/agent-skills/quater-apps

Install the framework-development skill:

npx -y skills add \
  https://github.com/DevilsAutumn/quater/tree/main/agent-skills/quater-framework

Working On Quater

This repo uses uv for local development:

uv sync --group dev
uv run pytest
uv run mypy
uv run ruff format --check src tests scripts
uv run ruff check src tests scripts
uv build

Docs use VitePress:

npm install
npm run docs:reference
npm run docs:dev
npm run docs:build
npm run docs:build:site

docs/en/dev is the only docs source tree. npm run docs:build publishes the dev channel under /en/dev/. npm run docs:build:site builds the deployable site in one VitePress pass: the dev channel from the working tree plus a stable channel materialized from the latest release tag at /en/stable/. Release docs are frozen by the Git tag, never copied into the repo.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quater-0.2.2.tar.gz (509.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

quater-0.2.2-cp311-abi3-win_amd64.whl (295.1 kB view details)

Uploaded CPython 3.11+Windows x86-64

quater-0.2.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (395.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

quater-0.2.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (382.6 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

quater-0.2.2-cp311-abi3-macosx_11_0_arm64.whl (365.1 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

quater-0.2.2-cp311-abi3-macosx_10_12_x86_64.whl (371.4 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file quater-0.2.2.tar.gz.

File metadata

  • Download URL: quater-0.2.2.tar.gz
  • Upload date:
  • Size: 509.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quater-0.2.2.tar.gz
Algorithm Hash digest
SHA256 7f198f7e7a7b9048825f46d01523cee964c0d6bdf3b2ab9fe9ca100305221dca
MD5 7594af04fd0933b0dde495aa4e7bc780
BLAKE2b-256 5571754b6a1f08ab86e19c4cf165edd93b9467b3f0d8ef2b631e7a046b7370e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.2.2.tar.gz:

Publisher: release.yml on DevilsAutumn/quater

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quater-0.2.2-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: quater-0.2.2-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 295.1 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quater-0.2.2-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ed68bf833e7958191e548871cb736516963f6e4cf393cb7f7777170226cc1a4d
MD5 2d25be634058fefaba8bd9d2e8600b32
BLAKE2b-256 20bebb17693dfcfcc90a621bcb5f3a9a1b2bb77dc2408347c615ad346a5d9011

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.2.2-cp311-abi3-win_amd64.whl:

Publisher: release.yml on DevilsAutumn/quater

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quater-0.2.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quater-0.2.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 66a4c2adb9bd55c582b81a26e25c50ce987ee628edbef4dba6b1f24823808cff
MD5 bfe8dafccfbe3572cff5f0833bda1a04
BLAKE2b-256 076c6f9d5f1ab352da1de3eb16b836b85a375f1812cf882b2a3972edc9144269

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.2.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on DevilsAutumn/quater

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quater-0.2.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for quater-0.2.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 71d0a99db34a8d8c1f69ea3d8cb5199382819368e54bb5a07166242ea20ee44f
MD5 a56cc7031e54703d7514ad21d8ec5782
BLAKE2b-256 4cc77a2a34fd3122465e20e4a6057b162b724853dec6b9be0d451adc63641b51

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.2.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on DevilsAutumn/quater

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quater-0.2.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for quater-0.2.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3afbc6abb9fc4945d9e242cdde6198ca9957d87e85e94f439ba73816b0b3ddc
MD5 49ff7c8176af3920cde55a5e2f19c195
BLAKE2b-256 6e53ef42cd5a7f2befc83c6018c588f070bdd7c001cff6349a5d0b3a8b0b208d

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.2.2-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on DevilsAutumn/quater

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quater-0.2.2-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for quater-0.2.2-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 50d7f745d165aa5507b4b2eee5fe15bdffb77aa9c2956a3b561c97380210a591
MD5 0c18ba9f14963268758582c04465ac42
BLAKE2b-256 1b11825d2be095e7983b6749e30d1df76b8f83e464efb605690a3ffa72dc9d16

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.2.2-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on DevilsAutumn/quater

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.2 This release

6 files

0.2.1

6 files

0.2.0

6 files

0.1.1

6 files

0.1.0

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page