Integrates with ESLint for code quality checks through the npm run lint command
Integrates with Prettier for code formatting through the npm run format command
Built with TypeScript support, using the Model Context Protocol SDK for TypeScript
Provides testing capabilities through Vitest with comprehensive test coverage
Uses Zod schemas for type-safe input validation of parameters passed to the refactoring tools
refactor-mcp
A Model Context Protocol (MCP) server that provides powerful refactoring tools for Coding Agents.
Features
This MCP server implements two main tools to assist with code refactoring:
🔧 code_refactor
Performs regex-based search and replace operations across files with advanced filtering capabilities.
Parameters:
search_pattern
(string) - Regular expression pattern to search forreplace_pattern
(string) - Replacement pattern (supports capture groups like $1, $2)context_pattern
(string, optional) - Only replace matches within this contextfile_pattern
(string, optional) - Glob pattern to limit files (e.g.,*.js
,src/**/*.ts
)
Example:
Context-aware refactoring:
🔍 code_search
Searches for regex patterns and returns file locations with precise line numbers.
Parameters:
search_pattern
(string) - Regular expression pattern to search forcontext_pattern
(string, optional) - Filter matches by surrounding contextfile_pattern
(string, optional) - Glob pattern to limit search scope
Example:
Installation
Quick Start
For Development
Usage
Development
Code Quality
MCP Integration
This server uses the Model Context Protocol to communicate with compatible clients. It runs via stdio transport and can be integrated into any MCP-compatible environment.
Claude Code Integration
For Claude Code users, you can easily add this MCP server with:
Manual Configuration
Add to your MCP client configuration:
Alternative Configuration (Local Installation)
Architecture
- Framework: Model Context Protocol SDK for TypeScript
- Runtime: Node.js with ES modules
- Validation: Zod schemas for type-safe input validation
- File Operations: Native fs module with glob pattern matching
- Testing: Vitest with comprehensive test coverage
Contributing
- Install dependencies:
npm install
- Run tests:
npm test
- Check code quality:
npm run check
- Build:
npm run build
License
MIT
A Model Context Protocol server that provides powerful regex-based code refactoring and search tools for Coding Agents.
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that provides tools for code modification and generation via Large Language Models, allowing users to create, modify, rewrite, and delete files using structured XML instructions.Last updated -12PythonMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables AI agents to retrieve and understand entire codebases at once, providing tools to analyze local workspaces or remote GitHub repositories.Last updated -9TypeScriptMIT License
- AsecurityAlicenseAqualityA flexible Model Context Protocol server that makes documentation or codebases searchable by AI assistants, allowing users to chat with code or docs by simply pointing to a git repository or folder.Last updated -12236JavaScriptMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that helps large language models process code repositories by providing file tree generation, code merging, and code analysis capabilities.Last updated -314JavaScriptMIT License