{"_id":"@myuon/refactor-mcp","_rev":"4-3aeb62cb2edd6ae7e1fded735b186467","name":"@myuon/refactor-mcp","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@myuon/refactor-mcp","version":"1.0.0","keywords":["mcp","model-context-protocol","refactoring","code-transformation","regex","search-replace"],"author":{"name":"myuon"},"license":"MIT","_id":"@myuon/refactor-mcp@1.0.0","maintainers":[{"name":"myuon","email":"ioi.joi.koi.loi@gmail.com"}],"homepage":"https://github.com/myuon/refactor-mcp#readme","bugs":{"url":"https://github.com/myuon/refactor-mcp/issues"},"bin":{"refactor-mcp":"dist/server.js"},"dist":{"shasum":"fc7685e6021b2b586db48093b7aa3f1015c1820d","tarball":"https://registry.npmjs.org/@myuon/refactor-mcp/-/refactor-mcp-1.0.0.tgz","fileCount":6,"integrity":"sha512-V2adcnoUR85DD1r648/1bN4qZG4WIrrG6SvJNa3FllH0/P9oriBdsgiruonWQ3fFG/gUfA021/7yZj9lOdn4Kg==","signatures":[{"sig":"MEUCIQCXMxZtpg5vg95iEp12QXMv6zUNvhEUkRjV7NPpR9FOngIgMZL2echIw+rXlOX0fZGIIKua+IEPXrj5kAo72wQEDwM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24215},"main":"dist/server.js","type":"module","types":"./dist/server.d.ts","engines":{"node":">=18.0.0"},"gitHead":"caae72c39a489d2823cb9b83d9515f0b5904b628","scripts":{"dev":"tsx src/server.ts","lint":"eslint src/**/*.ts tests/**/*.ts","test":"vitest","build":"tsc","check":"npm run type-check && npm run lint && npm run format:check && npm run test:run","start":"node dist/server.js","format":"prettier --write src/**/*.ts tests/**/*.ts","test:ui":"vitest --ui","lint:fix":"eslint src/**/*.ts tests/**/*.ts --fix","test:run":"vitest run","type-check":"tsc --noEmit","format:check":"prettier --check src/**/*.ts tests/**/*.ts","test:coverage":"vitest run --coverage","prepublishOnly":"npm run check && npm run build"},"_npmUser":{"name":"myuon","actor":{"name":"myuon","type":"user","email":"ioi.joi.koi.loi@gmail.com"},"email":"ioi.joi.koi.loi@gmail.com"},"repository":{"url":"git+https://github.com/myuon/refactor-mcp.git","type":"git"},"_npmVersion":"10.9.2","description":"MCP server for refactoring tools","directories":{},"_nodeVersion":"23.4.0","dependencies":{"zod":"^3.22.4","glob":"^11.0.3","@modelcontextprotocol/sdk":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.0.0","eslint":"^9.30.0","vitest":"^3.2.4","prettier":"^3.6.2","@eslint/js":"^9.30.0","@vitest/ui":"^3.2.4","typescript":"^5.0.0","@types/node":"^20.0.0","@types/eslint__js":"^8.42.3","typescript-eslint":"^8.35.0","eslint-config-prettier":"^10.1.5","eslint-plugin-prettier":"^5.5.1"},"_npmOperationalInternal":{"tmp":"tmp/refactor-mcp_1.0.0_1751184187508_0.17699945302935594","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@myuon/refactor-mcp","version":"1.1.0","keywords":["mcp","model-context-protocol","refactoring","code-transformation","regex","search-replace"],"author":{"name":"myuon"},"license":"MIT","_id":"@myuon/refactor-mcp@1.1.0","maintainers":[{"name":"myuon","email":"ioi.joi.koi.loi@gmail.com"}],"homepage":"https://github.com/myuon/refactor-mcp#readme","bugs":{"url":"https://github.com/myuon/refactor-mcp/issues"},"bin":{"refactor-mcp":"dist/server.js"},"dist":{"shasum":"3c37b7d7337f14749da8f9ef8c7bc51e255a9b87","tarball":"https://registry.npmjs.org/@myuon/refactor-mcp/-/refactor-mcp-1.1.0.tgz","fileCount":6,"integrity":"sha512-6UAGmYBALvN+/IGtlVTXQt/4hsL/mU8jlFm5AzVJr+vcvy8uo+9bX/3IZsxSHPAfNFgbVpgQrk3MMBii3rm/KA==","signatures":[{"sig":"MEUCIH2Hd9fixOkiC7sL1xwEUH4Uw65hJwAAyyX44O/U+WrMAiEAiSc0uA1CNPjTFRoMgKNc64/ixTYPhZkGHtWp5cmF4xw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26026},"main":"dist/server.js","type":"module","types":"./dist/server.d.ts","engines":{"node":">=18.0.0"},"gitHead":"63edf06fea0a504482ad927a759251caaa588819","scripts":{"dev":"tsx src/server.ts","lint":"eslint src/**/*.ts tests/**/*.ts","test":"vitest","build":"tsc","check":"npm run type-check && npm run lint && npm run format:check && npm run test:run","start":"node dist/server.js","format":"prettier --write src/**/*.ts tests/**/*.ts","test:ui":"vitest --ui","lint:fix":"eslint src/**/*.ts tests/**/*.ts --fix","test:run":"vitest run","type-check":"tsc --noEmit","format:check":"prettier --check src/**/*.ts tests/**/*.ts","test:coverage":"vitest run --coverage","prepublishOnly":"npm run check && npm run build"},"_npmUser":{"name":"myuon","actor":{"name":"myuon","type":"user","email":"ioi.joi.koi.loi@gmail.com"},"email":"ioi.joi.koi.loi@gmail.com"},"repository":{"url":"git+https://github.com/myuon/refactor-mcp.git","type":"git"},"_npmVersion":"10.9.2","description":"MCP server for refactoring tools","directories":{},"_nodeVersion":"23.4.0","dependencies":{"zod":"^3.22.4","glob":"^11.0.3","@modelcontextprotocol/sdk":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.0.0","eslint":"^9.30.0","vitest":"^3.2.4","prettier":"^3.6.2","@eslint/js":"^9.30.0","@vitest/ui":"^3.2.4","typescript":"^5.0.0","@types/node":"^20.0.0","@types/eslint__js":"^8.42.3","typescript-eslint":"^8.35.0","eslint-config-prettier":"^10.1.5","eslint-plugin-prettier":"^5.5.1"},"_npmOperationalInternal":{"tmp":"tmp/refactor-mcp_1.1.0_1751191275525_0.9919445925954493","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@myuon/refactor-mcp","version":"1.1.1","keywords":["mcp","model-context-protocol","refactoring","code-transformation","regex","search-replace"],"author":{"name":"myuon"},"license":"MIT","_id":"@myuon/refactor-mcp@1.1.1","maintainers":[{"name":"myuon","email":"ioi.joi.koi.loi@gmail.com"}],"homepage":"https://github.com/myuon/refactor-mcp#readme","bugs":{"url":"https://github.com/myuon/refactor-mcp/issues"},"bin":{"refactor-mcp":"dist/server.js"},"dist":{"shasum":"b1b5427fe3a619552c10558ff677a671f9996ed4","tarball":"https://registry.npmjs.org/@myuon/refactor-mcp/-/refactor-mcp-1.1.1.tgz","fileCount":6,"integrity":"sha512-QOoRDsSoenGQVmNhi4TnWbh3Pq/p5lTfDUIsODyc8cgTITqvbPcXGZ/PpwPefpn67PHkq0G1xcweBWNDWNl3jg==","signatures":[{"sig":"MEYCIQC6vXrUY7fZtonEzZSc0Ur2SnARpI/d2XUfzAtPI44D1wIhAKewKKN7bWIMgHL716SiOZtnw0NZbApdtylALOGtF5jh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27758},"main":"dist/server.js","type":"module","types":"./dist/server.d.ts","engines":{"node":">=18.0.0"},"gitHead":"f9b5512b37485418b04354e13c205fd46a844b3a","scripts":{"dev":"tsx src/server.ts","lint":"eslint src/**/*.ts tests/**/*.ts","test":"vitest","build":"tsc","check":"npm run type-check && npm run lint && npm run format:check && npm run test:run","start":"node dist/server.js","format":"prettier --write src/**/*.ts tests/**/*.ts","test:ui":"vitest --ui","lint:fix":"eslint src/**/*.ts tests/**/*.ts --fix","test:run":"vitest run","type-check":"tsc --noEmit","format:check":"prettier --check src/**/*.ts tests/**/*.ts","test:coverage":"vitest run --coverage","prepublishOnly":"npm run check && npm run build"},"_npmUser":{"name":"myuon","actor":{"name":"myuon","type":"user","email":"ioi.joi.koi.loi@gmail.com"},"email":"ioi.joi.koi.loi@gmail.com"},"repository":{"url":"git+https://github.com/myuon/refactor-mcp.git","type":"git"},"_npmVersion":"10.9.2","description":"MCP server for refactoring tools","directories":{},"_nodeVersion":"23.4.0","dependencies":{"zod":"^3.22.4","glob":"^11.0.3","@modelcontextprotocol/sdk":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.0.0","eslint":"^9.30.0","vitest":"^3.2.4","prettier":"^3.6.2","@eslint/js":"^9.30.0","@vitest/ui":"^3.2.4","typescript":"^5.0.0","@types/node":"^20.0.0","@types/eslint__js":"^8.42.3","typescript-eslint":"^8.35.0","eslint-config-prettier":"^10.1.5","eslint-plugin-prettier":"^5.5.1"},"_npmOperationalInternal":{"tmp":"tmp/refactor-mcp_1.1.1_1751192234182_0.8770314510286392","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@myuon/refactor-mcp","version":"1.2.0","description":"MCP server for refactoring tools","main":"dist/server.js","type":"module","bin":{"refactor-mcp":"dist/index.js"},"keywords":["mcp","model-context-protocol","refactoring","code-transformation","regex","search-replace"],"author":{"name":"myuon"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/myuon/refactor-mcp.git"},"homepage":"https://github.com/myuon/refactor-mcp#readme","bugs":{"url":"https://github.com/myuon/refactor-mcp/issues"},"engines":{"node":">=18.0.0"},"scripts":{"build":"tsc","start":"node dist/index.js","dev":"tsx src/index.ts","dev:cli":"tsx src/index.ts cli","cli":"tsx src/cli.ts","lint":"eslint src/**/*.ts tests/**/*.ts","lint:fix":"eslint src/**/*.ts tests/**/*.ts --fix","format":"prettier --write src/**/*.ts tests/**/*.ts","format:check":"prettier --check src/**/*.ts tests/**/*.ts","type-check":"tsc --noEmit","test":"vitest","test:run":"vitest run","test:ui":"vitest --ui","test:coverage":"vitest run --coverage","check":"npm run type-check && npm run lint && npm run format:check && npm run test:run","prepublishOnly":"npm run check && npm run build"},"publishConfig":{"access":"public"},"dependencies":{"@modelcontextprotocol/sdk":"^1.0.0","commander":"^14.0.0","glob":"^11.0.3","zod":"^3.22.4"},"devDependencies":{"@eslint/js":"^9.30.0","@types/eslint__js":"^8.42.3","@types/node":"^20.0.0","@vitest/ui":"^3.2.4","eslint":"^9.30.0","eslint-config-prettier":"^10.1.5","eslint-plugin-prettier":"^5.5.1","prettier":"^3.6.2","tsx":"^4.0.0","typescript":"^5.0.0","typescript-eslint":"^8.35.0","vitest":"^3.2.4"},"_id":"@myuon/refactor-mcp@1.2.0","gitHead":"32bac1b92a0aba68f6ed1a00d5c44530e1e8692d","types":"./dist/server.d.ts","_nodeVersion":"23.4.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-+N+j+2Sjl0ZKWHsiCRzZ+eZ19iIV+1bnW4kK6ZgG8slR32Z9MfD5zc5U/CML70jPEMWWZVWGMHp9Blyt7JyNqQ==","shasum":"71c72dc6926f0e33299b235d69a2a3ff164fcd1b","tarball":"https://registry.npmjs.org/@myuon/refactor-mcp/-/refactor-mcp-1.2.0.tgz","fileCount":24,"unpackedSize":67505,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDozo2+J72LiNWexhKsirb/2H1OH1eRJnfFimuxuXnD4AiBOURjf7zem8MJmcYaZeXYPAJON9JD65clM3QK7ciUyzQ=="}]},"_npmUser":{"name":"myuon","email":"ioi.joi.koi.loi@gmail.com","actor":{"name":"myuon","email":"ioi.joi.koi.loi@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"myuon","email":"ioi.joi.koi.loi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/refactor-mcp_1.2.0_1751734489297_0.632699809947328"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-29T08:03:07.422Z","modified":"2025-07-05T16:54:49.652Z","1.0.0":"2025-06-29T08:03:07.690Z","1.1.0":"2025-06-29T10:01:15.708Z","1.1.1":"2025-06-29T10:17:14.409Z","1.2.0":"2025-07-05T16:54:49.483Z"},"bugs":{"url":"https://github.com/myuon/refactor-mcp/issues"},"author":{"name":"myuon"},"license":"MIT","homepage":"https://github.com/myuon/refactor-mcp#readme","keywords":["mcp","model-context-protocol","refactoring","code-transformation","regex","search-replace"],"repository":{"type":"git","url":"git+https://github.com/myuon/refactor-mcp.git"},"description":"MCP server for refactoring tools","maintainers":[{"name":"myuon","email":"ioi.joi.koi.loi@gmail.com"}],"readme":"# refactor-mcp\n\nA Model Context Protocol (MCP) server that provides powerful refactoring tools for Coding Agents. It can run in two modes:\n\n- **MCP Server Mode** (default): Integrates with MCP-compatible clients like Claude Code\n- **CLI Mode**: Direct command-line usage for standalone refactoring tasks\n\n## Features\n\nThis MCP server implements two main tools to assist with code refactoring:\n\n### 🔧 code_refactor\nPerforms regex-based search and replace operations across files with advanced filtering capabilities.\n\n**Parameters:**\n- `search_pattern` (string) - Regular expression pattern to search for\n- `replace_pattern` (string) - Replacement pattern (supports capture groups like $1, $2)\n- `context_pattern` (string, optional) - Only replace matches within this context\n- `file_pattern` (string, optional) - Glob pattern to limit files (e.g., `*.js`, `src/**/*.ts`)\n\n**Example:**\n```javascript\n// Replace foo() calls with bar() calls\ncode_refactor(\"foo\\\\((.+)\\\\)\", \"bar($1)\")\n\n// Before: let k = foo(1,2,3);\n// After:  let k = bar(1,2,3);\n```\n\n**Context-aware refactoring:**\n```javascript\n// Only replace \"legacy_sdk\" within import statements\ncode_refactor(\"legacy_sdk\", \"brand_new_sdk\", \"import\")\n```\n\n### 🔍 code_search\nSearches for regex patterns and returns file locations with precise line numbers.\n\n**Parameters:**\n- `search_pattern` (string) - Regular expression pattern to search for\n- `context_pattern` (string, optional) - Filter matches by surrounding context\n- `file_pattern` (string, optional) - Glob pattern to limit search scope\n\n**Example:**\n```javascript\ncode_search(\"foo\\\\(.+\\\\)\")\n\n// Result:\n// ./src/utils.js (line: 15)\n// ./src/helpers.ts (lines: 23-27)\n```\n\n## Installation\n\n### Quick Start\n\n**MCP Server Mode** (for Claude Code and other MCP clients):\n```bash\n# Install globally for MCP integration\nnpm install -g @myuon/refactor-mcp\n\n# Or use with npx (recommended for MCP clients)\nnpx @myuon/refactor-mcp@latest\n```\n\n**CLI Mode** (for direct command-line usage):\n```bash\n# Search for patterns\nnpx @myuon/refactor-mcp@latest cli search -p \"function.*\\(\" -f \"src/**/*.js\"\n\n# Refactor with preview\nnpx @myuon/refactor-mcp@latest cli refactor -s \"const (\\w+)\" -r \"let \\$1\" --dry-run\n```\n\n### For Development\n```bash\n# Clone and install dependencies\ngit clone https://github.com/myuon/refactor-mcp.git\ncd refactor-mcp\nnpm install\n```\n\n## Usage\n\n### CLI Mode\nYou can use the refactor tools directly from the command line by adding `cli` after the main command:\n\n```bash\n# Search for patterns\nrefactor-mcp cli search -p \"function (.*) \\{\" -f \"src/**/*.ts\"\n\n# Search with matched content display\nrefactor-mcp cli search -p \"function (.*) \\{\" -f \"src/**/*.ts\" --print\n\n# Refactor with dry-run (preview changes)\nrefactor-mcp cli refactor -s \"const (\\w+) = \" -r \"let \\$1 = \" --dry-run\n\n# Refactor with matched content display\nrefactor-mcp cli refactor -s \"const (\\w+) = \" -r \"let \\$1 = \" --print --dry-run\n\n# Refactor with file pattern\nrefactor-mcp cli refactor -s \"old_function\" -r \"new_function\" -f \"src/**/*.js\"\n\n# Context-aware refactoring\nrefactor-mcp cli refactor -s \"legacy_sdk\" -r \"new_sdk\" -c \"import\" -f \"src/**/*.ts\"\n```\n\n**CLI Commands:**\n- `search` - Search for code patterns\n  - `-p, --pattern <pattern>` - Regular expression pattern to search for\n  - `-c, --context <context>` - Optional context pattern to filter matches\n  - `-f, --files <files>` - Optional file glob pattern to limit search scope\n  - `--print` - Print matched content to stdout\n  - `--matched` - Show only matched text with capture groups\n- `refactor` - Refactor code with regex replacement\n  - `-s, --search <search>` - Regular expression pattern to search for\n  - `-r, --replace <replace>` - Replacement pattern (supports $1, $2, etc.)\n  - `-c, --context <context>` - Optional context pattern to filter matches\n  - `-f, --files <files>` - Optional file glob pattern to limit search scope\n  - `--dry-run` - Preview changes without modifying files\n  - `--print` - Print matched content and replacements to stdout\n\n**Important Notes:**\n- When using capture groups in replacement patterns on the command line, escape the dollar sign: `\\$1`, `\\$2`, etc.\n- Example: `refactor-mcp cli refactor -s \"const (\\w+) = \" -r \"let \\$1 = \" --dry-run`\n- This prevents the shell from interpreting `$1` as a shell variable\n\n### MCP Server Mode (Default)\nBy default, `refactor-mcp` runs as an MCP server via stdio transport:\n\n```bash\n# Run as MCP server (default mode)\nrefactor-mcp\n\n# Or explicitly with npx\nnpx @myuon/refactor-mcp@latest\n```\n\n### Development\n```bash\nnpm run dev          # Run server in development mode\nnpm run dev:cli      # Run CLI in development mode with arguments\nnpm run cli          # Run CLI directly (for testing)\nnpm run build        # Build for production\nnpm start            # Run built server (MCP mode)\n```\n\n### Code Quality\n```bash\nnpm run check        # Run all quality checks\nnpm run lint         # Run ESLint\nnpm run format       # Format code with Prettier\nnpm test             # Run tests\n```\n\n## MCP Integration\n\nThis 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.\n\n### Claude Code Integration\nFor Claude Code users, you can easily add this MCP server with:\n\n```bash\nclaude mcp add refactor npx @myuon/refactor-mcp@latest\n```\n\n### Manual Configuration\nAdd to your MCP client configuration:\n\n```json\n{\n  \"mcpServers\": {\n    \"refactor-mcp\": {\n      \"command\": \"npx\",\n      \"args\": [\"@myuon/refactor-mcp@latest\"]\n    }\n  }\n}\n```\n\n### Alternative Configuration (Local Installation)\n```json\n{\n  \"mcpServers\": {\n    \"refactor-mcp\": {\n      \"command\": \"refactor-mcp\"\n    }\n  }\n}\n```\n\n## Architecture\n\n- **Framework**: Model Context Protocol SDK for TypeScript\n- **Runtime**: Node.js with ES modules\n- **Validation**: Zod schemas for type-safe input validation\n- **File Operations**: Native fs module with glob pattern matching\n- **Testing**: Vitest with comprehensive test coverage\n\n## Contributing\n\n1. Install dependencies: `npm install`\n2. Run tests: `npm test`\n3. Check code quality: `npm run check`\n4. Build: `npm run build`\n\n## License\n\nMIT","readmeFilename":"README.md"}