](https://mseep.ai/app/diazoxide-wp-standalone-mcp)
WordPress独立MCP服务器
一个强大的 模型上下文协议(MCP) 服务器,通过WordPress REST API在人工智能助手和WordPress网站之间提供无缝集成。该服务器自动发现并为每个WordPress REST API端点创建单独的工具,实现自然语言WordPress管理。
✨ 特性
- 🔄 动态工具生成:自动为每个发现的WordPress REST API端点创建单独的工具
- 🌐 多站点支持:从单个配置同时管理多个WordPress站点
- 🔒 安全认证:使用WordPress应用程序密码进行安全的API访问
- 🎯 智能工具过滤:使用精确匹配或正则表达式模式包含/排除特定工具
- 📊 全面覆盖:支持帖子、页面、用户、媒体、评论、插件、主题等
- 🚀 零配置发现:自动映射所有可用端点,无需手动设置
- ⚡ 高性能:高效的端点发现和请求处理
- 🛡️ 错误处理:通过详细的诊断消息进行优雅的错误处理
🚀 快速开始
安装
# Install globally
npm install -g wp-standalone-mcp
# Or run directly with npx
npx github:diazoxide/wp-standalone-mcp start基本配置
- 创建WordPress应用程序密码:
- 转到您的WordPress管理员→ 用户→ 个人资料 - 滚动到“应用程序密码”部分 - 创建新的应用程序密码 - 复制生成的密码
- 创建配置文件 (
wp-sites.json):
{
"myblog": {
"URL": "https://myblog.com",
"USER": "your_username",
"PASS": "your_application_password"
}
}- 配置Claude桌面 (
claude_desktop_config.json):
{
"mcpServers": {
"wordpress": {
"command": "npx",
"args": ["-y", "github:diazoxide/wp-standalone-mcp", "start"],
"env": {
"WP_SITES_PATH": "/absolute/path/to/wp-sites.json"
}
}
}
}- 重新启动克劳德桌面 开始管理你的WordPress网站!
工具参考
动态端点工具
当服务器启动时,它会自动发现所有可用的WordPress REST API端点,并为每个端点/方法组合创建单独的工具。工具名称遵循以下模式: [site]_[method]_[resource] 或 [site]_[method]_[resource]_id 用于ID特定的端点。
示例:
myblog_get_v2_posts-列出所有帖子myblog_get_v2_posts_id-通过ID获取特定帖子myblog_post_v2_posts-创建新帖子myblog_put_v2_posts_id-更新特定帖子myblog_delete_v2_posts_id-删除特定帖子
wp_discover_endpoints
重新查找WordPress网站上所有可用的REST API端点。
论据:
{
"site": {
"type": "string",
"description": "Site alias (as defined in configuration)",
"required": true
}
}退货: 可用终结点及其方法和命名空间的列表。
🔧 配置
环境变量
WP_SITES_PATH:WordPress网站配置文件的路径WP_SITES:直接JSON配置(替代文件)
站点配置架构
{
"site_alias": {
"URL": "https://your-site.com",
"USER": "wordpress_username",
"PASS": "application_password",
"FILTERS": {
"include": ["tool_name_patterns"],
"exclude": ["tool_name_patterns"]
}
}
}获取应用程序密码
- 登录您的WordPress管理仪表板
- 转到用户→ 个人资料
- 滚动到“应用程序密码”部分
- 输入应用程序的名称(例如“MCP服务器”)
- 点击“添加新应用程序密码”
- 复制生成的密码(您将无法再次看到它)
注意:应用程序密码需要WordPress 5.6或更高版本和HTTPS。
高级工具筛选
通过过滤工具控制哪些WordPress操作可用:
{
"myblog": {
"URL": "https://myblog.com",
"USER": "admin",
"PASS": "abcd 1234 efgh 5678",
"FILTERS": {
"include": [
"myblog_get_v2_posts",
"myblog_post_v2_posts",
"/.*_get_.*_posts.*/"
],
"exclude": [
"myblog_delete_v2_posts_id",
"/.*_.*_users.*/",
"/.*_delete_.*/"
]
}
}
}筛选规则:
include:仅显示指定的工具(白名单)exclude:指定工具隐藏(黑名单)include优先于exclude- 支持精确匹配和正则表达式模式(换行
/pattern/)
🛠️ 生成的工具
服务器会按照以下命名约定自动创建工具:
- 模式:
[site]_[method]_[resource]或[site]_[method]_[resource]_id - 例子:
- myblog_get_v2_posts -列出所有帖子 - myblog_get_v2_posts_id -通过ID获取特定帖子 - myblog_post_v2_posts -创建新帖子 - myblog_put_v2_posts_id -更新特定帖子 - myblog_delete_v2_posts_id -删除特定帖子 - myblog_get_v2_media -列出媒体文件 - myblog_get_v2_users -列出用户
发现工具
wp_discover_endpoints-重新发现站点的可用端点
💡 使用示例
配置后,使用自然语言与您的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 the last 5 posts from myblog"
"Create a new draft post titled 'AI and the Future' on myblog"
"Update the featured image for post ID 123 on myblog"
"Delete the post with ID 456 from myblog"媒体管理
"List all images uploaded this month to myblog"
"Upload a new image to myblog media library"
"Get details for media file ID 789"用户管理
"Show all users with editor role on myblog"
"Create a new contributor account on myblog"
"Update user permissions for user ID 101"现场分析
"What plugins are active on myblog?"
"Show me all pending comments"
"Get the current theme information"
"List all categories and their post counts"🏗️ 建筑
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Claude AI │ │ MCP Server │ │ WordPress API │
│ │◄──►│ │◄──►│ │
│ Natural Language│ │ Dynamic Tools │ │ REST Endpoints │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ Configuration │
│ wp-sites.json │
└──────────────────┘🔒 安全
- 应用程序密码:使用WordPress的安全应用程序密码系统
- 需要HTTPS:所有连接都必须使用HTTPS
- 配置安全:将配置文件保存在web可访问的目录之外
- 最小特权原则:使用具有最低所需权限的帐户
- 无凭据存储:凭据仅用于API身份验证
🐛 故障排除
常见问题
“站点未配置”错误
- 验证配置中的站点别名是否与使用情况匹配
- 检查配置文件路径和格式
“身份验证失败”错误
- 验证应用程序密码是否正确
- 确保用户帐户具有必要的权限
- 检查网站URL是否可访问
“未发现工具”错误
- 验证WordPress网站是否已启用REST API
- 检查网站URL是否包含
/wp-json无障碍 - 查看任何阻止REST API的安全插件
调试模式
集 DEBUG=wp-mcp 详细日志记录的环境变量:
DEBUG=wp-mcp npx github:diazoxide/wp-standalone-mcp start📋 需求
- WordPress:5.6+(用于应用程序密码)
- Node.js: 16+
- 超文本传输安全协议:应用程序密码需要
- REST API:必须启用(WordPress中的默认设置)
🤝 贡献
我们欢迎捐款!请查看我们的 贡献指南 了解详情。
- 复刻仓库
- 创建要素分支
- 进行更改
- 如果适用,添加测试
- 提交拉取请求
📄 许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
🔗 链接
- 仓库:
- 问题:
- WordPress REST API: https://developer.wordpress.org/rest-api/
- 模型上下文协议: https://modelcontextprotocol.io/
🙏 致谢
- WordPress REST API团队为全面的API
- 模型上下文协议规范的拟人化
- 开源社区提供持续的支持和反馈
______________________________________________________________________
由...制作❤️ WordPress和AI社区
