MCP Server
Use Retrace as an MCP server for AI coding agents like Claude Code and Cursor.
Overview
Retrace provides a Model Context Protocol (MCP) server that lets AI coding agents search traces, recall memories, and inspect past executions directly from their IDE. This bridges your observability data with your development workflow — agents can learn from previous runs without leaving the editor.
Setup
Add Retrace to your MCP configuration file:
Claude Code (.claude/mcp.json):
{
"mcpServers": {
"retrace": {
"command": "npx",
"args": ["@retrace/api", "mcp"],
"env": {
"DATABASE_URL": "postgresql://...",
"GEMINI_API_KEY": "AIza..."
}
}
}
}Cursor (Settings → MCP Servers):
Use the same configuration format. Cursor reads MCP server definitions identically.
Windsurf (.windsurf/mcp.json):
{
"mcpServers": {
"retrace": {
"command": "npx",
"args": ["@retrace/api", "mcp"],
"env": {
"DATABASE_URL": "postgresql://...",
"GEMINI_API_KEY": "AIza..."
}
}
}
}Environment Variables
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection string for your Retrace database |
GEMINI_API_KEY | Yes | Used for Retrace AI capabilities |
Available Tools
| Tool | Description | Parameters |
|---|---|---|
list_traces | List recent agent traces | limit, status |
get_trace | Get a trace with all child spans | trace_id |
search_spans | Semantic search across span content | query, limit |
store_memory | Store a fact or preference | key, value, scope, category |
recall_memories | Search memories semantically | query, limit |
get_tape | Retrieve a shareable tape by slug | slug |
Example Prompts
Once configured, ask your AI coding agent natural-language questions:
- "What traces failed recently?" → calls
list_traceswithstatus: "failed" - "Search for spans where the agent called web_search" → calls
search_spans - "Remember that the user prefers TypeScript" → calls
store_memory - "What do we know about the API rate limits?" → calls
recall_memories - "Show me the demo tape" → calls
get_tape
Use Cases
Debugging — When an agent run fails, ask your coding agent to pull the trace and inspect which span errored. It can read inputs, outputs, and error messages without you opening the dashboard.
Knowledge persistence — Store architectural decisions, user preferences, or project conventions as memories. Your coding agent recalls them in future sessions automatically.
Learning from history — Search past successful traces to understand how a workflow executed, then replicate or improve the pattern.
Troubleshooting
| Issue | Solution |
|---|---|
| Tools not appearing | Restart your IDE after editing the MCP config |
| Connection refused | Verify DATABASE_URL is reachable from your machine |
| Search returns empty | Confirm GEMINI_API_KEY is valid |
[!NOTE] The MCP server runs locally and connects directly to your database. No data is sent to Retrace cloud servers — all queries execute against your own PostgreSQL instance.