Debug a Worker that's throwing 500s in production
When to use: Your Worker's error rate spiked. You want logs, recent deploys, and a diff of what changed — without opening the dashboard.
Prerequisites
- Cloudflare account OAuth-connected to your MCP client — First tool call triggers OAuth; grant the 'Workers Observability' and 'Workers Bindings' scopes
Flow
-
Tail recent Worker logs filtered by errorTail logs for Worker 'api-edge' in the last 15 minutes. Filter to status >= 500. Group by the first 100 chars of the error message.✓ Copied→ Top error templates with counts and timestamps
-
List recent deploymentsList the last 5 deployments of 'api-edge'. Show deploy time, author, and the version hash.✓ Copied→ Deploy timeline — correlate with error onset
-
Roll back if neededThe error spike starts after the deploy at 14:22. Roll 'api-edge' back to the previous version. Ask me before confirming.✓ Copied→ Confirmation prompt before destructive action
Outcome: A restored production Worker, with a clear 'deploy X caused errors Y' postmortem note.
Pitfalls
- Log tail is real-time only; can miss a burst that already passed — For historical windows, use the Logpush or Analytics Engine MCP tools instead of tail
- Rollback doesn't migrate D1/KV state — If the bad deploy ran migrations, rolling the Worker alone isn't enough — you may need a D1 restore too