Skip to main content
Glama
MMI Architecture Analyzer

MMI Architecture Analyzer

by lady-logic

MMI Architecture Analyzer

Model Context Protocol (MCP) server for analyzing C# project architecture quality using the MMI (Modularity Maturity Index) framework by Carola Lilienthal.

Overview

This MCP server provides automated analysis of .NET/C# projects to assess architecture quality across four critical dimensions from Carola Lilienthal's MMI framework:

  • Dimension 2: Layering - Validates Clean Architecture layer dependencies

  • Dimension 5: Encapsulation - Analyzes public vs internal type visibility

  • Dimension 8: Abstraction Levels - Detects mixing of business logic with technical details

  • Dimension 9: Circular Dependencies - Identifies dependency cycles using Tarjan's algorithm

Related MCP server: Code-Oracle

Features

Token-Optimized Reports: Compact mode reduces token usage by 66%
Interactive Heatmap: D3.js visualization with cycle detection
Incremental Analysis: File-hash caching for 70% faster monitoring
Live Monitoring: Real-time analysis with trend tracking
Cycle Detection: Graph-based circular dependency analysis with visual highlighting

Installation

Prerequisites

  • Node.js 18 or higher

  • Cursor IDE

Setup

  1. Clone this repository:

git clone https://github.com/lady-logic/mmi-analyzer.git
cd mmi-analyzer
  1. Install dependencies:

npm install
  1. Configure in Cursor:

Add to your Cursor MCP settings (~/.cursor/config.json or via Settings β†’ MCP):

{
  "mcpServers": {
    "mmi-analyzer": {
      "command": "node",
      "args": ["C:/path/to/mmi-analyzer/src/server.js"]
    }
  }
}

Note: Use absolute paths. On Windows, use forward slashes.

  1. Restart Cursor

Usage

The MMI Analyzer provides seven tools accessible via Cursor's AI assistant:

1. Complete MMI Analysis

analyze_mmi(projectPath: "D:/Projects/MyApp")
analyze_mmi(projectPath: "D:/Projects/MyApp", mode: "detailed")  // Full report

Runs all four dimension analyses and provides an overall architecture quality score.

2. Interactive Architecture Heatmap

visualize_architecture(projectPath: "D:/Projects/MyApp")

Generates D3.js visualization showing:

  • Files as nodes colored by quality score (green=excellent, red=critical)

  • Dependencies as links (gray=normal, red=violations, pink=cycles)

  • Animated pulsing for circular dependencies

  • Interactive filtering by layer or cycles

  • Click nodes to see detailed issues

3. Circular Dependency Analysis

analyze_cycles(projectPath: "D:/Projects/MyApp")
analyze_cycles(projectPath: "D:/Projects/MyApp", mode: "detailed")

Detects circular dependencies across the entire project:

  • Uses graphlib's Tarjan algorithm for cycle detection

  • Analyzes ALL C# dependencies (using statements)

  • Severity classification:

    • πŸ”΄ CRITICAL: Domain layer involved in cycle

    • 🟠 HIGH: 2-way circular dependency

    • 🟑 MEDIUM: 3-4 files in cycle

    • πŸ”΅ LOW: 5+ files in cycle

  • Shows complete cycle paths

4. Live Monitoring

start_monitoring(projectPath: "D:/Projects/MyApp")
get_monitoring_status()
stop_monitoring(projectPath: "D:/Projects/MyApp")

Watches .cs files and automatically analyzes changes with trend visualization.

5. Layering Analysis

analyze_layering(projectPath: "D:/Projects/MyApp")

Detects Clean Architecture violations (e.g., Domain depending on Infrastructure).

6. Encapsulation Analysis

analyze_encapsulation(projectPath: "D:/Projects/MyApp")

Identifies over-exposed types that should be internal.

7. Abstraction Level Analysis

analyze_abstraction(projectPath: "D:/Projects/MyApp")

