When AI coding agents (Cursor, Claude Code, Windsurf) edit backend models or API routes in full-stack codebases, backend unit tests frequently pass while the frontend silently breaks in production:
- An agent modifies an API parameter or Pydantic/SQLAlchemy field in
backend/routes.py. - Backend tests pass in isolation. Nothing warns the agent.
- The React/Next.js client calling that endpoint across the boundary fails with runtime errors.
I built StackBridge-MCP, an open-source Model Context Protocol server that tracks cross-boundary contracts locally without running heavy test VMs.
Architecture & Approach
-
Tree-sitter AST Extraction: Parses Next.js (
fetch, Axios, React Query) β FastAPI routes β SQLAlchemy ORM models without heavy LSP sidecars or runtime imports. - SQLite Recursive CTEs: Stores graph relationships in a WAL-mode SQLite database, delivering 0.75 ms traversal latency.
- Baseline-Diffed Verification: Validates syntax and contract drift across affected files in 312 ms with zero false positives.
- Diagnostic Ranking: BFS graph-distance traversal ranks errors into root causes vs cascading breaks and generates immediate Git diff patches.
Benchmark Comparison
Measured on fastapi-realworld-example-app (44 files, 23 AST dependency nodes, 10 cross-boundary edges):
| Metric | Raw Codebase Dump | StackBridge Compact Slice | Improvement / Latency |
|---|---|---|---|
| Context Window Size | 19,705 tokens |
51 tokens |
π 99.74% Token Reduction |
| Blast Radius Traversal | Full-repo search: ~150 ms
|
SQLite Recursive CTE: 0.75 ms
|
β‘ 200x Faster Traversal |
| Compiler Verification | Global linter: ~3,500 ms
|
Baseline-Diffed Engine: 312 ms
|
π‘οΈ Zero False Positives |
| Automated Tests | β | 56 / 56 passing | β 100% Passing |
Quickstart
Run via uvx with zero local configuration:
bash
uvx stackbridge serve
Or install via pip:
Bash
pip install stackbridge
GitHub: https://github.com/ZainUlAbideen02/StackBridge-MCP
PyPI: https://pypi.org/project/stackbridge/0.1.0/
Top comments (1)
MCP solution