# Import Order Enforcer MCP for AI Agents MCP

> Import Order Enforcer MCP keeps your codebase clean and predictable. It uses AST parsing to automatically group, sort, and fix import statements in your source files. No more messy, inconsistent imports or unused code fragments left behind after refactoring. It's the easiest way to keep your TypeScript or JavaScript files organized without manual linting rules or manual editing.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_7L2p3lLlByzqOACQkcDbCHZPuRJAao4wrAm0ajfB/mcp
- **Tags:** typescript, ast, linting, refactoring, clean-code, import-ordering

## Description

Keeping a clean codebase is hard enough when you're constantly refactoring. Every time you move a file or change a dependency, your imports get messy. You end up with a group of built-in modules, built-in modules, external libraries, and internal project files all mixed together in no particular order. It's distracting and makes reading code is harder than it should be. This MCP lets your agent to look at your source code and fix the imports for you. Instead of manually hunting through files to find dead code or reordering them alphabetically, your agent can just handle it. You can connect this to your preferred AI client and use the Vinkius catalog to access it instantly. It ensures that every file follows a consistent structure where imports are highly predictable and easy to scan. Your agent can identify exactly which lines of code are no longer needed and even rebuild the entire import block to be perfectly clean and sorted.

## Tools

### detect_unused_imports
Your agent can scan your code to find any imports that are no longer being used in your file.

### fix_imports
Generates a clean, properly sorted and grouped import block for your source files.

### validate_imports
Checks if your current import statements follow the rules for the project's structure.

## Prompt Examples

**Prompt:** 
```
Are there any unused imports in this code? 
import { useState, useEffect } from 'react';
import { data } from './utils';
const x = 10;
```

**Response:** 
```
The following imports are unused: 'useState' at line 1, 'useEffect' at line 1.
```

**Prompt:** 
```
Check if my imports follow the rules for this file: 
import { z } from 'zod';
import fs from 'fs';
```

**Response:** 
```
The import order is valid according to your configuration.
```

**Prompt:** 
```
Fix the imports in this block: 
import { b } from 'pkg-b';
import { a } from 'pkg-a';
```

**Response:** 
```
import { a } from 'pkg-a';
import { b } from 'pkg-b';
```

## Capabilities

### Clean up dead code
Your agent can find and remove unused imports that clutter your files.

### Clean up dead code
Your agent can identify and remove unused imports that clutter your files.

## Use Cases

### Cleaning up after a refactor
A developer is moving components from one folder to path/to/component. They ask their agent to check the file for any unused imports and fix the the order of imports.

## Benefits

- [object Object]
- [object Object]

## How It Works

The bottom line is you get perfectly organized, alphabetically sorted, and dead-code-free imports in every file you touch.

1. Connect the Import Order Enforcer MCP to your AI client.
2. Point your agent to a specific source file or directory containing messy imports.
3. Your agent uses AST parsing to analyze and rebuild the sorted, clean import block.

## Frequently Asked Questions

**How can I find unused imports in my file?**
Use the `detect_unused_imports` tool by providing your file content; it will return a list of all identifiers that are declared but never used.

**Can this tool fix my import order automatically?**
Yes, the `generate_fixed_import_block` tool analyzes your current imports and returns a perfectly formatted block following your specified rules.

**Does it support custom groups?**
Yes, you can define specific grouping logic for 'builtin', 'external', 'internal', 'parent', and 'sibling' paths.