Code Intelligence & MCP Server

MCP Python TypeScript C# Roslyn Docker

Code Intelligence & MCP Server for Legacy Enterprise App — Defense Client (Switzerland)

Built static-analysis tools and an MCP server that gave AI coding agents full codebase understanding — cutting task completion time by 4.7x on a 500k+ LOC legacy system.

Show more ↓

1. Problem

The MILO5 enterprise portal (HR, finance, logistics, warehouse) is a large-scale Angular + .NET monolith serving 12 000 users. AI coding agents struggled with the codebase — they spent most of their time navigating files and guessing at architecture rather than solving problems. Additionally, the RAG chatbot's action data (see Action-Tree project) lacked backend context such as permissions, validations and service dependencies.

2. Solution Overview

I designed and built three tools that extract structured intelligence from both the frontend and backend, then serve it to AI agents via the Model Context Protocol:

Component Purpose Key Tech
Frontend Code Intelligence Parses Angular templates, NgRx state management and API proxies to trace UI click → store dispatch → effect → backend call TypeScript · ts-morph · Angular Compiler
Backend Code Intelligence Analyzes controllers, services, authorization attributes, DB schema, enums and data-scoping rules via Roslyn C# · .NET · Roslyn · SQL Server
MILO5 MCP Server Exposes 6 tools (trace API flow, trace UI action, module context, reverse UI lookup, DB schema, read-only SQL queries) over MCP Python · MCP SDK · rapidfuzz · Docker

3. Impact

  • AI coding agents completed 5 benchmark tasks in 3 min with MCP vs. 14 min without — a 4.7x speedup
  • Simple bug fixes dropped from ~2 min to 20–30 s per task
  • Full-stack feature task dropped from 6 min to 2 min
  • Enriched all 715 chatbot actions with extracted business logic (preconditions, permissions, service dependencies, error scenarios) — the MCP-equipped agent analyzed the entire frontend and backend in 1.5 hours
  • Demonstrated a replicable approach for making any legacy codebase AI-ready

4. My Contributions

Designed the full code-intelligence architecture; built the TypeScript frontend analyzer (6 extractors + trace builder), the C# backend analyzer (Roslyn-based controller, auth, schema, enum and scoping analysis) and the Python MCP server; defined the 5-task evaluation benchmark from real commit history; measured before/after performance; integrated extracted business logic into the RAG chatbot's action data.

5. Key Challenges & Mitigations

Challenge Mitigation & Result
Tracing UI events end-to-end through Angular + NgRx + API proxy layers Built a TraceBuilder that indexes and links template events → component methods → dispatched actions → effects → API calls
Extracting authorization from custom attributes (MiloAuthorize, role/permission combos) Roslyn semantic analysis with attribute-specific parsers → complete permission map per endpoint
Ensuring safe database access for AI agents Read-only SQL enforcement, pattern-based injection prevention, TOP 1000 row limit
Fuzzy endpoint lookup across 9 modules with hundreds of controllers rapidfuzz string matching (70 % threshold) on controller/action names → reliable tool results

6. Architecture

┌─────────────────────────────────────────────────────┐
│                   AI Coding Agent                   │
│               (Claude Code / Cursor)                │
└──────────────────────┬──────────────────────────────┘
                       │ MCP Protocol
┌──────────────────────▼──────────────────────────────┐
│                 MILO5 MCP Server                    │
│  trace_api_flow · trace_ui_action · module_context  │
│  find_ui_for_endpoint · db_schema · query_database  │
└──────┬───────────────────────────────────┬──────────┘
       │                                   │
┌──────▼──────────┐              ┌─────────▼─────────┐
│ analysis.json   │              │ schema_context.json│
│ (per module)    │              │ (DB metadata)      │
│                 │              │                    │
│ frontend-       │              │ tables · columns   │
│ analysis.json   │              │ FKs · enums        │
│ (per module)    │              │ scoping rules      │
└──────▲──────────┘              └─────────▲─────────┘
       │                                   │
┌──────┴──────────┐              ┌─────────┴─────────┐
│ Frontend Code   │              │ Backend Code      │
│ Intelligence    │              │ Intelligence      │
│ (TypeScript)    │              │ (C# / Roslyn)     │
└─────────────────┘              └───────────────────┘