LocalWP代理工具
A. 本地 为AI驱动的WordPress开发提供MCP服务器和项目上下文的插件。适用于Claude Code、Cursor、Windsurf、VS Code Copilot和任何MCP客户端。
它做什么
当您在本地网站上单击“启用”时,插件:
- 在MCP服务器上注册站点 --在Local的主进程中运行的单个HTTP服务器,使AI工具能够访问WP-CLI、错误日志、配置和站点管理
- 写入MCP配置 (
.mcp.json,.cursor/mcp.json等)——为每个代理自动配置正确的HTTP端点 - 生成项目上下文 (
CLAUDE.md,.cursorrules等)——站点上下文,包括PHP/MySQL版本、活动插件、主题和文件结构 - 更新
.gitignore--因此,生成的文件不会被提交
然后在你选择的人工智能工具中打开网站文件夹,你就可以开始了。
建筑
MCP服务器在Local的Electron主进程中作为单个HTTP服务器运行,每个站点没有单独的Node.js进程。每个站点都有自己的端点:
http://localhost:{port}/sites/{siteId}/mcp服务器使用MCP流式HTTP传输。端口在重启过程中保持稳定(持续时间为 ~/.local-agent-tools/port,默认值为24842)。
即使停止,站点也会保持注册状态,因此MCP端点始终是可访问的。需要运行服务的工具(WP-CLI、数据库)返回相应的错误;基于文件的工具(配置、日志、站点信息)无论如何都能工作。每次工具调用时都会刷新配置,因此启动站点会自动使数据库工具工作,而无需重新连接。
支持的代理
| 代理 | MCP配置 | 上下文文件 |
|---|---|---|
| 克劳德代码 | .mcp.json | CLAUDE.md |
| 光标 | .cursor/mcp.json | .cursorrules |
| 风帆冲浪 | .windsurf/mcp.json | .windsurfrules |
| VS代码副本 | .vscode/mcp.json | .github/copilot-instructions.md |
MCP工具(共12个)
| 类别 | 工具 | 描述 |
|---|---|---|
| WP-CLI | wp_cli | 运行任何WP-CLI命令(数据库查询、导入、导出、搜索替换、插件/主题管理等) |
| 日志 | read_error_log | 读取并解析PHP错误日志 |
read_access_log | 读取nginx访问日志 | |
wp_debug_toggle | 启用/禁用WP_DEBUG、WP_DEBUG_LOG和SCRIPT_DEBUG | |
| 配置 | read_wp_config | 解析wp-config.php常量和表前缀 |
edit_wp_config | 添加或修改wp-config.php常量(带备份) | |
| 网站 | get_site_info | 路径、URL、数据库配置、PHP/WP版本、活动插件和主题 |
site_health_check | 数据库连接、文件权限、WP_DEBUG状态、日志大小、PHP版本 | |
| 环境 | site_start | 启动网站的服务(PHP、MySQL、web服务器) |
site_stop | 停止网站的服务 | |
site_restart | 重新启动网站的服务 | |
site_status | 获取站点的当前状态 | |
list_sites | 列出所有具有状态的本地站点 |
安装
源自
git clone agent-tools
cd agent-tools
npm install --legacy-peer-deps
npm run build将构建的插件复制到Local的插件目录:
# macOS
cp -r . ~/Library/Application\ Support/Local/addons/agent-tools/
# Linux
cp -r . ~/.config/Local/addons/agent-tools/
# Windows (PowerShell)
Copy-Item -Recurse -Force . "$env:APPDATA\Local\addons\agent-tools"在已安装的位置安装生产依赖项,然后重新启动本地:
# macOS
cd ~/Library/Application\ Support/Local/addons/agent-tools/
# Linux
cd ~/.config/Local/addons/agent-tools/
# Windows (PowerShell)
cd "$env:APPDATA\Local\addons\agent-tools"npm install --production --ignore-scripts
# Then restart Local发展
# Build the add-on
npm run build
# Watch for changes
npm run watch构建后,同步到已安装的插件:
# macOS
cp -R lib/* ~/Library/Application\ Support/Local/addons/agent-tools/lib/
# Linux
cp -R lib/* ~/.config/Local/addons/agent-tools/lib/
# Windows (PowerShell)
Copy-Item -Recurse -Force lib\* "$env:APPDATA\Local\addons\agent-tools\lib"然后重新启动本地以获取更改。
项目结构
agent-tools/
├── src/ # Add-on source (TypeScript)
│ ├── main.ts # Main process — lifecycle hooks, IPC, MCP server startup
│ ├── renderer.tsx # Renderer process — React UI
│ ├── mcp-server.ts # HTTP MCP server — session management, Streamable HTTP transport
│ ├── helpers/
│ │ ├── site-config.ts # SiteConfig type and SiteConfigRegistry
│ │ ├── paths.ts # Platform-specific binary resolution (PHP, MySQL, WP-CLI)
│ │ └── port.ts # Stable port allocation with file persistence
│ └── tools/ # MCP tool implementations
│ ├── index.ts # Aggregates definitions, routes handleToolCall()
│ ├── wpcli.ts # wp_cli
│ ├── logs.ts # read_error_log, read_access_log, wp_debug_toggle
│ ├── config.ts # read_wp_config, edit_wp_config
│ ├── site.ts # get_site_info, site_health_check
│ └── environment.ts # site_start, site_stop, site_restart, site_status, list_sites
├── lib/ # Compiled output
├── package.json
└── tsconfig.json需求
- 本地9.0+
- MCP兼容的AI工具(Claude Code、Cursor、Windsurf、VS Code Copilot等)
平台支持
macOS(darwin-arm64和darwin-x64)、Windows和Linux。
支持级别
活动: 10up正在积极致力于此,我们希望在可预见的未来继续工作,包括保持测试到最新版本的Local。欢迎Bug报告、功能请求、问题和拉取请求。
更新日志
Agent Tools的所有显著更改的完整列表记录在 更改日志.md.
贡献
就像你看到的?

