Skip to main content
Glama

Refactor MCP

by myuon

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 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)

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")

Searches for regex patterns and returns file locations with precise line numbers.

Parameters:

  • 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

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

  1. Install dependencies: npm install
  2. Run tests: npm test
  3. Check code quality: npm run check
  4. Build: npm run build

License

MIT

Install Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

A Model Context Protocol server that provides powerful regex-based code refactoring and search tools for Coding Agents.

  1. Features
    1. 🔧 code_refactor
    2. 🔍 code_search
  2. Installation
    1. Quick Start
    2. For Development
  3. Usage
    1. Development
    2. Code Quality
  4. MCP Integration
    1. Claude Code Integration
    2. Manual Configuration
    3. Alternative Configuration (Local Installation)
  5. Architecture
    1. Contributing
      1. License

        Related MCP Servers

        • A
          security
          A
          license
          A
          quality
          A 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 -
          12
          Python
          MIT License
          • Linux
          • Apple
        • -
          security
          A
          license
          -
          quality
          A 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 -
          9
          TypeScript
          MIT License
          • Linux
          • Apple
        • A
          security
          A
          license
          A
          quality
          A 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 -
          1
          22
          36
          JavaScript
          MIT License
        • A
          security
          A
          license
          A
          quality
          A 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 -
          3
          14
          JavaScript
          MIT License

        View all related MCP servers

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/myuon/refactor-mcp'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server