提供工具查询和过滤Rector PHP重构规则的MCP服务器。
直接从GitHub Packages运行MCP Rector服务器:
npx @vasilvestre/mcp-rector
使用特定版本:
npx @vasilvestre/mcp-rector@1.0.0
永久安装:
npm install -g @vasilvestre/mcp-rector
mcp-rector
本地开发:
npm install
npm run build
在你的Claude Desktop配置文件中添加:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"rector": {
"command": "npx",
"args": ["-y", "@vasilvestre/mcp-rector"]
}
}
}
对于特定版本(例如1.0.0):
{
"mcpServers": {
"rector": {
"command": "npx",
"args": ["-y", "@vasilvestre/mcp-rector@1.0.0"]
}
}
}
更新配置后,请重启Claude Desktop以激活MCP服务器。
在你的Cline MCP设置中添加:
settings.json:{
"cline.mcpServers": {
"rector": {
"command": "npx",
"args": ["-y", "@vasilvestre/mcp-rector"]
}
}
}
或者使用Cline MCP设置UI来添加服务器。
在Continue配置中添加,路径为~/.continue/config.json:
{
"mcpServers": [
{
"name": "rector",
"command": "npx",
"args": ["-y", "@vasilvestre/mcp-rector"]
}
]
}
在你的Zed设置中添加,路径为~/.config/zed/settings.json:
{
"context_servers": {
"rector": {
"command": {
"path": "npx",
"args": ["-y", "@vasilvestre/mcp-rector"]
}
}
}
}
如果你更喜欢全局安装而不是使用npx:
npm install -g @vasilvestre/mcp-rector
然后使用直接命令进行配置:
{
"mcpServers": {
"rector": {
"command": "mcp-rector"
}
}
}
配置好你的MCP客户端后:
list-rector-rules, filter-rector-rules, search-rector-rulesMCP Inspector是一个开发者工具,在将其与客户端集成之前用于本地测试MCP服务器。
npx @modelcontextprotocol/inspector
npx @modelcontextprotocol/inspector npx -y @vasilvestre/mcp-rector
这将:
Inspector提供了:
示例测试流程:
list-rector-rules{"ruleSet": "naming"})列出所有可用的Rector规则,并可选地通过规则集进行过滤。
参数:
ruleSet(可选):按规则集类别过滤规则(例如,“php80”,“code-quality”)通过关键词搜索Rector规则,支持多词查询。
参数:
query(必需):搜索关键词或多词短语(例如,“rename class”)ruleSet(可选):按规则集类别过滤结果功能:
示例:
{"query": "rename class"} → 查找RenameClass, RenameClassConstFetch等{"query": "type declaration"} → 查找AddParamTypeDeclaration, ReturnTypeDeclaration等{"query": "php80", "ruleSet": "php80"} → 仅在PHP 8.0规则集中搜索按规则集类别过滤规则。
参数:
ruleSet(必需):要过滤的规则集名称(不区分大小写)其他工具文档在specs/001-list-rector-rules/
npm run build # 将TypeScript构建到build/
npm test # 运行测试
npm run test:watch # 在监视模式下运行测试
确保已安装Node.js 18+和npm:
node --version # 应该大于等于18.0.0
npm --version
该包应自动处理权限。如果问题仍然存在,请尝试:
npx --yes mcp-rector
检查npm注册表连接:
npm ping
如果遇到缓存版本的问题,请清除npx缓存:
rm -rf ~/.npm/_npx
在Windows上,你可能需要调整PowerShell执行策略:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser