MCP Hub
Back to servers

@agentlensai/mcp

Validation Failed

MCP server for AgentLens — instrument AI agents with zero code changes

npm18/wk
Stars
3
Updated
Mar 5, 2026
Validated
Mar 7, 2026

Validation Error:

Timeout after 45s

Quick Install

npx -y @agentlensai/mcp

🔍 AgentLens

Open-source observability & audit trail for AI agents

PyPI npm server npm mcp License: MIT Build Status

📖 Documentation · Quick Start · Dashboard · ☁️ Cloud


📑 Table of Contents


AgentLens is a flight recorder for AI agents. It captures every LLM call, tool invocation, approval decision, and error — then presents it through a queryable API and real-time web dashboard.

Four ways to integrate — pick what fits your stack:

IntegrationLanguageEffortCapture
🤖 OpenClaw PluginOpenClawCopy & enableEvery Anthropic call — prompts, tokens, cost, tools — zero code
🐍 Python Auto-InstrumentationPython1 lineEvery OpenAI / Anthropic / LangChain call — deterministic
🔌 MCP ServerAny (MCP)Config blockTool calls, sessions, events from Claude Desktop / Cursor
📦 SDKPython, TypeScriptCodeFull control — log events, query analytics, build integrations

🚀 Quick Start

Docker (recommended)

git clone https://github.com/agentkitai/agentlens
cd agentlens
cp .env.example .env
docker compose up
# Open http://localhost:3000

For production (auth enabled, Stripe, TLS):

docker compose -f docker-compose.yml -f docker-compose.prod.yml up

Without Docker

npx @agentlensai/server
# Opens on http://localhost:3400 with SQLite — zero config

Create an API Key

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. Then head to the Integration Guides to instrument your agent.

📖 Full setup guide →

🏗️ Architecture

graph TB
    subgraph Agents["Your AI Agents"]
        PY["Python App<br/>(OpenAI, Anthropic, LangChain)"]
        MCP_C["MCP Client<br/>(Claude Desktop, Cursor)"]
        TS["TypeScript App"]
        OC["OpenClaw Plugin"]
    end

    PY -->|"agentlensai.init()<br/>auto-instrumentation"| SERVER
    MCP_C -->|MCP Protocol| MCP_S["@agentlensai/mcp"]
    MCP_S -->|HTTP| SERVER
    TS -->|"@agentlensai/sdk"| SERVER
    OC -->|HTTP| SERVER

    subgraph Server["@agentlensai/server"]
        direction TB
        INGEST[Ingest Engine]
        QUERY[Query Engine]
        ALERT[Alert Engine]
        LLM_A[LLM Analytics]
        HEALTH[Health Scoring]
        COST[Cost Optimizer]
        REPLAY[Session Replay]
        BENCH[Benchmark Engine]
        GUARD[Guardrails]
    end

    SERVER --> DB[(SQLite / Postgres)]
    SERVER --> DASH["Dashboard<br/>(React SPA)"]

    EXT["AgentGate / FormBridge"] -->|Webhook| SERVER

🔧 Integration Guides

🤖 OpenClaw Plugin

If you're running OpenClaw, the AgentLens plugin captures every Anthropic API call automatically — prompts, completions, token usage, costs, latency, and tool calls.

cp -r packages/openclaw-plugin /usr/lib/node_modules/openclaw/extensions/agentlens-relay
openclaw config patch '{"plugins":{"entries":{"agentlens-relay":{"enabled":true}}}}'
openclaw gateway restart

Set AGENTLENS_URL if your AgentLens instance isn't on localhost:3000. See the plugin README for details.

🐍 Python Auto-Instrumentation

One line — every LLM call captured automatically across 9 providers (OpenAI, Anthropic, LiteLLM, AWS Bedrock, Google Vertex AI, Google Gemini, Mistral AI, Cohere, Ollama):

pip install agentlensai[all-providers]
import agentlensai

