Open-source reference implementation of an identity and authorization control plane for AI agents.
Agent Identity Lab demonstrates how autonomous agents can be represented as first-class security principals — with unique identities, short-lived credentials, delegated authority, policy-based authorization, identity-aware MCP tool access, token brokerage, and cryptographically verifiable audit records.
🌐 Project Website → — architecture, API reference, development phases, ADRs
Most AI agents authenticate using weak patterns (personal credentials, broad service accounts, static API keys) that fail to distinguish which agent, which user, which runtime, and which permissions were involved in any action.
Identity API → Policy Engine → Token Broker → MCP Gateway → Tools
↓
PostgreSQL + Audit
# Install dependencies
uv sync --extra dev
# Generate dev keys
bash scripts/generate_dev_keys.sh
# Run services
docker compose up -d
# Run tests
PYTHONPATH=. uv run pytest tests/ -v
# Run demo (requires services running)
PYTHONPATH=. uv run python examples/delegated_research/authorized_read.pyThis repo can also be run locally without Docker for development and test execution.
# Install dependencies
uv sync --extra dev
# Generate dev keys
bash scripts/generate_dev_keys.sh
# Create a local SQLite database
PYTHONPATH=. DATABASE_URL=sqlite+aiosqlite:///./dev.sqlite3 uv run python scripts/init_local_db.pyStart each service in its own terminal:
PYTHONPATH=. DATABASE_URL=sqlite+aiosqlite:///./dev.sqlite3 JWT_PRIVATE_KEY_PATH=./keys/private.pem JWT_PUBLIC_KEY_PATH=./keys/public.pem uv run uvicorn apps.identity_api.main:app --host 127.0.0.1 --port 8000PYTHONPATH=. DATABASE_URL=sqlite+aiosqlite:///./dev.sqlite3 uv run uvicorn apps.token_broker.main:app --host 127.0.0.1 --port 8001PYTHONPATH=. JWT_PRIVATE_KEY_PATH=./keys/private.pem JWT_PUBLIC_KEY_PATH=./keys/public.pem IDENTITY_API_URL=http://127.0.0.1:8000 TOKEN_BROKER_URL=http://127.0.0.1:8001 MCP_GATEWAY_URL=http://127.0.0.1:8002 uv run uvicorn apps.mcp_gateway.main:app --host 127.0.0.1 --port 8002PYTHONPATH=. uv run uvicorn apps.mock_mcp_server.main:app --host 127.0.0.1 --port 8003Verify health:
curl http://127.0.0.1:8000/health
curl http://127.0.0.1:8001/health
curl http://127.0.0.1:8002/health
curl http://127.0.0.1:8003/healthRun tests locally without Docker:
PYTHONPATH=. uv run pytest tests/ -vNotes:
- This local path uses SQLite for convenience instead of the default PostgreSQL Docker setup.
- Authorization falls back to the Python policy adapter when OPA is not running.
- The full production-like topology is still the Docker Compose flow.
With the local stack running, you can execute the demo scenarios under examples/.
Authorized read:
PYTHONPATH=. uv run python examples/delegated_research/authorized_read.pyExample output:
Demo: Authorized Read — decision=allow, scopes=['repo:read']
PASS: authorized read succeeded
Denied write:
PYTHONPATH=. uv run python examples/unauthorized_write_attempt/denied_write.pyExample output:
Demo: Denied Write — decision=deny, reason=No scopes remain after intersection. Removed: ['issues:write']
PASS: unauthorized write attempt was denied
Suspended agent:
PYTHONPATH=. uv run python examples/hermes_agent/suspended_agent.pyExample output:
Created initial session e7a6891d-96b1-4dba-bbc4-d3159eb5205b
Suspended agent 8102bd5b-1af7-4b6c-a1cf-4b5d07effbcc
PASS: suspended agent session creation failed with 400
Invalid runtime:
PYTHONPATH=. uv run python examples/hermes_agent/invalid_runtime.pyExample output:
Demo: Invalid Runtime — decision=deny, reason=Environment 'development' not in approved environments
PASS: invalid runtime environment was denied
Secret isolation:
PYTHONPATH=. uv run python examples/delegated_research/secret_isolation.pyExample output:
Demo: Secret Isolation — type=bearer, lease_id=87c4f9ef-f09f-40bb-b8dc-f38aec6ad20b
PASS: token broker returned a leased credential without raw secret material
Machine-only session:
PYTHONPATH=. uv run python examples/hermes_agent/machine_only_session.pyExample output:
Demo: Machine-Only Session — decision=allow, acting_user=None
PASS: machine-only session authorized successfully
- 🌐 Project Website — full site with architecture, API reference, phases, ADRs
- Architecture
- Threat Model
- Token Model
- Policy Model
- MCP Integration
- Hermes Integration
- Demo Walkthrough
| Phase | Scope | Status |
|---|---|---|
| 1 | Core Identity Model | ✅ |
| 2 | Sessions and Tokens | ✅ |
| 3 | Policy Enforcement | ✅ |
| 4 | MCP Gateway | ✅ |
| 5 | Token Brokerage | ✅ |
| 6 | Audit Chain | ✅ |
| 7 | Hermes Demo + Docs | ✅ |
MIT