使用说明
WordPress MCP服务器📝
用于WordPress的模型上下文协议(MCP)服务器,使Claude AI能够通过WordPress REST API创建、更新和管理WordPress博客文章。
✨ 特性
- 📄 创建新帖子(草稿或已发布)
- ✏️ 更新现有帖子
- 📋 列出带有过滤功能的帖子
- 🔍 获取帖子详细信息
- 🗑️ 删除帖子
- 🏷️ 列出类别和标签
- 🖼️ 上传媒体文件
- 🎯 完全支持帖子元数据(类别、标签、特色图片、摘录)
🚀 快速开始
先决条件
1.生成WordPress应用程序密码
- 登录您的WordPress管理仪表板
- 导航至 用户→ 个人资料
- 滚动到 应用程序密码 章节
- 输入名称(例如“MCP服务器”)
- 点击 添加新应用程序密码
- 复制生成的密码 (你不会再看到它了!)
2.克隆和构建
# Clone the repository
git clone https://github.com/SixFiveMil/wp-mcp-server.git
cd wp-mcp-server
# Build the Docker image
docker build -t wordpress-mcp-server .
3.配置环境
创建一个 .env 文件(复制自 .env.example):
cp .env.example .env
编辑 .env 使用您的凭据:
WORDPRESS_URL=https://your-site.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx
4.测试服务器
docker run -i --rm \
-e WORDPRESS_URL=https://your-site.com \
-e WORDPRESS_USERNAME=your-username \
-e WORDPRESS_APP_PASSWORD=your-app-password \
wordpress-mcp-server
或者使用docker compose:
# Edit docker-compose.yml with your credentials first
docker-compose up
🔧 Claude桌面集成
安装
-
找到您的Claude Desktop配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
-
添加WordPress MCP服务器配置:
{
"mcpServers": {
"wordpress": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "WORDPRESS_URL=https://your-site.com",
"-e", "WORDPRESS_USERNAME=your-username",
"-e", "WORDPRESS_APP_PASSWORD=your-app-password",
"wordpress-mcp-server"
]
}
}
}
- 重新启动克劳德桌面
📚 用法示例
配置后,您可以使用Claude与您的WordPress网站进行交互:
创建草稿帖子
Create a draft blog post titled "My First Post" with the content "Hello World!"
发布帖子
Create a published post titled "Announcing Our New Product" with this content: [your content]
列出最近的帖子
Show me the 5 most recent posts from my WordPress site
更新帖子
Update post ID 123 to change the status to published
使用类别
List all categories on my WordPress site
上传图片
Upload the image at /path/to/image.jpg to WordPress
🛠️ 可用工具
| 工具 | 说明 |
|---|---|
create_post |
创建具有完整元数据支持的新WordPress帖子 |
update_post |
更新现有帖子 |
get_post |
通过ID获取特定帖子的详细信息 |
list_posts |
列出带有筛选选项(状态、搜索、分页)的帖子 |
delete_post |
删除或删除帖子 |
list_categories |
列出所有可用类别 |
list_tags |
列出所有可用标签 |
upload_media |
将媒体文件上传到WordPress |
📖 API文档
create_post
{
"title": "Post Title",
"content": "Post content in HTML or plain text",
"status": "draft|publish|pending|private",
"excerpt": "Optional excerpt",
"categories": [1, 2, 3],
"tags": [4, 5, 6],
"featured_media": 123
}
update_post
{
"post_id": 123,
"title": "Updated Title",
"content": "Updated content",
"status": "publish"
}
list_post
{
"per_page": 10,
"page": 1,
"status": "any|publish|draft|pending|private",
"search": "search term"
}
🔒 安全说明
- ⚠️ 永远不要提交您的应用程序密码 到版本控制
- ✅ 使用环境变量或机密管理
- 🔑 应用程序密码可以随时从WordPress配置文件中撤销
- 🛡️ REST API尊重您的WordPress用户权限
- 🔐 在生产环境中为您的WordPress网站使用HTTPS
🐛 故障排除
身份验证错误
- 验证您的应用程序密码是否正确(空格会自动删除)
- 确保您的WordPress用户有权创建/编辑帖子
- 检查你的WordPress网站上是否启用了REST API
连接错误
- 验证WordPress URL是否正确且可访问
- 确保你的WordPress网站使用HTTPS
- 检查是否有防火墙阻止连接
- 确认WordPress REST API端点可在访问
/wp-json/wp/v2/
Docker问题
- 确保Docker正在运行:
docker ps - 验证已成功构建的映像:
docker images | grep wordpress-mcp - 检查Docker日志:
docker logs wordpress-mcp-server - 尝试重建:
docker build --no-cache -t wordpress-mcp-server .
🤝 贡献
欢迎投稿!以下是您可以提供帮助的一些方法:
- 🐛 报告错误
- 💡 建议新功能
- 📝 改进文档
- 🔧 提交拉取请求
看 贡献.md 了解更多详情。
开发环境设置
# Clone the repo
git clone https://github.com/SixFiveMil/wp-mcp-server.git
cd wp-mcp-server
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run tests (if available)
pytest
🗺️ 路线图
考虑中的未来功能:
- []支持自定义帖子类型
- []自定义字段管理
- []评论管理
- []用户管理
- []批量操作
- []媒体库管理
- []SEO元数据支持(Yoast、RankMath)
- []多站点支持
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
🙏 致谢
- 内置 模型上下文协议(MCP)
- 由...驱动 WordPress REST API
- 专为 克劳德Anthropic
📞 支持
由以下材料制成❤️ WordPress和AI社区