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
Installdmint in your environment:
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 raisesAuthorizationError:
agent_loop.py
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’sSQLiteApprovalStore handles transactional isolation and connection pooling safely.
main.py