Direct Python Integration

For custom agent backends, FastAPI services, or Python tool suites, Dmint provides in-process protection via the @dmint.protected decorator and programmatic authorization APIs.

1. Setup & Initialization

Install dmint in your environment:
Initialize your approval store and policy:
security.py

2. The @dmint.protected Decorator

Decorate any Python function with a capability identifier in the format tool.action:
tools.py

3. Handling Interception & Retries

When a function requires approval, Dmint halts execution and raises AuthorizationError:
agent_loop.py
Once approved by a human (via dmint dashboard), the agent retrieves the approved assertion and passes it as approval_credential:

4. Programmatic Authorization (dmint.authorize)

If you prefer explicit control without decorators:

5. Thread-Safe Web Framework Integration (FastAPI)

When running inside multi-threaded web applications like FastAPI or Uvicorn, each worker thread accesses SQLite cleanly. Core’s SQLiteApprovalStore handles transactional isolation and connection pooling safely.
main.py