When AI coding agents meet a 500 000-line enterprise codebase, they spend most of their time navigating rather than solving. I built an MCP server that changed that equation entirely.
The system in question is a large Angular + .NET monolith — HR, finance, logistics, warehouse — serving 12 000 users across 9 modules. When I pointed Claude Code or Cursor at a bug, the agent would spend minutes opening files, guessing at architecture, and losing context before it could even start reasoning about the fix.
The root cause: AI agents lack the structural understanding that a senior developer builds up over months. They don't know which controller handles a given UI action, what permissions are required, or how data flows through NgRx stores to API calls.
Rather than fine-tuning or prompt engineering, I built structured code intelligence — static analysis tools that extract architectural knowledge — and served it through the Model Context Protocol (MCP), so any compatible agent can query it on demand.
The system has three components:
A set of extractors built with ts-morph and Angular's compiler API that parse:
These get linked into end-to-end traces: UI click → component method → store dispatch → effect → API call.
A Roslyn-based analyzer that extracts:
MiloAuthorize decorators with role/permission combinationsA Python server exposing 6 tools over the MCP protocol:
| Tool | Purpose |
|---|---|
trace_api_flow |
Given an endpoint, returns the full backend flow: controller → services → DB queries → response |
trace_ui_action |
Given a UI element, traces the complete path from click to API call |
module_context |
Returns architecture overview for a module (components, services, routes) |
find_ui_for_endpoint |
Reverse lookup — given a backend endpoint, finds all UI elements that call it |
db_schema |
Returns table structure, relationships, and scoping rules |
query_database |
Executes read-only SQL queries with injection prevention and row limits |
The server uses rapidfuzz for fuzzy endpoint matching (70% threshold), so agents don't need exact controller names.
I designed a 5-task benchmark from real commit history — ranging from simple bug fixes to full-stack feature additions:
Beyond coding speed, the MCP server also enabled bulk knowledge extraction: an MCP-equipped agent analyzed the entire frontend and backend and enriched all 715 chatbot actions with extracted business logic in 1.5 hours.
Why MCP over RAG? RAG would require chunking and embedding architectural knowledge, then hoping the retrieval picks the right chunks. MCP gives agents structured, queryable access — they ask specific questions and get precise answers. No hallucination risk from retrieved context.
Why static analysis over runtime tracing? Static analysis works without deploying the application, captures all code paths (not just exercised ones), and produces deterministic results. The tradeoff is that you miss runtime-only behaviors, but for architectural understanding that's acceptable.
Why fuzzy matching? Enterprise codebases have inconsistent naming. Controllers might be UserController, UsersController, or UserManagementController. A 70% fuzzy threshold handles these variations without returning false matches.
AI agents need architecture, not just code. Throwing raw files at an agent is like giving a new developer the codebase without any onboarding. Structured context transforms agent performance.
MCP is the right abstraction. It separates the intelligence extraction (which is codebase-specific) from the consumption (which is agent-agnostic). Any MCP-compatible agent benefits immediately.
The approach is replicable. The specific extractors are tailored to Angular + .NET, but the pattern — static analysis → structured JSON → MCP server — works for any stack. The investment in building code intelligence tools pays compound returns as more agents and use cases emerge.
Building this convinced me that the next wave of AI-assisted development isn't about better models — it's about better context infrastructure. The models are already capable; we just need to feed them the right information.