Phpactor MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Phpactor MCP Server find all references to App\Models\User"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Phpactor MCP Server
MCP server that wraps Phpactor to provide project-wide semantic PHP refactoring tools for AI assistants (Claude Code, etc.).
What it does
Exposes 6 tools that require Phpactor's type-aware engine — things a text-based AI cannot reliably do with grep:
Tool | Description |
| Build/rebuild project index (prerequisite for other tools) |
| Find all semantic references to a class or member |
| Rename class + update ALL references project-wide |
| Rename method/property/constant project-wide |
| Move class to new file/namespace + update references |
| Query class info (implements, implementations) |
See docs/spec.md for full specification.
Related MCP server: phpustik MCP Server
Prerequisites
Node.js >= 18
Phpactor installed and available in PATH (or set
PHPACTOR_BINenv var)# Install Phpactor (PHAR) curl -Lo phpactor https://github.com/phpactor/phpactor/releases/latest/download/phpactor.phar chmod +x phpactor mv phpactor ~/.local/bin/PHP >= 8.1
A PHP project with Composer and PSR-4 autoload configured
Yii2 / non-PSR-4 projects
Phpactor requires PSR-4 autoload mappings. For Yii2 projects, add this to composer.json:
{
"autoload": {
"psr-4": {
"common\\": "common/",
"backend\\": "backend/",
"frontend\\": "frontend/",
"console\\": "console/",
"modules\\": "modules/"
}
}
}Then run composer dump-autoload.
Install
npm install -g @p4it-kft/phpactor-mcpNo build step needed — the package is published prebuilt to npm.
From source (development)
git clone https://github.com/p4it-kft/@p4it-kft/phpactor-mcp
cd @p4it-kft/phpactor-mcp
npm install
npm run buildConfigure in Claude Code
Add to ~/.claude/settings.json (or project-level .claude/settings.json):
{
"mcpServers": {
"phpactor": {
"command": "npx",
"args": ["-y", "@p4it-kft/phpactor-mcp"]
}
}
}Optionally set PHPACTOR_BIN if Phpactor is not in PATH:
{
"mcpServers": {
"phpactor": {
"command": "npx",
"args": ["-y", "@p4it-kft/phpactor-mcp"],
"env": {
"PHPACTOR_BIN": "/path/to/phpactor"
}
}
}
}Usage
Once configured, the tools are available to Claude. Typical workflow:
Build the index first — Claude calls
phpactor_index_buildwith your project pathUse tools — find references, rename, move classes as needed
Rebuild index after significant file changes
Testing
# Run all integration tests (requires tmp/p4it-website test project)
bash test-phpactor.shDevelopment
npm run dev # Watch mode — recompiles on changes
npm run build # One-time buildAvailable Tools
6 toolsphpactor_class_infoA
Query indexed information about a PHP class: FQCN, file path, type, what it implements, and what implements it.
Inputs: fqcn (required), projectPath (required).
phpactor_find_referencesA
Find all semantic references to a PHP class or class member across the project. Returns type-aware results (not grep-based text matching).
Inputs: filePath (required), projectPath (required), memberName, memberType.
phpactor_index_buildA
Build or rebuild the Phpactor project index. Must run before other phpactor tools. Checks PSR-4 autoload config and warns if missing (Yii2 projects need manual setup).
Inputs: projectPath (required), reset.
phpactor_move_classA
Move/rename a PHP class: moves the file, updates the namespace declaration, AND updates all references project-wide. This is the tool for full class renames. WARNING: Writes directly to disk — commit your work first!
Inputs: destPath (required), sourcePath (required), projectPath (required).
phpactor_rename_classA
Update all REFERENCES to a PHP class project-wide (use statements, type hints, docblocks, instantiations). Does NOT rename the file or modify the class declaration — use phpactor_move_class for a full rename including file move and namespace update.
Inputs: newFqcn (required), filePath (required), projectPath (required), dryRun.
phpactor_rename_memberA
Rename a PHP method, property, or constant and update all references project-wide. Uses type inference to only rename the correct member (not same-named members on other classes).
Inputs: newName (required), filePath (required), memberName (required), memberType (required), +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: class info, find references, build index, move class, rename class (only references), rename member. The descriptions explicitly contrast move_class vs rename_class, so an agent can easily differentiate.
All tools start with 'phpactor_' and use snake_case, but the verb_noun pattern is not fully consistent: 'class_info' and 'index_build' deviate slightly. However, the overall pattern is predictable and readable.
6 tools is well-scoped for a PHP code intelligence server, covering indexing, querying, and refactoring. No tool is redundant, and the count is appropriate for the domain.
The tool set covers core operations (index, inspect, move/rename class, rename member) but lacks capabilities like listing classes or getting method details. Minor gaps exist, but the surface is usable for common tasks.
Maintenance
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Ask a codebase what calls what: search, blast radius, paths between symbols, and diffs.
Codebase intelligence for AI coding agents: graph, git history, docs, decisions, code health.
Related MCP Servers
- AlicenseAqualityDmaintenanceConnects AI assistants like Claude to PHP's XDebug debugger for runtime inspection, breakpoint control, and variable tracking, enabling natural language debugging of PHP applications.61Apache 2.0
- AlicenseBqualityDmaintenanceEnables AI assistants to deeply interact with the PHP ecosystem, including runtime, static analysis, security scanning, testing, Composer, and frameworks like Laravel and Symfony. It exposes over 30 tools, 8 resources, and 7 prompts via MCP, allowing natural language commands to run PHP linting, static analysis, audits, tests, and project initialization.41MIT
- AlicenseNot gradedqualityCmaintenanceBridges AI assistants to clangd for C/C++ code intelligence, providing tools for symbol search, definitions, references, type info, and more.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to navigate and refactor a codebase through an AST index, offering project overviews, symbol and usage search, module dependency exploration, and LSP-backed operations such as rename, go-to-definition, diagnostics, and extract-method. Supports TypeScript/JavaScript and C# with automatic reindexing and watch mode.MIT