Rector is great. Its cold start is not. Every
rector processrebuilds its container before a single rule fires: 7 seconds per file on a real production codebase. Keep Rector warm, and every call after the first takes 0.68s. Same output as cold. ~10× faster.
Two ways in, one warm engine:
- an MCP server that gives your AI agent a fast Rector;
- a language server that puts Rector's fixes in your editor.
Who it's for • Get started • AI agent • Editor • Validation loop • Numbers • Docs
| You… | You get | Use |
|---|---|---|
| let an AI agent refactor PHP | Rector as a tool your agent calls after every edit | MCP server |
| want Rector in your editor | Rector's fixes flagged as you type, one click to apply | Language server |
| run Rector in a validation loop | A warm Rector you call file by file, without paying the boot each time | MCP server |
Both ship in one package. Run one, or both side by side.
- ~10× faster per call. 0.68s warm against 7.02s cold, at the median.
- Identical output. All 20 benchmark files gave the same answer warm and cold, and CI checks warm output against a fresh cold Rector run. Nothing to re-check.
- One-time boot. The first call costs about one cold run (~6.4s), once per session. An idle server costs nothing.
- Edit
rector.phpfreely. Config changes apply on the next call. No restart.
composer global require dpt/mcp-rector-warmThat's the install. PHP 8.2+, Rector ^2.4 comes along as a normal Composer dependency. Now pick where Rector should run.
For: anyone who lets Claude, Copilot agent mode, Cursor, Cline or another agent refactor PHP.
- Your agent runs Rector after every edit, without waiting 7 seconds each time.
- Preview first. The agent sees the diff; files change only when it asks to write.
- Stays inside your project. Paths outside the working directory are refused.
- Any MCP client. Claude Desktop, VS Code, Cursor, Cline, Continue, Zed.
Add it to Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"rector": {
"command": "mcp-rector-warm",
"args": [
"--working-dir=/path/to/your/project",
"--config=/path/to/your/project/rector.php"
]
}
}
}Restart Claude and ask: "Run Rector on src/Foo.php". Done.
Full setup → VS Code and other clients, the rector_process tool, timeouts.
For: PHP developers who want Rector's suggestions where they write code, not in a terminal afterwards.
- Fixes appear as you type, on unsaved edits too, not only on save.
- One click to apply one rule, the whole file, or the whole project, without touching files that have unsaved changes.
- A broken file never looks clean. A syntax error or a bad config shows up as an error.
- Change
rector.php, see it at once. Open files re-check when the config changes.
Point your editor's LSP client at:
rector-warm-lsp --working-dir=/path/to/projectfor PHP files, with composer.json / rector.php as root markers.
Full setup → copy-paste configs for Neovim and Helix (tested in CI), Zed, Sublime Text and PhpStorm.
For: teams and tools that run Rector after every generated change, as a check.
- Start once, call per file. No boot on each check after the first.
- Plain MCP over stdio. Drive it from any MCP client library (Python, Node, Go…).
- Failures are real errors. A bad path, a missing config or a Rector exception comes back as an error, never as a silent pass.
mcp-rector-warm --working-dir=/path/to/project --config=/path/to/project/rector.php~10× faster per call. The first call boots Rector once, costing about the same as one cold run (6.4s). Every call after that takes 0.68s (median) instead of 7.0s cold.
| Setup | median | p95 |
|---|---|---|
Cold rector process, every call |
7.02s | 9.00s |
| Warm, first call (one-time boot, once per session) | 6.4s | |
| Warm, every later call | 0.68s | 2.40s |
20 files from a real production codebase: 144s cold, 30s warm including the one-time boot. All 20 warm answers matched the cold ones.
Method, caveats, reproduce it on your project →
composer global require dpt/mcp-rector-warmPuts mcp-rector-warm and rector-warm-lsp on your $PATH. As a project dependency, both are in vendor/bin/.
- MCP server: every client setup, the
rector_processtool, options, the call timeout, compatibility. - Language server: editor setup, diagnostics, quick-fixes, unsaved buffers, fix-all, limits.
- How it works: architecture, config reloads, Windows and other PHP builds without pcntl.
- Benchmark: method, full numbers, how to reproduce.
- FAQ.
- The language server, for the Rector maintainers: design, correctness checks, known limits.
- Rector by Tomas Votruba and contributors — the engine doing all the real work. If you ship PHP, sponsor him.
- Model Context Protocol by Anthropic — the protocol that makes this kind of tool integration possible.
- mcp/sdk — official PHP SDK, used here for stdio transport + tool discovery.
- Rector docs — config, rules, sets.
- Rector on Packagist — the upstream package.
- claude-supertool — DPT's batched-ops Claude Code companion; integrates this server as a validator.
Community License — see LICENSE. Built by Digital Process Tools.
