Open-source observability & audit trail for AI agents
AgentLens is a flight recorder for AI agents. It captures every tool call, approval decision, data exchange, and error β then presents it through a queryable API and real-time web dashboard.
MCP-native. Add one config block β every tool call is captured automatically. Zero code changes.
- π MCP-Native β Ships as an MCP server. Agents connect to it like any other tool. Works with Claude Desktop, Cursor, and any MCP client.
- π Real-Time Dashboard β Session timelines, event explorer, cost analytics, and alerting in a beautiful web UI.
- π Tamper-Evident Audit Trail β Append-only event storage with SHA-256 hash chains per session. Cryptographically linked and verifiable.
- π° Cost Tracking β Track token usage and estimated costs per session, per agent, over time. Alert on cost spikes.
- π¨ Alerting β Configurable rules for error rate, cost threshold, latency anomalies, and inactivity.
- π AgentKit Ecosystem β First-class integrations with AgentGate (approval flows) and FormBridge (data collection).
- π Self-Hosted β SQLite by default, no external dependencies. MIT licensed. Your data stays on your infrastructure.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Agents (Claude Desktop, Cursor, GPT-4, Custom) β
β β β
β β MCP Protocol (stdio) β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββ β
β β @agentlensai/mcp β β
β β Tools: session_start Β· log_event β β
β β session_end Β· query_events β β
β ββββββββββββββββ¬ββββββββββββββββββββββββ β
β β HTTP (batched events) β
βββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β @agentlensai/server β
β β
β ββββββββββββββ ββββββββββββββ ββββββββββββββ β
β β Ingest β β Query β β Alert β β
β β Engine β β Engine β β Engine β β
β βββββββ¬βββββββ βββββββ¬βββββββ ββββββββββββββ β
β βββββββββββββββββ β
β β β
β ββββββββ΄βββββββ βββββββββββββββ β
β β SQLite β β Dashboard β β
β β (append β β React SPA β β
β β only) β β (served β β
β βββββββββββββββ β at /) β β
β βββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Integrations: AgentGate βββ
FormBridge ββ€βββΊ POST /api/events/ingest
Generic βββββ (HMAC-SHA256 verified)
Opens on http://localhost:3400 with SQLite β zero config.
curl -X POST http://localhost:3400/api/keys \
-H "Content-Type: application/json" \
-d '{"name": "my-agent"}'
Save the als_... key from the response β it’s shown only once.
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"agentlens": {
"command": "npx",
"args": ["@agentlensai/mcp"],
"env": {
"AGENTLENS_API_URL": "http://localhost:3400",
"AGENTLENS_API_KEY": "als_your_key_here"
}
}
}
}
Cursor (.cursor/mcp.json):
{
"mcpServers": {
"agentlens": {
"command": "npx",
"args": ["@agentlensai/mcp"],
"env": {
"AGENTLENS_API_URL": "http://localhost:3400",
"AGENTLENS_API_KEY": "als_your_key_here"
}
}
}
}
Navigate to http://localhost:3400 β see sessions, timelines, analytics, and alerts in real time.
| Endpoint | Description |
|---|---|
POST /api/events |
Ingest events (batch) |
GET /api/events |
Query events with filters |
GET /api/sessions |
List sessions |
GET /api/sessions/:id/timeline |
Session timeline with hash chain verification |
GET /api/analytics |
Bucketed metrics over time |
GET /api/analytics/costs |
Cost breakdown by agent |
POST /api/alerts/rules |
Create alert rules |
POST /api/events/ingest |
Webhook ingestion (AgentGate/FormBridge) |
POST /api/keys |
Create API keys |
AgentLens works alongside two companion projects for unified agent lifecycle management:
Together: data collection β approvals β observability.
Approval events from AgentGate and form submissions from FormBridge appear directly in AgentLens session timelines, giving you a single view of the complete agent lifecycle.
# Clone and install
git clone https://github.com/amitpaz/agentlens.git
cd agentlens
pnpm install
# Run all checks
pnpm typecheck
pnpm test
pnpm lint
# Start dev server
pnpm dev
- Node.js β₯ 20.0.0
- pnpm β₯ 10.0.0