WordPress MCP服务器
](https://smithery.ai/server/server-wp-mcp)
A. 模型上下文协议(MCP) 使人工智能助手能够通过WordPress REST API与WordPress网站交互的服务器。支持多个具有安全身份验证的WordPress网站,通过自然语言实现内容管理、帖子操作和网站配置。
特性
- 多站点支持:同时连接到多个WordPress网站
- REST API集成完全访问 WordPress REST API 端点
- 安全认证:使用应用程序密码进行安全的API访问
- 动态端点发现:自动映射每个站点的可用端点
- 灵活操作:支持GET、POST、PUT、DELETE和PATCH方法
- 错误处理:通过有意义的消息进行优雅的错误处理
- 简单配置:易于维护的JSON配置文件
安装
通过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服务器”)
- 点击“添加新应用程序密码”
- 复制生成的密码(您将无法再次看到它)
注意:应用程序密码需要WordPress 5.6或更高版本和HTTPS。
配置文件设置
创建JSON配置文件(例如。, wp-sites.json)您的WordPress网站详细信息:
{
"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"
}
}每个站点配置都需要:
URL:WordPress网站URL(必须包含http://或https://)USER:WordPress用户名PASS:应用程序密码(空格将自动删除)
配置键(例如“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 learningAdd a new category called "Tech News" to myblog管理评论
Show me all pending comments on myblog's latest postFind comments from testsite that might be spamList the most engaged commenters on myblog插件管理
What plugins are currently active on myblog?Check if any plugins on testsite need updatesTell me about the security plugins installed on myblog用户管理
Show me all users with editor role on testsiteCreate a new author account on myblogUpdate user roles and permissions on testsite站点设置和配置
What theme is currently active on myblog?Check the permalink structure on testsiteShow me the current media library settings on myblog维护和诊断
Check if there are any broken links on myblogShow me the PHP version and other system info for testsiteList any pending database updates on myblog错误处理
服务器处理常见错误,包括:
- 配置文件路径或格式无效
- 站点配置无效
- 身份验证失败
- 端点缺失或无效
- API速率限制
- 网络错误
所有错误都会返回描述性消息,以帮助诊断问题。
安全考虑
- 保持你的
wp-sites.json文件安全,从不将其提交到版本控制 - 考虑在生产中为敏感数据使用环境变量
- 将配置文件存储在公共目录之外
- 对所有WordPress网站使用HTTPS
- 定期轮换应用程序密码
- 分配用户角色时遵循最小权限原则
依赖项
- @modelcontextprotocol/sdk-MCP协议实现
- axios-API请求的HTTP客户端
许可证
麻省理工学院