Finds mixing of business logic with technical details (SQL, HTTP, File I/O).

Report Modes

Compact Mode (Default)

  • Token-optimized output (~66% reduction)

  • Grouped violations

  • Concise recommendations

  • Perfect for quick checks and monitoring

Detailed Mode

  • Full violation listings

  • Code examples

  • Comprehensive tables

  • Ideal for documentation and deep analysis

Example Output

# Complete MMI Analysis Report

Overall MMI Score: 4.2/5 (Gut)

## MMI Scorecard
| Dimension              | Score | Level      | Status |
|------------------------|-------|------------|--------|
| Layering               | 5/5   | Exzellent  | βœ…     |
| Encapsulation          | 4/5   | Gut        | βœ…     |
| Abstraction Levels     | 3/5   | Akzeptabel | 🟑     |
| Circular Dependencies  | 5/5   | Exzellent  | βœ…     |

## 🎯 Priority Actions
1. **Fix abstraction mixing** - Remove SQL queries from Domain layer

Heatmap Visualization

The interactive heatmap provides real-time visual feedback:

Color Coding:

  • 🟒 Green: Excellent (4.5-5.0)

  • πŸ”΅ Blue: Good (3.5-4.5)

  • 🟠 Orange: Acceptable (2.5-3.5)

  • πŸ”΄ Red: Critical (<2.5)

  • 🟣 Pink: Circular dependency

Interactive Features:

  • Drag nodes to rearrange

  • Zoom and pan

  • Filter by layer or cycles

  • Click nodes for detailed issues

  • Animated pink pulsing links show cycles

Architecture

mmi-analyzer/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ server.js              # MCP server implementation
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── report-config.js   # Report mode configuration
β”‚   β”œβ”€β”€ analyzers/
β”‚   β”‚   β”œβ”€β”€ layering.js        # Dimension 2: Layer dependencies
β”‚   β”‚   β”œβ”€β”€ encapsulation.js   # Dimension 5: Type visibility
β”‚   β”‚   β”œβ”€β”€ abstraction.js     # Dimension 8: Abstraction mixing
β”‚   β”‚   └── cycle-analyzer.js  # Dimension 9: Circular dependencies
β”‚   β”œβ”€β”€ formatters/            # Report formatters (compact/detailed)
β”‚   β”‚   β”œβ”€β”€ cycle-formatter.js # Cycle-specific formatting
β”‚   β”‚   └── combined-formatter.js # 4D MMI reports
β”‚   β”œβ”€β”€ monitoring/            # File watching & history
β”‚   β”œβ”€β”€ visualizations/        # Heatmap generator with cycle viz
β”‚   └── utils/
β”‚       └── file-cache.js      # Hash-based caching
β”œβ”€β”€ package.json
└── README.md

Scoring System

MMI Scores (0-5):

  • 5 - Exzellent: State-of-the-art architecture

  • 4 - Gut: Strong architecture, minor improvements needed

  • 3 - Akzeptabel: Solid foundation, some refactoring recommended

  • 2 - VerbesserungswΓΌrdig: Significant technical debt

  • 1 - Schlecht: Major refactoring required

  • 0 - Kritisch: Architecture fundamentally broken

Cycle Scoring:

  • 0 cycles = 5 points

  • <1% files in cycles = 4 points

  • <3% files in cycles = 3 points

  • <5% files in cycles = 2 points

  • <10% files in cycles = 1 point

  • β‰₯10% files in cycles = 0 points

Performance

  • Compact reports: ~2,400 tokens (vs. 7,000 detailed)

  • Monitoring: Only analyzes changed files (70% reduction)

  • Caching: MD5 hash-based file tracking

  • Cycle detection: O(V + E) using Tarjan's SCC algorithm

  • First analysis: Full scan, subsequent: incremental

Breaking Cycles

