gtrias/knip-mcp-server
If you are the rightful owner of knip-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
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.
The knip-mcp-server is a specialized MCP server designed to enhance codebase maintenance by integrating with knip.dev. It provides AI agents with the ability to perform comprehensive code analysis, identifying and removing unused files, imports, exports, and dependencies. This server is particularly beneficial for projects using JavaScript and TypeScript, ensuring that codebases remain clean and efficient. It supports monorepo and workspace setups, making it versatile for various project structures. With built-in safety checks, backup mechanisms, and a dry run mode, it ensures that all operations are safe and reversible. The server can be easily integrated with Cursor AI and other MCP-compatible tools, providing a seamless experience for developers looking to maintain high code quality standards.
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
Usages
usage with Cursor AI MCP Server Configuration
{ "servers": { "knip": { "command": "npx", "args": ["@genar/knip-mcp-server"], "env": { "KNIP_PROJECT_ROOT": ".", "KNIP_LOG_LEVEL": "info", "KNIP_SAFE_MODE": "true" } } } }
usage with Cursor AI Cursor Rules Configuration
# Knip Code Cleanup Rules You have access to the Knip MCP server for code cleanup tasks. Use these tools proactively to maintain clean code: ## Available Tools - `knip_scan` - Run comprehensive code analysis - `knip_get_unused_files` - Find unused files - `knip_get_unused_exports` - Find unused exports - `knip_get_unused_imports` - Find unused imports - `knip_get_unused_dependencies` - Find unused dependencies - `knip_remove_unused_files` - Safely remove unused files - `knip_remove_unused_imports` - Clean up unused imports - `knip_fix_issues` - Auto-fix common issues - `knip_get_config` - View knip configuration - `knip_validate_config` - Validate knip config ## Usage Guidelines 1. **After implementing features**: Always run `knip_scan` to identify cleanup opportunities 2. **Before commits**: Use `knip_fix_issues` with `dryRun: true` to preview cleanup 3. **Regular maintenance**: Run `knip_get_unused_dependencies` to audit packages 4. **Safety first**: Always use dry-run mode first, create backups for destructive operations ## Workflow Integration When asked to implement features: 1. Complete the implementation 2. Run `knip_scan` to analyze unused code 3. Use `knip_remove_unused_imports` to clean imports 4. Check `knip_get_unused_files` for orphaned files 5. Apply fixes with appropriate safety measures ## Safety Measures - All destructive operations default to dry-run mode - Backups are created automatically before modifications - File limits prevent accidental bulk deletions - Safe mode protects critical files (package.json, etc.) Remember: Always review suggestions before applying changes to ensure they don't break functionality.
usage with Per Project MCP Configuration
{ "servers": { "knip": { "command": "npx", "args": ["@genar/knip-mcp-server"], "env": { "KNIP_PROJECT_ROOT": ".", "KNIP_LOG_LEVEL": "info", "KNIP_SAFE_MODE": "true" } } } }
Tools
knip_scan
Run comprehensive knip analysis on your project.
knip_get_unused_files
Get a list of unused files in the project.
knip_get_unused_exports
Get unused exports organized by file.
knip_get_unused_imports
Get unused imports organized by file.
knip_get_unused_dependencies
Get unused npm dependencies and devDependencies.