How to debug a production Laravel app with an AI agent
AI agents are already good at fixing bugs, when they can see the real failure. The catch is that production context lives in your observability tool, and what usually reaches the agent is a stack trace pasted from Slack: one frame of a much longer story. Here are two practical ways to hand an agent the whole story.
Why a stack trace isn't enough
A production bug is rarely just the exception. The N+1 that made the request slow enough to time out, the queued job that dispatched the failing code, the external call that returned garbage, what the same user did two requests earlier: that's the part you'd investigate yourself, and it's the part an agent needs too. Given one stack frame, an agent proposes a plausible fix for the symptom. Given the causal chain, it fixes the cause.
Option 1: copy the trace as Markdown
The lowest-friction version, and it works with any AI chat. Open a trace or an exception in Unravel and press Copy as Markdown: the failing span, its immediate cause, the normalized queries, N+1 clusters and the user's journey, as text structured for a model to read. Paste it into Claude Code, Cursor, or a plain chat window and ask what went wrong.
Option 2: connect the agent over MCP
Better: let the agent pull production context itself, so you never play courier. Unravel exposes an MCP server - connect Claude Code (or any MCP client) in the repo you're debugging:
claude mcp add --transport http unravel https://api.unravel.run/mcp
The exact command, with your key filled in, is in Settings → API keys in the dashboard (MCP access is available on the Solo plan and up). Once connected, the agent can search traces, read a full trace, compare two runs, inspect exceptions, find slow queries and read the current load, across every trace in your retention window; Unravel samples nothing.
What the workflow looks like
An alert tells you checkout is failing. Instead of opening dashboards, you ask the agent in your editor:
Why is checkout failing in production? Check the recent traces and fix it.
The agent searches recent failing traces on the checkout route, reads one, and sees what actually happened: the exception, the queued job it ran inside, the query that slowed everything down before it. Then it edits the code, grounded in what production did rather than what it guessed from a stack trace.
Keep it safe
-
MCP access is read-only: the agent can look, never mutate.
-
Each key is scoped to one project and one environment, shown once, and revocable in the dashboard.
-
Secrets are scrubbed on your server before anything is captured, so they're not in the data an agent can read either.
-
AI agents - the MCP connection and Copy as Markdown in depth.
-
AI agents docs - the exact tools, scope and limits.
-
Alerting - hear about the failure your agent is about to fix.