关于 Mcp Wordpress
Mcp Wordpress 是通过 WordPress REST API v2 管理站点的 MCP 服务,面向需要借助 AI 助手维护 WordPress 内容的用户。它提供覆盖内容、媒体、用户及站点设置的 54 个工具,并支持多种认证方式。
主要功能
- 01管理文章和页面
- 02浏览与上传媒体
- 03管理用户、评论和分类标签
- 04查询及更新站点设置
- 05支持应用密码、JWT 和 Basic Auth
适用场景
- 01创建或编辑 WordPress 文章与页面
- 02上传媒体并更新媒体信息
- 03处理评论和管理用户
- 04检查站点统计或调整设置
MCP 相关
该 MCP 服务通过 WordPress REST API v2 访问站点,并向 MCP 客户端提供 54 个 WordPress 管理工具。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
MCP WordPress Server
通过 WordPress REST API v2 管理 WordPress 的综合 MCP 服务。完全使用 TypeScript 编写,提供最高的类型安全性和更好的开发者体验。
🚀 功能
- 54 个 WordPress 管理工具,涵盖 8 个类别
- 100% TypeScript - 完整的类型安全性和 IntelliSense
- 现代 ES Modules - 针对性能进行了优化
- 交互式设置向导 - 轻松配置
- 全面测试 - 完整的测试套件
- 灵活的身份验证 - 支持 App Passwords、JWT、Basic Auth
- 调试与监控 - 结构化日志记录和错误跟踪
⚡ 快速开始
选项 1:NPX(推荐)
最简单的开始方式,无需安装:
# Run directly with NPX
npx @aiondadotcom/mcp-wordpress
# Or install globally
npm install -g @aiondadotcom/mcp-wordpress
mcp-wordpress
选项 2:本地开发
git clone https://github.com/AiondaDotCom/mcp-wordpress.git
cd mcp-wordpress
npm install
npm run setup
npm start
设置向导
# For NPX users
npx @aiondadotcom/mcp-wordpress setup
# For local installation
npm run setup
设置向导将引导你完成以下操作:
- 配置 WordPress 网站
- 选择身份验证方式
- 测试连接
- 配置 Claude Desktop
🚀 通过 Claude Desktop 轻松设置
超简单的 NPX 设置
如果你想要最简单的设置方式,只需将以下提示词粘贴到 Claude Desktop 中:
Set up the MCP WordPress server using NPX for my Claude Desktop.
My WordPress details:
- Site URL: [YOUR_WORDPRESS_URL]
- Username: [YOUR_USERNAME]
Please:
1. Help me create a WordPress Application Password
2. Configure my Claude Desktop mcp.json file with the NPX command
3. Test the connection to make sure everything works
4. Show me how to use the WordPress tools
I want to use the NPX version (@aiondadotcom/mcp-wordpress) so I don't need to install anything locally.
完整的本地开发设置
用于本地开发和自定义:
Build and configure the MCP WordPress server project from https://github.com/AiondaDotCom/mcp-wordpress locally on my computer.
Please:
1. Clone the repository to an appropriate directory
2. Install all dependencies
3. Run the setup wizard and help me configure my WordPress connection
4. Test the connection to make sure everything works
5. Set up the Claude Desktop MCP configuration
6. Run a quick test to verify all tools are working
My WordPress site URL is: [YOUR_WORDPRESS_URL]
My WordPress username is: [YOUR_USERNAME]
Guide me through any steps that require manual input, and let me know if you need any additional information from me.
只需将 [YOUR_WORDPRESS_URL] 和 [YOUR_USERNAME] 替换为你的实际 WordPress 网站信息,Claude 就会处理其余事项!
🔧 配置
环境变量(.env)
WORDPRESS_SITE_URL=https://your-wordpress-site.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx
WORDPRESS_AUTH_METHOD=app-password
DEBUG=false
Claude Desktop 集成
在 Claude Desktop 的 mcp.json 配置文件中配置 MCP WordPress Server:
选项 1:NPX(推荐)
{
"mcpServers": {
"mcp-wordpress": {
"command": "npx",
"args": ["@aiondadotcom/mcp-wordpress"],
"env": {
"WORDPRESS_SITE_URL": "https://your-site.com",
"WORDPRESS_USERNAME": "your-username",
"WORDPRESS_APP_PASSWORD": "your-app-password",
"WORDPRESS_AUTH_METHOD": "app-password"
}
}
}
}
选项 2:全局安装
{
"mcpServers": {
"mcp-wordpress": {
"command": "mcp-wordpress",
"env": {
"WORDPRESS_SITE_URL": "https://your-site.com",
"WORDPRESS_USERNAME": "your-username",
"WORDPRESS_APP_PASSWORD": "your-app-password",
"WORDPRESS_AUTH_METHOD": "app-password"
}
}
}
}
选项 3:本地开发
{
"mcpServers": {
"mcp-wordpress": {
"command": "node",
"args": ["/path/to/mcp-wordpress/dist/index.js"],
"env": {
"WORDPRESS_SITE_URL": "https://your-site.com",
"WORDPRESS_USERNAME": "your-username",
"WORDPRESS_APP_PASSWORD": "your-app-password",
"WORDPRESS_AUTH_METHOD": "app-password"
}
}
}
}
使用 .env 文件(适用于任何选项)
如果你更愿意使用 .env 文件,而不是在配置中设置环境变量:
{
"mcpServers": {
"mcp-wordpress": {
"command": "npx",
"args": ["@aiondadotcom/mcp-wordpress"],
"env": {
"NODE_ENV": "production"
}
}
}
}
Claude Desktop 配置文件位置
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
快速配置步骤
- 在上述路径创建或找到 Claude Desktop 配置文件
- 使用上述任一选项添加 MCP 服务配置
- 重启 Claude Desktop 以使更改生效
- 验证连接 - 你应该能在 Claude Desktop 中看到可用的 WordPress 工具
完整配置示例
以下是包含 MCP WordPress 的完整 claude_desktop_config.json 文件:
{
"mcpServers": {
"mcp-wordpress": {
"command": "npx",
"args": ["@aiondadotcom/mcp-wordpress"],
"env": {
"WORDPRESS_SITE_URL": "https://your-site.com",
"WORDPRESS_USERNAME": "your-username",
"WORDPRESS_APP_PASSWORD": "your-app-password",
"WORDPRESS_AUTH_METHOD": "app-password"
}
}
}
}
🛠 构建系统
TypeScript 构建
# Compile
npm run build
# Watch mode
npm run build:watch
# Type checking
npm run typecheck
开发
# Development mode with debug output
npm run dev
# Check status
npm run status
# Re-run setup
npm run setup
🔐 身份验证
WordPress 应用程序密码(推荐)
- WordPress 管理后台 → 用户 → 个人资料
- 滚动到 应用程序密码
- 输入名称(例如,“MCP WordPress Server”)
- 点击 添加新的应用程序密码
- 复制生成的密码(格式:
xxxx xxxx xxxx xxxx xxxx xxxx)
其他身份验证方式
# JWT Authentication (requires JWT plugin)
WORDPRESS_AUTH_METHOD=jwt
WORDPRESS_JWT_SECRET=your-jwt-secret
# Basic Authentication (not recommended for production)
WORDPRESS_AUTH_METHOD=basic
WORDPRESS_PASSWORD=your-actual-password
# API Key Authentication (requires API Key plugin)
WORDPRESS_AUTH_METHOD=api-key
WORDPRESS_API_KEY=your-api-key
📋 可用工具(54 个工具)
📝 文章(6 个工具)
wp_list_posts- 列出并筛选博客文章wp_get_post- 获取指定文章wp_create_post- 创建新文章wp_update_post- 编辑文章wp_delete_post- 删除文章wp_get_post_revisions- 获取文章修订版本
📄 页面(6 个工具)
wp_list_pages- 列出页面wp_get_page- 获取指定页面wp_create_page- 创建新页面wp_update_page- 编辑页面wp_delete_page- 删除页面wp_get_page_revisions- 获取页面修订版本
🖼️ 媒体(6 个工具)
wp_list_media- 浏览媒体库wp_get_media- 获取媒体详情wp_upload_media- 上传文件wp_update_media- 编辑媒体元数据wp_delete_media- 删除媒体wp_get_media_sizes- 获取可用的图片尺寸
👥 用户(6 个工具)
wp_list_users- 列出用户wp_get_user- 获取用户详情wp_create_user- 创建新用户wp_update_user- 编辑用户资料wp_delete_user- 删除用户wp_get_current_user- 获取当前用户
💬 评论(7 个工具)
wp_list_comments- 列出评论wp_get_comment- 获取评论详情wp_create_comment- 创建新评论wp_update_comment- 编辑评论wp_delete_comment- 删除评论wp_approve_comment- 批准评论wp_spam_comment- 将评论标记为垃圾评论
🏷️ 分类法(10 个工具)
wp_list_categories- 列出分类wp_get_category- 获取分类详情wp_create_category- 创建新分类wp_update_category- 编辑分类wp_delete_category- 删除分类wp_list_tags- 列出标签wp_get_tag- 获取标签详情wp_create_tag- 创建新标签wp_update_tag- 编辑标签wp_delete_tag- 删除标签
⚙️ 站点管理(7 个工具)
wp_get_site_settings- 获取站点设置wp_update_site_settings- 更新站点设置wp_get_site_stats- 获取站点统计信息wp_search_site- 全站搜索wp_get_application_passwords- 列出应用程序密码wp_create_application_password- 创建新的应用程序密码wp_delete_application_password- 删除应用程序密码
🔐 身份验证(6 个工具)
wp_test_auth- 测试身份验证wp_get_auth_status- 获取身份验证状态wp_start_oauth_flow- 启动 OAuth 流程wp_complete_oauth_flow- 完成 OAuth 流程wp_refresh_oauth_token- 刷新 OAuth 令牌wp_switch_auth_method- 切换身份验证方式
🧪 测试
# Run all tests
npm test
# Tests with coverage
npm run test:coverage
# Quick tests
npm run test:fast
# MCP integration tests
npm run test:mcp
# Tool integration tests
npm run test:tools
# Tests in watch mode
npm run test:watch
📊 状态与监控
# Check connection status
npm run status
# Debug mode
DEBUG=true npm run dev
# Lint code
npm run lint
# Auto-fix linting errors
npm run lint:fix
🏗 项目结构
mcp-wordpress/
├── src/ # TypeScript source code
│ ├── index.ts # Main MCP server
│ ├── server.ts # Server compatibility
│ ├── types/ # TypeScript definitions
│ │ ├── wordpress.ts # WordPress API types
│ │ ├── mcp.ts # MCP protocol types
│ │ ├── client.ts # Client interface types
│ │ └── index.ts # Type exports
│ ├── client/ # WordPress API client
│ │ ├── api.ts # HTTP client
│ │ └── auth.ts # Authentication
│ ├── tools/ # MCP tool implementations
│ │ ├── posts.ts # Post management
│ │ ├── pages.ts # Page management
│ │ ├── media.ts # Media management
│ │ ├── users.ts # User management
│ │ ├── comments.ts # Comment management
│ │ ├── taxonomies.ts # Categories/Tags
│ │ ├── site.ts # Site settings
│ │ └── auth.ts # Authentication
│ └── utils/ # Utility functions
│ └── debug.ts # Debug logger
├── dist/ # Compiled JavaScript files
├── bin/ # Utility scripts
│ ├── setup.js # Setup wizard
│ └── status.js # Status checker
├── tests/ # Test suite
├── scripts/ # Build and test scripts
├── tsconfig.json # TypeScript configuration
├── jest.config.json # Jest test configuration
└── package.json # Node.js project configuration
💡 TypeScript 特性
- 完整的类型安全 - 编译时验证
- IntelliSense 支持 - 更好的 IDE 集成
- 类型安全的 API 客户端 - 类型化的 HTTP 方法
- 全面的 WordPress 类型 - 400 多行精准定义
- MCP 协议类型 - 工具定义和处理程序
- 增强的错误处理 - 类型化异常
- 源映射 - 调试支持
🔧 WordPress 要求
- WordPress 5.0+,并启用 REST API
- HTTPS(建议用于生产环境)
- 具有相应权限的用户
- 启用应用程序密码(WordPress 5.6+)
WordPress 用户角色
| 角色 | 访问权限 |
|---|---|
| 管理员 | 可完全访问所有功能 |
| 编辑者 | 文章、页面、评论、媒体 |
| 作者 | 自己的文章和媒体 |
| 投稿者 | 自己的文章(仅草稿) |
| 订阅者 | 只读 |
🐛 故障排除
常见问题
-
“无法连接到 WordPress”
- 检查 WORDPRESS_SITE_URL
- 确保 REST API 可访问
- 测试:
curl https://your-site.com/wp-json/wp/v2/
-
“身份验证失败”
- 验证用户名和应用程序密码
- 确保已启用应用程序密码
- 尝试再次运行
npm run setup
-
“TypeScript 编译错误”
- 运行
npm run typecheck - 确保已安装所有依赖项
- 运行
调试日志
DEBUG=true npm run dev
📚 API 文档
🤝 参与贡献
- Fork 此仓库
- 创建功能分支:
git checkout -b feature/new-feature - 提交更改:
git commit -m 'Add new feature' - 推送分支:
git push origin feature/new-feature - 创建拉取请求
📄 许可证
MIT 许可证 - 详情请参阅 LICENSE 文件
🚀 由 TypeScript 驱动,带来更出色的开发体验和类型安全!
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。