agentlensai.init(
    url="http://localhost:3400",
    api_key="als_your_key",
    agent_id="my-agent",
)
# Every LLM call is now captured automatically

Key guarantees: ✅ Deterministic · ✅ Fail-safe · ✅ Non-blocking · ✅ Privacy (init(redact=True))

📖 Python SDK full docs →

🔌 MCP Integration

For Claude Desktop, Cursor, or any MCP client — add to your config:

{
  "mcpServers": {
    "agentlens": {
      "command": "npx",
      "args": ["@agentlensai/mcp"],
      "env": {
        "AGENTLENS_API_URL": "http://localhost:3400",
        "AGENTLENS_API_KEY": "als_your_key_here"
      }
    }
  }
}

AgentLens ships 12 MCP tools — 5 core observability, 3 intelligence & analytics, 4 operations. Full MCP tool reference →

📖 MCP setup guide →

📦 Programmatic SDK

Python:

pip install agentlensai
from agentlensai import AgentLensClient
client = AgentLensClient("http://localhost:3400", api_key="als_your_key")
sessions = client.get_sessions()
analytics = client.get_llm_analytics()

TypeScript:

npm install @agentlensai/sdk
import { AgentLensClient } from '@agentlensai/sdk';
const client = new AgentLensClient({ baseUrl: 'http://localhost:3400', apiKey: 'als_your_key' });
const sessions = await client.getSessions();

📖 SDK reference →

✨ Key Features

  • 🐍 Python Auto-Instrumentationagentlensai.init() captures every LLM call across 9 providers automatically. Deterministic — no reliance on LLM behavior.
  • 🔌 MCP-Native — Ships as an MCP server. Works with Claude Desktop, Cursor, and any MCP client.
  • 🧠 LLM Call Tracking — Full prompt/completion visibility, token usage, cost aggregation, latency measurement, and privacy redaction.
  • 📊 Real-Time Dashboard — Session timelines, event explorer, LLM analytics, cost tracking, and alerting.
  • 🔒 Tamper-Evident Audit Trail — Append-only event storage with SHA-256 hash chains per session.
  • 💰 Cost Tracking — Track token usage and estimated costs per session, per agent, per model. Alert on cost spikes.
  • 🚨 Alerting — Configurable rules for error rate, cost threshold, latency anomalies, and inactivity.
  • ❤️‍🩹 Health Scores — 5-dimension health scoring with trend tracking.
  • 💡 Cost Optimization — Complexity-aware model recommendation engine with projected savings.
  • 📼 Session Replay — Step-through any past session with full context reconstruction.
  • ⚖️ A/B Benchmarking — Statistical comparison of agent variants using Welch's t-test and chi-squared analysis.
  • 🛡️ Guardrails — Automated safety rules with dry-run mode for safe testing.
  • 🔌 Framework Plugins — LangChain, CrewAI, AutoGen, Semantic Kernel — auto-detection, fail-safe, non-blocking.
  • 🔗 AgentKit Ecosystem — Integrations with AgentGate, FormBridge, Lore, and AgentEval.
  • 🔒 Tenant Isolation — Multi-tenant support with per-tenant data scoping and API key binding.
  • 🏠 Self-Hosted — SQLite by default, no external dependencies. MIT licensed.

📸 Dashboard

AgentLens ships with a real-time web dashboard for monitoring your agents.

📸 Dashboard Screenshots (click to expand)

Overview — At-a-Glance Metrics

Dashboard Overview

The overview page shows live metrics — sessions, events, errors, and active agents — with a 24-hour event timeline chart, recent sessions with status badges, and a recent errors feed.

Sessions — Track Every Agent Run

Sessions List

Every agent session with sortable columns: agent name, status, start time, duration, event count, error count, and total cost.

Session Detail — Timeline & Hash Chain

Session Detail

Full event timeline with tamper-evident hash chain verification. Filter by event type, view cost breakdown.

