# Legacy System Pattern Matcher MCP for AI Agents AI Agent Connect

> Legacy System Pattern Matcher identifies hidden architectural patterns and non-standard structures in aging codebases. It provides your AI agent with the specific rules needed to modify old code without causing regressions or breaking custom ORM and framework-specific logic.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_yT8rHQbJrgjbeTzTwHPdFUB2tecMf5DDhoj7QYuQ/ai-agent-connect
- **Tags:** legacy-code, pattern-matching, risk-assessment, codebase-analysis, refactoring-safety

## Description

Working on a codebase that's been around for a decade is a minefield. You know the feeling: you try to refactor a single function, and suddenly a custom ORM pattern or a weirdly structured directory breaks something three modules away. This MCP acts as a safety net for your AI agent, giving it the context it needs to navigate old, messy, or non-standard code without making catastrophic mistakes. Instead of guessing how a specific framework or custom setup works, your agent can scan the files to find specific signatures and get clear instructions on how to interact with them safely. It identifies things like custom database connections or old-school module patterns and tells your agent exactly what to do—or more importantly, what not to do. By connecting this to your workflow through the Vinkius catalog, you turn an unpredictable AI agent into a cautious, informed collaborator that respects the constraints of your legacy environment. It's about moving fast on old code without the constant fear of breaking the build.

## Tools

### calculate_risk_assessment
Determines the danger level of modifying a specific file. It helps you decide if a change is too risky for an automated agent.

### get_pattern_details
Fetches the exact rules and protection requirements for a detected pattern. It tells your agent how to handle specific code structures.

### scan_codebase
Searches your files for framework signatures and custom patterns. It builds the map your agent needs to navigate the project.

## Prompt Examples

**Prompt:** 
```
Can you check if it's safe to modify the database connection logic in this folder?
```

**Response:** 
```
I've analyzed the directory. The database connection logic in `src/db/connection.js` is part of a custom ORM pattern. 

**Risk Assessment:**
* **Status:** Critical Risk
* **Pattern Detected:** Custom Legacy ORM
* **Required Action:** `wrap_dont_replace` 

I strongly recommend wrapping any new logic around the existing calls rather than attempting to rewrite the connection handler.
```

**Prompt:** 
```
What kind of legacy patterns are present in the current directory?
```

**Response:** 
```
The scan of the current directory has identified the following patterns:

| Pattern Type | Location | Risk Level |
| :--- | :--- | :--- |
| AngularJS Module | `src/legacy/app.js` | High |
| jQuery AJAX | `src/legacy/utils.js` | Medium |
| Custom ORM | `src/db/connection.js` | Critical |

There is a high density of legacy patterns in the `src/legacy` directory.
```

**Prompt:** 
```
I need to update the utility functions. Are there any specific rules I should follow?
```

**Response:** 
```
Yes. The utility functions in `src/legacy/utils.js` follow a specific pattern. To maintain compatibility, you must follow these rules:

* **`wrap_dont_replace`**: Do not overwrite existing functions; wrap them to preserve the original API surface.
* **`preserve_api_surface`**: Ensure that any new additions do not change the signature of existing exported methods.

Following these will prevent breaking the downstream dependencies.
```

## Capabilities

### Detect legacy architectural signatures
Finds specific framework patterns and non-standard directory structures within your code.

### Enforce safe modification rules
Provides specific instructions like wrapping instead of replacing to prevent breaking old logic.

### Evaluate file modification danger
Calculates a risk score to show how likely a change is to cause a regression.

### Retrieve specific protection requirements
Fetches the exact rules needed to maintain compatibility with custom ORMs or modules.

### Map codebase density
Identifies how heavily legacy patterns are concentrated in specific directories.

## Use Cases

### Safe Refactoring of Old Modules
An engineer needs to update a utility file in a massive jQuery-based project. They use scan_codebase to find the pattern and follow the rules to avoid breaking the UI.

### Modernizing Custom ORMs
A developer wants to move toward a modern database layer. They use get_pattern_details to ensure they wrap existing logic instead of deleting it entirely.

### Risk-Based Migration Planning
A lead dev uses calculate_risk_assessment to identify which parts of the codebase are too fragile to touch during a major version upgrade.

### Onboarding to Messy Projects
A new hire uses the MCP to quickly understand the non-standard directory structures and custom patterns used in a legacy enterprise app.

## Benefits

- Stop accidental regressions by using calculate_risk_assessment to check file danger before editing.
- Avoid breaking custom ORMs by following the specific rules provided by get_pattern_details.
- Identify hidden technical debt quickly using scan_codebase to find old framework signatures.
- Maintain code stability with deterministic rules like wrap_dont_replace for sensitive modules.
- Reduce manual auditing time by letting your agent automatically detect non-standard directory structures.

## How It Works

The bottom line is you get a set of guardrails that prevent your AI agent from breaking old code.

1. Connect the MCP to your AI client via Vinkius
2. Run a scan of your local directory to identify existing patterns
3. Receive specific safety rules and risk scores for every file identified

## Frequently Asked Questions

**How does the Legacy System Pattern Matcher prevent code breakage?**
It identifies specific, non-standard patterns in your code and provides your AI agent with deterministic rules, like telling it to wrap code instead of replacing it, to ensure changes don't break existing logic.

**Can I use this Legacy System Pattern Matcher with Cursor or VS Code?**
Yes, you can connect this MCP to any compatible client like Cursor, VS Code, or Windsurf through the Vinkius platform to start using it immediately.

**Will this Legacy System Pattern Matcher work on any programming language?**
It works on any codebase where it can identify patterns, specifically targeting custom ORMs, framework signatures, and non-standard directory structures regardless of the language.

**How accurate is the risk assessment in the Legacy System Pattern Matcher?**
The risk assessment is based on the density of legacy patterns and specific architectural signatures found during a scan, providing a concrete danger level for every file you intend to modify.

**Does the Legacy System Pattern Matcher replace my existing linting tools?**
No, it complements them. While linters find syntax and style issues, this MCP finds deep architectural patterns and provides the specific safety rules needed for complex, legacy environments.

**How does the tool identify legacy patterns?**
The tool uses deterministic AST and regex pattern matching to identify specific architectural or syntactical markers in the codebase.

**What are the interaction rules?**
The rules include `do_not_modernize` to prevent regressions, `wrap_dont_replace` to mandate adapters, `preserve_api_surface` for stability, and `test_before_changing` for safety verification.

**Can I use this with Claude Desktop?**
Yes, this MCP server can be connected to Claude Desktop, Cursor, VS Code, Windsurf, and any other MCP-compatible client via Vinkius Edge.