WordPress MCP 服务器

一个模型上下文协议 (MCP)服务器,使 AI 助手能够通过 WordPress REST API 与 WordPress 网站进行交互。它支持多个 WordPress 网站,并具有安全身份验证功能,支持通过自然语言进行内容管理、帖子操作和网站配置。
特征
多站点支持:同时连接到多个 WordPress 站点
REST API 集成:完全访问 WordPress REST API 端点
安全身份验证:使用应用程序密码进行安全的 API 访问
动态端点发现:自动映射每个站点的可用端点
灵活的操作:支持GET、POST、PUT、DELETE和PATCH方法
错误处理:优雅的错误处理,提供有意义的消息
简单配置:易于维护的 JSON 配置文件
Related MCP server: WordPress MCP Server
安装
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 WordPress 服务器:
npx -y @smithery/cli install server-wp-mcp --client claude
手动安装
npm install server-wp-mcp
工具参考
wp_discover_endpoints
映射 WordPress 网站上所有可用的 REST API 端点。
参数:
{
"site": {
"type": "string",
"description": "Site alias (as defined in configuration)",
"required": true
}
}
**返回:**可用端点及其方法和命名空间的列表。
wp_call_endpoint
对 WordPress 网站执行 REST API 请求。
参数:
{
"site": {
"type": "string",
"description": "Site alias",
"required": true
},
"endpoint": {
"type": "string",
"description": "API endpoint path",
"required": true
},
"method": {
"type": "string",
"enum": ["GET", "POST", "PUT", "DELETE", "PATCH"],
"description": "HTTP method",
"default": "GET"
},
"params": {
"type": "object",
"description": "Request parameters or body data",
"required": false
}
}
配置
获取应用程序密码
登录到您的 WordPress 管理仪表板
前往用户 → 个人资料
滚动到“应用程序密码”部分
输入应用程序的名称(例如“MCP Server”)
点击“添加新的申请密码”
复制生成的密码(您将无法再看到它)
注意:应用程序密码需要 WordPress 5.6 或更高版本和 HTTPS。
配置文件设置
使用您的 WordPress 网站详细信息创建一个 JSON 配置文件(例如wp-sites.json ):
{
"myblog": {
"URL": "https://myblog.com",
"USER": "yourusername",
"PASS": "abcd 1234 efgh 5678"
},
"testsite": {
"URL": "https://test.example.com",
"USER": "anotherusername",
"PASS": "wxyz 9876 lmno 5432"
}
}
每个站点配置都需要:
配置键(例如“myblog”,“testsite”)成为您与服务器交互时使用的站点别名。
与 Claude Desktop 一起使用
添加到您的claude_desktop_config.json :
{
"mcpServers": {
"wordpress": {
"command": "node",
"args": ["path/to/server/dist/index.js"],
"env": {
"WP_SITES_PATH": "/absolute/path/to/wp-sites.json"
}
}
}
}
WP_SITES_PATH环境变量必须指向配置文件的绝对路径。
示例用法
配置完成后,您可以要求 Claude 执行各种 WordPress 操作:
列出和查询帖子
Can you show me all posts from myblog published in the last month?
Find all posts on testsite tagged with "technology" and "AI"
Show me draft posts from myblog that need review
创建和编辑内容
Create a new draft post on testsite titled "The Future of AI" with these key points: [points]
Update the featured image on myblog's latest post about machine learning
Add a new category called "Tech News" to myblog
管理评论
Show me all pending comments on myblog's latest post
Find comments from testsite that might be spam
List the most engaged commenters on myblog
插件管理
What plugins are currently active on myblog?
Check if any plugins on testsite need updates
Tell me about the security plugins installed on myblog
用户管理
Show me all users with editor role on testsite
Create a new author account on myblog
Update user roles and permissions on testsite
站点设置和配置
What theme is currently active on myblog?
Check the permalink structure on testsite
Show me the current media library settings on myblog
维护和诊断
Check if there are any broken links on myblog
Show me the PHP version and other system info for testsite
List any pending database updates on myblog
错误处理
服务器处理常见错误包括:
配置文件路径或格式无效
无效的站点配置
身份验证失败
端点缺失或无效
API 速率限制
网络错误
所有错误都会返回描述性消息以帮助诊断问题。
安全注意事项
依赖项
执照
麻省理工学院