This guide walks you through installing and using agtrace to monitor AI agent sessions and enable agents to query their execution history.
agtrace works in two modes:
- MCP Server — Gives agents access to their session history (recommended)
- CLI Tools — For manual session inspection and debugging
For both modes, install globally:
npm install -g @lanegrid/agtraceIf you prefer not to install globally, run via npx.
Note: In the examples below, replace agtrace with npx @lanegrid/agtrace.
npx @lanegrid/agtrace@latest initcargo install agtraceLet your AI agent query its execution history by connecting agtrace via MCP:
1. Initialize agtrace:
agtrace init2. Connect to your AI assistant:
For Claude Code:
claude mcp add agtrace -- agtrace mcp serveFor Codex (OpenAI):
codex mcp add agtrace -- agtrace mcp serveFor Claude Desktop, add to claude_desktop_config.json:
{
"mcpServers": {
"agtrace": { "command": "agtrace", "args": ["mcp", "serve"] }
}
}3. Start using it:
Now your agent can query its own history:
- "What did we decide about the database schema?"
- "Show me errors from previous attempts"
- "Continue where we left off yesterday"
See MCP Integration Guide for details.
For manual session inspection and debugging:
1. Initialize agtrace:
agtrace init2. Navigate to your project:
cd /path/to/your/project3. Start live monitoring:
agtrace watch4. Start your AI agent (same directory):
claude # or codex, gemini, etc.5. Explore session history:
agtrace session list
agtrace session show <session_id>
agtrace lab grep "error" --json- Learn about watch command for live monitoring
- Explore session command for history inspection
- Understand CWD-scoped monitoring