Debug replay endpoint
Debugging an MCP server through Claude Desktop is slow. You edit code, restart the client, open a chat, call the tool, then read the output. A plain HTTP endpoint sitting on the same service layer gives you a browser, curl, and the OpenAPI inspector for free. Same business logic, faster feedback loop.
from fastapi import APIRouter, HTTPException
from service import fetch_pr_diff, review_pr
router = APIRouter(prefix="/inspect", tags=["inspect"])
@router.get("/{owner}/{repo}/{pr_number}")
async def inspect_pr(owner: str, repo: str, pr_number: int):
try:
pr = await fetch_pr_diff(owner, repo, pr_number)
result = await review_pr(owner, repo, pr_number)
except Exception as exc:
raise HTTPException(status_code=502, detail=str(exc)) from exc
return {
"pr": {
"owner": pr.owner, "repo": pr.repo, "number": pr.pr_number,
"title": pr.title, "changed_files": pr.changed_files,
"diff_chars": len(pr.diff),
},
"review": result.model_dump(),
}One endpoint exercises the full pipeline. Open http://localhost:8000/docs and hit inspect from the Swagger UI. You get the typed request form, a response preview, and a replayable curl command, all without touching an MCP client.
Shared service layer
The MCP tools and the FastAPI inspector call the same business logic.
Quiz: Quiz
Loading practice…