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. 1.Install the SDK, and add the same URL to requirements.txt or pyproject.toml so your deploy installs it too.

    terminalbash
    pip install https://runheed.com/dl/runheed-0.1.7-py3-none-any.whl
  2. 2.Initialize it and add the middleware.

    main.pypython
    import 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. 3.Connect your agent, then sign in when it asks (other clients: /connect).

    terminalbash
    claude 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

Read next for Python and FastAPI

7-day trial, then $29/moOther agents and editorsCancel any time from the billing portal