Refactor MCP
A Model Context Protocol server that provides powerful regex-based code refactoring and search tools for Coding Agents.
Tools
code_refactor
Refactor code by replacing search pattern with replace pattern using regex
code_search
Search for code patterns using regex and return file locations with line numbers
README
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:
// Replace foo() calls with bar() calls
code_refactor("foo\\((.+)\\)", "bar($1)")
// Before: let k = foo(1,2,3);
// After: let k = bar(1,2,3);
Context-aware refactoring:
// Only replace "legacy_sdk" within import statements
code_refactor("legacy_sdk", "brand_new_sdk", "import")
🔍 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:
code_search("foo\\(.+\\)")
// Result:
// ./src/utils.js (line: 15)
// ./src/helpers.ts (lines: 23-27)
Installation
Quick Start
# Install globally
npm install -g @myuon/refactor-mcp
# Or run directly with npx
npx @myuon/refactor-mcp@latest
For Development
# Clone and install dependencies
git clone https://github.com/myuon/refactor-mcp.git
cd refactor-mcp
npm install
Usage
Development
npm run dev # Run server in development mode
npm run build # Build for production
npm start # Run built server
Code Quality
npm run check # Run all quality checks
npm run lint # Run ESLint
npm run format # Format code with Prettier
npm test # Run tests
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:
claude mcp add refactor npx @myuon/refactor-mcp@latest
Manual Configuration
Add to your MCP client configuration:
{
"mcpServers": {
"refactor-mcp": {
"command": "npx",
"args": ["@myuon/refactor-mcp@latest"]
}
}
}
Alternative Configuration (Local Installation)
{
"mcpServers": {
"refactor-mcp": {
"command": "refactor-mcp"
}
}
}
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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.