Knip Mcp Server
About
This MCP server provides AI agents with powerful code cleanup capabilities through knip.dev integration. It's designed to work seamlessly with Cursor AI and other MCP-compatible tools to maintain clean, efficient codebases.
Details
- Author
- gtrias
- Downloads
- 363
- Categories
- Developer Tools
Jump to
- Comprehensive code analysis via knip
- Unused file, import, export, and dependency detection
- Safe removal with dry-run mode and automatic backups
- Full workspace and monorepo support
- Safety measures (file limits, critical‑file protection)
- Backup mechanisms before destructive operations
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
Knip Mcp ServerCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Install globally (npm install -g @genar/knip-mcp-server) or locally in your project, then run knip-mcp-server or npx @genar/knip-mcp-server. Configure via environment variables (KNIP_PROJECT_ROOT, KNIP_CONFIG_PATH, KNIP_BACKUP_DIR, KNIP_LOG_LEVEL, KNIP_SAFE_MODE). Integrate with Cursor AI by adding an MCP server entry, Cursor rules, or a per-project .mcp-config.json file.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"knip mcp server": {
"knip": {
"command": "npx",
"args": [
"@genar/knip-mcp-server"
],
"env": {
"KNIP_PROJECT_ROOT": ".",
"KNIP_LOG_LEVEL": "info",
"KNIP_SAFE_MODE": "true"
}
}
}
}
}
McpServers
{
"knip": {
"command": "npx",
"args": [
"@genar/knip-mcp-server"
],
"env": {
"KNIP_PROJECT_ROOT": ".",
"KNIP_LOG_LEVEL": "info",
"KNIP_SAFE_MODE": "true"
}
}
}
@genar/knip-mcp-server
A Model Control Protocol (MCP) server that integrates with knip.dev to help AI agents identify and clean up unused files, imports, exports, and dependencies in JavaScript/TypeScript projects.
Overview
This MCP server provides AI agents with powerful code cleanup capabilities through knip.dev integration. It's designed to work seamlessly with Cursor AI and other MCP-compatible tools to maintain clean, efficient codebases.
Features
- Code Analysis: Run comprehensive knip analysis to find unused code
- Unused File Detection: Identify files that are no longer referenced
- Import/Export Cleanup: Find and remove unused imports and exports
- Dependency Management: Detect unused npm dependencies and devDependencies
- Safe Operations: Built-in safety checks and backup mechanisms
- Workspace Support: Full support for monorepo and workspace setups
- Dry Run Mode: Preview changes before applying them
Installation
npm install -g @genar/knip-mcp-server
Or in your project:
npm install @genar/knip-mcp-server
Usage
As an MCP Server
Run the server directly:
knip-mcp-server
Or use npx:
npx @genar/knip-mcp-server
Configuration
Configure via environment variables:
export KNIP_PROJECT_ROOT="/path/to/your/project"
export KNIP_CONFIG_PATH="/path/to/knip.json"
export KNIP_BACKUP_DIR="/path/to/backups"
export KNIP_LOG_LEVEL="info"
export KNIP_SAFE_MODE="true"
Integration with Cursor AI
Option 1: MCP Server Configuration
1. In Cursor AI settings, navigate to MCP configuration
2. Add a new MCP server:
- Name: "Knip Code Cleanup"
- Command: npx @genar/knip-mcp-server
3. Save and restart Cursor AI
Option 2: Cursor Rules Configuration
You can also integrate this MCP server through Cursor's rules system by creating a .cursor/rules directory in your project root and adding the following configuration:
1. Create the rules directory structure:
mkdir -p .cursor/rules
2. Create a knip rule file (.cursor/rules/knip-mcp.md):
```markdown
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