When circular dependencies are detected, the tool suggests resolution strategies:

  1. Dependency Inversion - Introduce interfaces

  2. Event-Driven Architecture - Use message bus (e.g., MassTransit)

  3. Extract Common Dependencies - Create shared module

  4. Merge Components - Combine artificially separated code

  5. Anti-Corruption Layer - Add translation layer

Troubleshooting

Server not connecting

  1. Check absolute paths in Cursor config

  2. Verify Node.js version: node --version (needs 18+)

  3. Check logs: mmi-analyzer.log in server directory

No analysis results

  • Ensure the project path contains .cs files

  • Verify project follows folder structure (Domain/, Application/, Infrastructure/)

Cache issues

  • Delete .mmi-cache.json in project root to force full re-analysis

Cycles not detected

  • Ensure files have proper namespace declarations

  • Check that using statements reference project namespaces

  • Multiple files can share the same namespace (supported)

Contributing

Contributions welcome! This is an experimental tool for learning MCP server development.

License

MIT

References


Status: Experimental | Version: 0.4.0

Available Tools

9 tools
analyze_abstractionC

Analyzes separation of abstraction levels. Detects mixing of business logic (Domain/Application) with technical details (SQL, HTTP, File I/O). Identifies violations of clean separation.

Inputs: projectPath (required), mode.

analyze_cyclesB

Analyzes circular dependencies (cycles) in the codebase. Detects files that depend on each other in a circular way, which violates good architecture principles. Critical when Domain layer is involved.

Inputs: projectPath (required), mode.

analyze_encapsulationC

Analyzes encapsulation quality by checking public vs internal visibility of classes, interfaces, and records. Identifies over-exposed types that should be internal.

Inputs: projectPath (required), mode.

analyze_layeringB

Analyzes Clean Architecture layering violations in a C# project. Checks if Domain/Application/Infrastructure layers follow dependency rules.

Inputs: projectPath (required), mode.

analyze_mmiB

Complete MMI (Modularity Maturity Index) analysis. Runs all three dimensions: Layering (Dimension 2), Encapsulation (Dimension 5), and Abstraction Levels (Dimension 8). Provides overall architecture quality score.

Inputs: projectPath (required), mode.

get_monitoring_statusB

Shows status of all monitored projects with current scores and trends.

Inputs: no named parameters.

start_monitoringB

Starts continuous MMI monitoring for a C# project. Watches .cs files and automatically analyzes on changes. Stores score history over time.

Inputs: projectPath (required).

stop_monitoringB

Stops MMI monitoring for a project. Preserves history.

Inputs: projectPath (required).

visualize_architectureC

Generate interactive architecture heatmap visualization with D3.js. Shows files as nodes colored by score (green=good, red=critical), dependencies as links, violations highlighted. Click nodes to see details.

Inputs: projectPath (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 9 tools

    Disambiguation4/5

    Most tools have distinct purposes, such as analyze_abstraction for abstraction levels and analyze_cycles for circular dependencies, but analyze_mmi overlaps by running multiple analyses that other tools handle individually, which could cause confusion in tool selection. The monitoring tools (get_monitoring_status, start_monitoring, stop_monitoring) are clearly separate from analysis tools, reducing overall ambiguity.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case, such as analyze_abstraction, get_monitoring_status, and visualize_architecture. This uniformity makes the tool set predictable and easy to navigate, with no deviations in naming conventions across the nine tools.

    Tool Count5/5

    With 9 tools, the count is well-scoped for an architecture analyzer server, covering analysis, monitoring, and visualization aspects without being overwhelming. Each tool serves a clear role, such as specific analyses or monitoring controls, making the set appropriately sized for the domain.

    Completeness4/5

    The tool set provides comprehensive coverage for architecture analysis, including specific checks (e.g., layering, encapsulation), overall scoring (analyze_mmi), monitoring lifecycle (start/stop/get status), and visualization. A minor gap is the lack of tools for fixing or suggesting corrections for identified violations, but agents can work around this by using analysis results to guide manual improvements.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers