Verify an X-Token value (format, drift, HMAC). Raises HTTPException(403) on any failure. Returns (nonce, timestamp_ms) for callers that want to consume the nonce themselves. max_drift_ms=None resolves to MCP['TOKEN_MAX_DRIFT_MS'] (default 30000ms).
Same as validate_token plus replay protection: reserves the nonce in Redis with SET NX PX for 2 * max_drift_ms. Reused nonces inside the window raise HTTPException(403). This is what BaseResource._enforce_token uses.
Exceptions
Name
Kind
Use it for
HTTPException(status, detail)
class
Raise from anywhere to return a JSON error response. See HTTPException.
Multi-tenant
Name
Kind
Use it for
aset_tenant(account_id)
async function
Switch the active DB connection. See Multi-tenant.
Returns the current tenant id from db_state, or None.
set_default(account_id)
async function — script-only
Replaces the global default connection with the tenant's connection. Not safe inside ASGI request handling (mutates process-wide state). Import directly from zeromcp.tenant.tenant; not re-exported from 0-mcp. Use aset_tenant for per-request switching.
unset_default(account_id)
async function — script-only
Restores the original DEFAULT_DATABASE. Same caveats as set_default.
get_account(domain)
async function
Resolve an account by its domain.
get_master_user(email, password)
async function
Look up a user on the master DB by credentials. Used by /login flows.
db_state
ContextVar
Holds the active connection name. Read it directly when you need to know the current tenant DB.
DBRouter
class
Database router. Add to DATABASE_ROUTERS in settings.
Filters
Name
Kind
Use it for
OrmFilter
class
Build Django Q expressions from JSON filter trees. Used internally by resources; useful standalone for custom queries. Re-exported as OrmFilter (the underlying class is zeromcp.filters.Filter).
Names that are not in this list (e.g. zeromcp.calc.get_results, zeromcp.helpers.*, zeromcp.client_ip.get_client_ip) are internal. They may still be useful, but they are not part of the public API and may change between releases.
0-mcp by Stamatios Stamou Jr — github.com/ssjunior/0-mcp