WP审核MCP服务器
MCP(模型上下文协议)服务器,用于在WP引擎上进行全面的WordPress站点审核。
这是什么?
这是一个MCP服务器,它提供 克劳德代码 用于审计和优化WP Engine上托管的WordPress网站的专用工具。您不必手动运行PHP脚本和API调用,只需让Claude审核网站,它就会自动使用这些工具。
运作原理
┌─────────────────────────────────────────────────────────────────┐
│ Your Computer │
│ │
│ Claude Code ◄──stdio──► wp-audit-mcp (Node.js) │
│ │ │
│ ├──SSH──► WP Engine sites │
│ │ (runs WP-CLI/PHP) │
│ │ │
│ └──HTTPS──► CloudFlare API │
└─────────────────────────────────────────────────────────────────┘- 克劳德代码 将MCP服务器作为本地子进程启动
- 它们通过stdin/stdout(非网络)进行通信
- 当你让克劳德审计一个网站时,它会调用MCP工具
- MCP服务器通过SSH连接到WP引擎并运行PHP脚本
- 对于CloudFlare,它直接进行API调用
特性
| 工具 | 说明 |
|---|---|
wp_baseline | 完整的网站审计(内容计数、数据库大小、SEO状态、插件工件) |
wp_cleanup | 数据库清理(孤立数据、修订、瞬态、操作调度器) |
wp_plugin_artifacts | 从已删除的插件中删除剩余的表/选项 |
wp_seo_check | 检查元描述覆盖率 |
wp_seo_fix | 自动生成或手动设置元描述 |
wp_rocket_fix | 检查并优化WP Rocket设置 |
wp_clear_cache | 清除所有缓存(WordPress、WP Rocket、页面构建器、WP引擎) |
cloudflare_check | 审核CloudFlare安全设置 |
cloudflare_fix | 应用推荐的CloudFlare设置 |
ahrefs_extract | 解析和总结Ahrefs网站审计导出 |
______________________________________________________________________
安装
先决条件
1.Node.js 18+
下载自 或使用版本管理器:
# Check your version
node --version # Should be v18.x or higher
# macOS (with Homebrew)
brew install node
# Windows (with Chocolatey)
choco install nodejs
# Linux (Ubuntu/Debian)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs2.克劳德密码
如果你还没有安装Claude Code:
npm install -g @anthropic-ai/claude-code3.SSH访问WP引擎
您需要对WP引擎站点进行基于SSH密钥的身份验证。
生成SSH密钥(如果您没有):
ssh-keygen -t ed25519 -C "your-email@example.com"将您的公钥添加到WP引擎:
- 登录 WP引擎门户
- 首选 我的资料 → SSH密钥
- 点击 添加SSH密钥
- 粘贴内容
~/.ssh/id_ed25519.pub
测试连接:
# Replace SITEID with your WP Engine environment name
ssh SITEID@SITEID.ssh.wpengine.net 'echo "Connected successfully"'4.CloudFlare Global API密钥(可选)
仅当您想使用CloudFlare工具时才需要。
- 登录 CloudFlare仪表板
- 单击您的个人资料图标→ 我的资料
- 首选 API令牌 标签
- 找到 全球API密钥 → Click 视图
- 复制密钥(运行CloudFlare工具时需要此密钥)
注: 使用全局API密钥,而不是API令牌。全球API密钥适用于所有区域。
______________________________________________________________________
分步安装
步骤1:克隆存储库
# Clone to a permanent location (not in a project folder)
git clone https://github.com/markahope-aag/wp-audit-mcp.git ~/wp-audit-mcp
# Or on Windows
git clone https://github.com/markahope-aag/wp-audit-mcp.git C:\tools\wp-audit-mcp步骤2:安装依赖关系并构建
cd ~/wp-audit-mcp # or C:\tools\wp-audit-mcp on Windows
# Install Node.js dependencies
npm install
# Build the TypeScript code
npm run build你应该看到一个 dist/ 使用编译的JavaScript创建的文件夹。
步骤3:配置Claude代码
克劳德代码使用 .mcp.json 了解MCP服务器的文件。您需要将此服务器添加到该文件中。
选项A:使用配置脚本
# Run from your project directory (where you use Claude Code)
~/wp-audit-mcp/configure.sh .
# Windows
C:\tools\wp-audit-mcp\configure.sh .选项B:手动配置
创建或编辑 .mcp.json 在您的项目目录中:
{
"mcpServers": {
"wp-audit": {
"command": "node",
"args": ["/Users/yourname/wp-audit-mcp/dist/index.js"]
}
}
}重要提示: 使用完整的绝对路径 dist/index.js:
- macOS/Linux:
/Users/yourname/wp-audit-mcp/dist/index.js - 窗户:
C:/tools/wp-audit-mcp/dist/index.js(使用正斜杠)
步骤4:重新启动Claude代码
# Start Claude Code in your project directory
cd /path/to/your/project
claude当Claude Code启动时,它将自动启动MCP服务器。您应该看到它连接时没有错误。
步骤5:验证安装
问克劳德:
What MCP tools do you have available for WordPress audits?Claude应该列出wp_baseline、wp_cleanup和其他工具。
______________________________________________________________________
配置详情
.mcp.json文件
这 .mcp.json 文件告诉克劳德代码启动哪些MCP服务器。它可以放置在:
- 项目目录 (推荐)-该项目可用的工具
- 主目录 (
~/.mcp.json)-全球可用的工具
多服务器示例:
{
"mcpServers": {
"wp-audit": {
"command": "node",
"args": ["/Users/yourname/wp-audit-mcp/dist/index.js"]
},
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-memory"],
"env": {
"MEMORY_FILE_PATH": "./.claude/memory.json"
}
}
}
}工具如何连接到WP引擎
MCP服务器使用SSH连接到WP引擎并运行WP-CLI命令:
# This is what happens behind the scenes
ssh SITEID@SITEID.ssh.wpengine.net 'wp eval-file /tmp/script.php'这 site_id 您提供的参数是 WP引擎环境名称,您可以在以下网址找到:
- WP引擎门户URL:
my.wpengine.com/installs/SITEID - 或者在网站的“概述”页面中
SSH配置(可选)
为了方便起见,您可以将WP引擎站点添加到 ~/.ssh/config:
Host wpengine-mysite
HostName mysite.ssh.wpengine.net
User mysite
IdentityFile ~/.ssh/id_ed25519这不会影响MCP服务器的工作方式,但会使手动SSH更容易。
______________________________________________________________________
用法
基本命令
安装后,只需自然地与Claude交谈:
Audit the WordPress site "mysite" on WP Engine或者更具体地说:
Use wp_baseline with site_id "mysite"示例会话
You: I need to audit the site "clientsite" - check SEO, clean up the database,
and fix CloudFlare settings. Zone ID is abc123def456.
Claude: I'll run a comprehensive audit. Let me start with the baseline...
[Uses wp_baseline]
Now checking SEO meta descriptions...
[Uses wp_seo_check]
I found 15 pages missing meta descriptions. Should I auto-generate them?
You: Yes, generate them.
Claude: [Uses wp_seo_fix with mode "auto"]
Done. Now checking CloudFlare...
[Uses cloudflare_check]
Found issues: SSL is "flexible" (should be "full"), TLS 1.0 (should be 1.2).
Should I fix these?
You: Yes, fix all CloudFlare issues.
Claude: [Uses cloudflare_fix]
All CloudFlare settings updated. Let me clear all caches...
[Uses wp_clear_cache]
Audit complete! Here's the summary...______________________________________________________________________
工具参考
wp_baseline
在WordPress网站上运行全面的基线审计。
Parameters:
site_id: WP Engine environment name (required)
Returns: Content counts, database size, orphaned data, SEO status,
WP Rocket settings, deleted plugin artifactswp_清理
清理孤立数据并优化数据库。
Parameters:
site_id: WP Engine environment name (required)
delete_revisions: Delete post revisions (default: true)
Actions: Removes orphaned postmeta, termmeta, commentmeta, auto-drafts,
transients, old action scheduler entries. Closes pingbacks.wp_pluginartifacts
从已删除的插件中删除数据库工件。
Parameters:
site_id: WP Engine environment name (required)
plugins: Array of plugins to clean (optional - cleans all if empty)
Options: yoast, rankmath, aioseo, wsal, revslider,
layerslider, woocommerce, jetpack
dry_run: Preview changes without applying (default: false)
Actions: Drops orphaned tables, deletes leftover optionswp_seo_check
检查页面/帖子的元描述状态。
Parameters:
site_id: WP Engine environment name (required)
post_type: 'page', 'post', or 'all' (default: 'page')
Returns: Count of pages with/without meta descriptions, list of missingwp_seo_fix
向内容添加元描述。
Parameters:
site_id: WP Engine environment name (required)
mode: 'auto' or 'manual' (default: 'auto')
post_type: For auto mode (default: 'page')
descriptions: For manual mode - {postId: "description"} object
dry_run: Preview changes (default: false)
Auto mode: Extracts first 155 chars from page content
Manual mode: Sets specific descriptions for specific post IDswp_rocket_fix
检查并修复WP火箭设置。
Parameters:
site_id: WP Engine environment name (required)
dry_run: Preview changes (default: false)
Fixes: Enables cache preload, sitemap preload, lazy loading, mobile cachewp_clear_cache
清除网站上的所有缓存。
Parameters:
site_id: WP Engine environment name (required)
Clears: WordPress object cache, transients, WP Rocket, WP Super Cache,
Elementor, Beaver Builder, Divi, WP Engine page cachecloudflare_check
检查CloudFlare安全和性能设置。
Parameters:
zone_id: CloudFlare Zone ID (required)
email: CloudFlare account email (required)
api_key: CloudFlare Global API Key (required)
Checks: SSL mode, min TLS version, HSTS, Bot Fight Mode,
AI bot protection, crawler protectioncloudflare_fix
应用推荐的CloudFlare设置。
Parameters:
zone_id: CloudFlare Zone ID (required)
email: CloudFlare account email (required)
api_key: CloudFlare Global API Key (required)
fix_ssl: Fix SSL to 'full' (optional)
fix_tls: Fix min TLS to 1.2 (optional)
fix_hsts: Enable HSTS with 6-month max-age (optional)
fix_bots: Enable bot protection (optional)
fix_all: Apply all fixes (default: auto-detects what's needed)ahrefs_提取物
提取并总结Ahrefs站点审计ZIP文件。
Parameters:
zip_path: Full path to Ahrefs ZIP export (required)
output_dir: Directory to extract to (optional)
Returns: Summary of errors, warnings, and notices from the audit______________________________________________________________________
典型审计工作流程
- 基线:
wp_baseline-了解网站的当前状态 - 阿雷夫斯:
ahrefs_extract-解析Ahrefs审计文件(如果提供) - 云耀:
cloudflare_check→cloudflare_fix-修复安全设置 - 数据库:
wp_cleanup→wp_plugin_artifacts-清理数据库 - 搜索引擎优化:
wp_seo_check→wp_seo_fix-修复缺失的元描述 - 缓存:
wp_rocket_fix-优化WP火箭 - 完成:
wp_clear_cache-清除所有缓存
______________________________________________________________________
故障排除
“SSH连接失败”
- 验证SSH密钥是否已添加到WP引擎门户
- 手动测试:
ssh SITEID@SITEID.ssh.wpengine.net 'echo test' - 检查一下
site_id与WP引擎环境名称完全匹配
“找不到MCP服务器”
- 验证中的路径
.mcp.json绝对正确 - 检查一下
npm run build已完成,无错误 - 验证
dist/index.js存在
“CloudFlare身份验证失败”
- 使用 全球API密钥,不是API令牌
- 验证电子邮件是否与您的CloudFlare登录信息匹配
- 检查区域ID是否正确(在CloudFlare仪表板概述中找到)
工具未出现在Claude中
- 完全重新启动Claude代码
- 检查
.mcp.json位于当前目录中 - Claude代码启动时查找错误
______________________________________________________________________
支持的平台
- 视窗 -通过Git Bash、WSL或原生(路径中有正斜杠)
- macOS -本地终端
- Linux -本地终端
______________________________________________________________________
发展
# Run in development mode (watches for changes)
npm run dev
# Build for production
npm run build
# The server communicates via stdio, so to test manually:
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node dist/index.js______________________________________________________________________
许可证
麻省理工学院
______________________________________________________________________
贡献
问题和拉取请求欢迎访问 .
