refactor-mcp
About
Refactor code using regex-based search and replace.
Details
- Author
- myuon
- Categories
- Developer Tools
Jump to
Alternative Configuration (Local Installation)
{ "mcpServers": { "refactor-mcp": { "command": "refactor-mcp" } } }
- 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
- Install dependencies:npm install
- Run tests:npm test
- Check code quality:npm run check
- Build:npm run build
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
AI-to-AI code review platform — Claude, Codex, and Gemini cross-check each other via MCP, REST API, and CLI for consensus-based results.
A stateful LSP runtime for AI agents: warm language server sessions with 50+ tools for go-to-definition, find-references, diagnostics, rename, and more across 30+ languages.
Persistent code index using Tree-sitter for fast, precise code search. Replaces grep with ~50 token responses instead of 2000+.
Orchestrates a dual-AI engineering loop where a Primary AI plans and implements, while a Review AI validates and reviews, with continuous feedback for optimal code quality. Supports custom AI pairing (Claude, Codex, Gemini, etc.)
A Model Context Protocol (MCP) server that provides powerful refactoring tools for Coding Agents. It can run in two modes:
- MCP Server Mode(default): Integrates with MCP-compatible clients like Claude Code
- CLI Mode: Direct command-line usage for standalone refactoring tasks
This MCP server implements two main tools to assist with code refactoring:
Performs regex-based search and replace operations across files with advanced filtering capabilities.
- search_pattern(string) - Regular expression pattern to search for
- replace_pattern(string) - Replacement pattern (supports capture groups like $1, $2)
- context_pattern(string, optional) - Only replace matches within this context
- file_pattern(string, optional) - Glob pattern to limit files (e.g.,.js,src//.ts)
// 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);
// Only replace "legacy_sdk" within import statements code_refactor("legacy_sdk", "brand_new_sdk", "import")
Searches for regex patterns and returns file locations with precise line numbers.
- search_pattern(string) - Regular expression pattern to search for
- context_pattern(string, optional) - Filter matches by surrounding context
- file_pattern(string, optional) - Glob pattern to limit search scope
code_search("foo\\(.+\\)") // Result: // ./src/utils.js (line: 15) // ./src/helpers.ts (lines: 23-27)
MCP Server Mode(for Claude Code and other MCP clients):
# Install globally for MCP integration npm install -g @myuon/refactor-mcp # Or use with npx (recommended for MCP clients) npx @myuon/refactor-mcp@latest
CLI Mode(for direct command-line usage):
# Search for patterns npx @myuon/refactor-mcp@latest cli search -p "function.\(" -f "src//.js" # Refactor with preview npx @myuon/refactor-mcp@latest cli refactor -s "const (\w+)" -r "let \$1" --dry-run
# Clone and install dependencies git clone https://github.com/myuon/refactor-mcp.git cd refactor-mcp npm install
You can use the refactor tools directly from the command line by addingcliafter the main command:
# Search for patterns refactor-mcp cli search -p "function (.) \{" -f "src//.ts" # Search with matched content display refactor-mcp cli search -p "function (.) \{" -f "src//.ts" --print # Refactor with dry-run (preview changes) refactor-mcp cli refactor -s "const (\w+) = " -r "let \$1 = " --dry-run # Refactor with matched content display refactor-mcp cli refactor -s "const (\w+) = " -r "let \$1 = " --print --dry-run # Refactor with file pattern refactor-mcp cli refactor -s "old_function" -r "new_function" -f "src//.js" # Context-aware refactoring refactor-mcp cli refactor -s "legacy_sdk" -r "new_sdk" -c "import" -f "src//.ts"
- search- Search for code patterns
- -p, --pattern <pattern>- Regular expression pattern to search for
- -c, --context <context>- Optional context pattern to filter matches
- -f, --files <files>- Optional file glob pattern to limit search scope
- --print- Print matched content to stdout
- --matched- Show only matched text with capture groups
- -s, --search <search>- Regular expression pattern to search for
- -r, --replace <replace>- Replacement pattern (supports $1, $2, etc.)
- -c, --context <context>- Optional context pattern to filter matches
- -f, --files <files>- Optional file glob pattern to limit search scope
- --dry-run- Preview changes without modifying files
- --print- Print matched content and replacements to stdout
- When using capture groups in replacement patterns on the command line, escape the dollar sign:\$1,\$2, etc.
- Example:refactor-mcp cli refactor -s "const (\w+) = " -r "let \$1 = " --dry-run
- This prevents the shell from interpreting$1as a shell variable
By default,refactor-mcpruns as an MCP server via stdio transport:
# Run as MCP server (default mode) refactor-mcp # Or explicitly with npx npx @myuon/refactor-mcp@latest
npm run dev # Run server in development mode npm run dev:cli # Run CLI in development mode with arguments npm run cli # Run CLI directly (for testing) npm run build # Build for production npm start # Run built server (MCP mode)
npm run check # Run all quality checks npm run lint # Run ESLint npm run format # Format code with Prettier npm test # Run tests
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.
For Claude Code users, you can easily add this MCP server with:
claude mcp add refactor npx @myuon/refactor-mcp@latest
{ "mcpServers": { "refactor-mcp": { "command": "npx", "args": ["@myuon/refactor-mcp@latest"] } } }
Alternative Configuration (Local Installation)
{ "mcpServers": { "refactor-mcp": { "command": "refactor-mcp" } } }
- 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
- Install dependencies:npm install
- Run tests:npm test
- Check code quality:npm run check
- Build:npm run build
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
AI-to-AI code review platform — Claude, Codex, and Gemini cross-check each other via MCP, REST API, and CLI for consensus-based results.
A stateful LSP runtime for AI agents: warm language server sessions with 50+ tools for go-to-definition, find-references, diagnostics, rename, and more across 30+ languages.
Persistent code index using Tree-sitter for fast, precise code search. Replaces grep with ~50 token responses instead of 2000+.
Orchestrates a dual-AI engineering loop where a Primary AI plans and implements, while a Review AI validates and reviews, with continuous feedback for optimal code quality. Supports custom AI pairing (Claude, Codex, Gemini, etc.)
AmazingMCP — MCP Server for .NET / C# Codebases
An MCP server that gives AI agents deep understanding of C# codebases via Roslyn — type search, dependency graphs, usage analysis, and architecture overviews, all from a live in-memory compilation.
A platform-agnostic code analysis library with semantic search capabilities and MCP server support.
Enforce consistent C++ style and best practices across your codebase. Analyze naming conventions, memory safety, and const correctness, and get actionable modernization suggestions up to C++23. Accelerate reviews with ready-made prompts and quick access to curated guidelines.
AI-Safe Code Analysis with 113+ MCP tools for guard validation, memory, workflow, and testing.
A Rust-based CLI tool for code-related tasks, operating as an MCP server.
Provides AI assistants with a comprehensive, one-time analysis for complete codebase context and understanding.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





