FastAPI and Python error tracking your coding agent can read
Updated 2026-11-22
The Runheed Python SDK reports exceptions with the traceback and breadcrumbs. For FastAPI, one middleware records the request and every exception that escapes a route. Your agent reads them over MCP from Claude Code, Cursor or any MCP client.
Set it up
1.Install the SDK, and add the same URL to requirements.txt or pyproject.toml so your deploy installs it too.
terminalbashpip install https://runheed.com/dl/runheed-0.1.7-py3-none-any.whl2.Initialize it and add the middleware.
main.pypythonimport os import runheed from fastapi import FastAPI from runheed import FastAPIIntegration runheed.init(dsn=os.environ["RUNHEED_DSN"], environment=os.environ.get("ENVIRONMENT", "production")) app = FastAPI() integration = FastAPIIntegration() integration.setup(runheed.get_client()) app.add_middleware(integration.create_middleware())3.Connect your agent, then sign in when it asks (other clients: /connect).
terminalbashclaude mcp add --transport http runheed https://runheed.com/api/mcp
The npm and PyPI releases are not out yet, so these commands install the same package files straight from runheed.com. Nothing else changes when the registry versions ship.
What it catches
- Exceptions raised in route handlers, with method and URL
- Errors logged through the logging module (on by default)
- Errors you report with runheed.capture_exception(e)
What it does not do
- FastAPI BackgroundTasks run after the response, so wrap them in try/except with capture_exception (Celery task failures are reported on their own when Celery is installed)
- No performance tracing: Runheed tracks errors only
Then ask your agent
> what did the FastAPI routes raise since the last deploy? read the traceback of the top one, fix it and resolve it with the commit hash
Connect Runheed first: Claude Code, Cursor or another client. Then see how the agent fixes and resolves an error.
Common Python and FastAPI errors
- 422 Unprocessable Entity: {"detail":[{"type":"missing","loc":["body","email"],"msg":"Fi...
- pydantic_core._pydantic_core.ValidationError: 1 validation error for User email Field...
- RuntimeWarning: coroutine 'fetch_user' was never awaited
- psycopg.errors.UniqueViolation: duplicate key value violates unique constraint "users_e...
- ModuleNotFoundError: No module named 'x'
- ConnectionResetError: [Errno 104] Connection reset by peer
- sqlite3.OperationalError: database is locked
- redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection re...
- PermissionError: [Errno 13] Permission denied: '/app/data/report.csv'