Events Explorer — Search & Filter Everything

Events Explorer

Searchable, filterable view of every event across all sessions.

🧠 LLM Analytics — Prompt & Cost Tracking

LLM Analytics

Total LLM calls, cost, latency, and token usage across all agents with model comparison.

🧠 Session Timeline — LLM Call Pairing

LLM Timeline

LLM calls in session timeline with model, tokens, cost, and latency.

💬 Prompt Detail — Chat Bubble Viewer

LLM Call Detail

Full prompt and completion in a chat-bubble style viewer with metadata panel.

❤️‍🩹 Health Overview — Agent Reliability

Health Overview

5-dimension health score for every agent with trend tracking.

💡 Cost Optimization — Model Recommendations

Cost Optimization

Analyzes LLM call patterns and recommends cheaper model alternatives with confidence levels.

📼 Session Replay — Step-Through Debugger

Session Replay

Step through any past session event by event with full context reconstruction.

⚖️ Benchmarks — A/B Testing for Agents

Benchmarks

Create and manage A/B experiments with statistical significance testing.

🛡️ Guardrails — Automated Safety Rules

Guardrails

Create and manage automated safety rules with trigger history and activity feed.

☁️ AgentLens Cloud

Don't want to self-host? AgentLens Cloud is a fully managed SaaS — same SDK, zero infrastructure:

import agentlensai
agentlensai.init(cloud=True, api_key="als_cloud_your_key_here", agent_id="my-agent")
  • Same SDK, one parameter change — switch url= to cloud=True
  • Managed Postgres — multi-tenant with row-level security
  • Team features — organizations, RBAC, audit logs, usage billing
  • No server to run — dashboard at app.agentlens.ai

📖 Cloud Setup Guide · Migration Guide · Troubleshooting

📦 Packages

Python (PyPI)

PackageDescriptionPyPI
agentlensaiPython SDK + auto-instrumentation for 9 LLM providersPyPI

TypeScript / Node.js (npm)

PackageDescriptionnpm
@agentlensai/serverHono API server + dashboard servingnpm
@agentlensai/mcpMCP server for agent instrumentationnpm
@agentlensai/sdkProgrammatic TypeScript clientnpm
@agentlensai/coreShared types, schemas, hash chain utilitiesnpm
@agentlensai/cliCommand-line interfacenpm
@agentlensai/dashboardReact web dashboard (bundled with server)private

🔌 API Overview

EndpointDescription
POST /api/eventsIngest events (batch)
GET /api/eventsQuery events with filters
GET /api/sessionsList sessions
GET /api/sessions/:id/timelineSession timeline with hash chain verification
GET /api/analyticsBucketed metrics over time

Full API Reference →

⌨️ CLI

npx @agentlensai/cli health                          # Overview of all agents
npx @agentlensai/cli health --agent my-agent          # Detailed health with dimensions
npx @agentlensai/cli optimize                          # Cost optimization recommendations

Both commands support --format json for machine-readable output. See agentlens health --help for all options.

🛠️ Development

git clone https://github.com/agentkitai/agentlens.git
cd agentlens
pnpm install

pnpm typecheck && pnpm test && pnpm lint  # Run all checks
pnpm dev                                   # Start dev server

Requirements: Node.js ≥ 20.0.0 · pnpm ≥ 10.0.0

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for setup instructions, coding standards, and the PR process.

🧰 AgentKit Ecosystem

ProjectDescription
AgentLensObservability & audit trail for AI agents⬅️ you are here
LoreCross-agent memory and lesson sharing
AgentGateHuman-in-the-loop approval gateway
FormBridgeAgent-human mixed-mode forms
AgentEvalTesting & evaluation framework
agentkit-meshAgent discovery & delegation
agentkit-cliUnified CLI orchestrator
agentkit-guardrailsReactive policy guardrails

📄 License

MIT © Amit Paz

Reviews

No reviews yet

Sign in to write a review