Skip to main content

The Python framework for APIs that humans use and agents can safely operate.

Project description

Quater

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 operations 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.

Quater is not trying to replace Django/FastAPI/Flask, ship an ORM, or hide your architecture behind a large dependency graph. It focuses on the parts this new backend model needs: typed handlers, explicit auth boundaries, AI-readable metadata, operator-friendly actions, generated docs, and a small request path.

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, auth, resources"]
    mcp_surface_auth["MCP auth\nmcp_auth"]
    cli_surface_auth["CLI auth\ncli_auth"]
    route_auth["Route auth\nauth="]
    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| route_auth
    router -->|MCP| mcp_surface_auth --> route_auth
    router -->|remote CLI| cli_surface_auth --> route_auth
    route_auth --> handler
    handler --> response

A Small App

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


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


app = Quater(mcp_auth=authenticate, cli_auth=authenticate)

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


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


@app.get(
    "/orders/{order_id}",
    tool=True,
    cli=True,
    auth=authenticate,
    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:

uv add quater
quater dev main.py

Expected server output:

[INFO] Starting granian
[INFO] Listening at: http://127.0.0.1:8000

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

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

For a hosted app, connect once and call the named remote:

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

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, 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: route auth, 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.

Current Status

Quater is pre-release. The documented top-level imports are the public surface, but names and defaults can still change before the first stable release. Pin the version you test with.

Documentation

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

Project details


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.1.0a1.tar.gz (362.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.1.0a1-cp311-abi3-win_amd64.whl (269.5 kB view details)

Uploaded CPython 3.11+Windows x86-64

quater-0.1.0a1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (370.5 kB view details)

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

quater-0.1.0a1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (358.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

quater-0.1.0a1-cp311-abi3-macosx_11_0_arm64.whl (340.0 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

quater-0.1.0a1-cp311-abi3-macosx_10_12_x86_64.whl (347.4 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file quater-0.1.0a1.tar.gz.

File metadata

  • Download URL: quater-0.1.0a1.tar.gz
  • Upload date:
  • Size: 362.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quater-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 31b432e29cc5a38e19ed8e0b6fcb2056a84b9180954592378505e7ab168d705a
MD5 afb7571fb48066b51d31c8c8de04d576
BLAKE2b-256 ab05046dc59e545ee969e9f5f1596b213987e03156cf1887632f7d52b2f28d2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.1.0a1.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.1.0a1-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: quater-0.1.0a1-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 269.5 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quater-0.1.0a1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1c89bfdaaebbe17d771a128416d991fbb8781825d335865bfa493e7752dfc857
MD5 91c27fb08d91f45de0532eec4e307199
BLAKE2b-256 c39e13c8c10991a561c9d6bed3b9712158bea417a23452bd3ab764c95e494896

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.1.0a1-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.1.0a1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quater-0.1.0a1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47bed784426768a53d92fd4413bce932d9be6fc484a689a84fc07a7e16d38a5a
MD5 26a9ff947a81892cb779a56718835661
BLAKE2b-256 4478507e9667cba51fe571fa1ae25d7e888d033c10c40682ae31e717bef50dd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.1.0a1-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.1.0a1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for quater-0.1.0a1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 da52f75f6964a2b6a8a5ca6584655866efb3b0a658747ba4a6a769f7537c755d
MD5 510c786085a40da0d41116852ca1df8a
BLAKE2b-256 cfcc35bccb7999446d6678e8ac8d96e70c07687b74aa04f06a70d072a3f8798c

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.1.0a1-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.1.0a1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for quater-0.1.0a1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23c6ef42cce5a1b8ab8bd927ab5b96c33b8e1104b108929db7178fce3adeefcd
MD5 71d5a41cc5df765f0ecc70c9adea4ccb
BLAKE2b-256 7166c2a9e9b76407482bca4a05d08807c6d9e4620c4c602ffa7ee92792b8bf8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.1.0a1-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.1.0a1-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for quater-0.1.0a1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3040b20b4ad26510b4dd81bd112829b957f049784a5a97132133571a5252bc4a
MD5 9b558c043ae092c717c320ed3922af5c
BLAKE2b-256 24a0a511b90f4495aa28b2710ed6e76f751afc1a404cd84bf711460628caa275

See more details on using hashes here.

Provenance

The following attestation bundles were made for quater-0.1.0a1-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page