WordPress管理协议服务

WordPress MCP是一个模型上下文协议服务器,为AI代理提供对WordPress站点的全面管理功能,包括文章、页面、媒体、分类、标签、评论、SEO、重定向等46种工具。

  • by 5unnykum4r
  • PHP
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 5unnykum4r/wordpress-mcp

使用说明

WordPress MCP

一个模型上下文协议(MCP)服务器,让AI代理完全控制WordPress网站。通过46个MCP工具管理帖子、页面、媒体、类别、标签、评论、SEO、重定向、Gutenberg块、可重用模式、TablePress表、插件、用户和网站设置。

专为 克劳德代码。还与Claude Agent SDK和任何支持MCP的客户端兼容。

运作原理

┌─────────────┐     JSON-RPC      ┌──────────────────┐     HTTP/Auth     ┌─────────────────┐
│  Claude /    │ ──────────────▶  │  Python MCP      │ ──────────────▶  │  WordPress Site  │
│  AI Agent    │                  │  Proxy Server    │                  │  (MCP Adapter)   │
│              │ ◀──────────────  │  (server.py)     │ ◀──────────────  │  (mu-plugin)     │
└─────────────┘     MCP Tools     └──────────────────┘     JSON-RPC     └─────────────────┘
                                         │
                                    sites.json
                                  (multi-site config)

单个Python代理处理 无限制的WordPress网站每个工具调用都包含一个 site 参数以针对特定站点。身份验证使用WordPress应用程序密码(内置于WP 5.6+中)。

特性

类别 工具 功能
帖子和页面 9个工具 CRUD、批量状态更改、修订、搜索和替换
类别和标签 8个工具 支持排名数学SEO的CRUD
媒体 4个工具 从URL上传、浏览库、更新元数据、删除
评论 3个工具 列表、审核(批准/垃圾邮件/垃圾)、回复、删除
排名数学SEO -- 帖子和类别的完整SEO元数据(标题、描述、焦点关键字、Open Graph、Twitter、模式、机器人)
重定向 4个工具 排名数学重定向CRUD(301/302/307/410/451)
古腾堡积木 1工具 发现所有具有属性模式的已注册块类型
同步模式 5个工具 创建、读取、更新、删除可重用块
TablePress 5个工具 带显示选项和可见性的全表CRUD
插件 2个工具 列出已安装的插件,激活/停用
用户 1工具 列出具有角色筛选的用户
设置 3个工具 读/写选项、刷新缓存、获取站点信息
效用 1工具 列出所有已配置的站点

总计:46个工具 覆盖整个WordPress管理界面。

快速开始

1.安装WordPress适配器

# Build PHP dependencies locally
cd wordpress/
composer install

# Upload vendor/ and load-mcp-adapter.php to your WordPress server
# See SETUP.md for detailed instructions

2.配置代理

# Copy the example config
cp sites.json.example sites.json

# Edit with your site details
{
  "myblog": {
    "url": "https://yourdomain.com/wp-json/mcp/mcp-adapter-default-server",
    "username": "YourAdmin",
    "password": "xxxx xxxx xxxx xxxx xxxx xxxx"
  }
}

3.联系克劳德

克劳德代码 --添加到 ~/.claude.json (或请您的Claude Code代理为您设置):

{
  "mcpServers": {
    "wordpress": {
      "type": "stdio",
      "command": "uv",
      "args": [
        "run",
        "--with", "fastmcp",
        "--with", "httpx",
        "python",
        "/path/to/wordpress-mcp/server.py"
      ]
    }
  }
}

然后安装工具文档的技能:

npx skills add 5unnykum4r/wordpress-mcp

或手动符号链接:

ln -s /path/to/wordpress-mcp/skill/wordpress-mcp ~/.claude/skills/wordpress-mcp

查看完整 安装指南 有关详细说明、故障排除和使用示例。

工具参考

所有工具都需要 site 作为第一个参数。

Posts & Pages (9 tools)
工具 动作
list_posts 列出/过滤帖子和页面
read_post 阅读完整内容、元数据、SEO
create_post 创建内容、类别、标签、SEO
update_post 部分更新任何字段
delete_post 垃圾箱或永久删除
bulk_update_status 更改多个职位的状态
list_revisions 查看修订历史记录
restore_revision 恢复到以前的版本
search_replace 跨内容查找/替换(支持模拟运行)
Categories & Tags (8 tools)
工具 动作
list_categories 包含排名数学SEO数据的列表
create_category 使用可选的SEO创建
update_category 更新名称、slug、父级、SEO
delete_category 删除(帖子移动到默认值)
list_tags 列表和搜索标签
create_tag 创建新标签
update_tag 更新标签名称、slug、描述
delete_tag 删除标签(帖子未标记)
Media (4 tools)
工具 动作
upload_image 从URL下载并添加到媒体库
list_media 使用mime类型过滤进行浏览
update_media 更新标题、alt文本、标题
delete_media 永久删除
Comments (3 tools)
工具 动作
list_comments 按职位、状态、搜索筛选
update_comment 批准、垃圾邮件、垃圾或回复
delete_comment 永久删除
Redirections (4 tools)
工具 动作
list_redirections 列表排名数学重定向
create_redirection 创建301/302/307/410/451重定向
update_redirection 修改源、目标、类型
delete_redirection 删除重定向规则
Gutenberg & Patterns (6 tools)
工具 动作
list_block_types 发现已注册的块+模式
list_patterns 列出可重用/同步的模式
read_pattern 读取模式块内容
create_pattern 创建同步模式
update_pattern 更新图案内容
delete_pattern 删除图案
TablePress (5 tools)
工具 动作
list_tablepress_tables 列出所有表格
read_tablepress_table 读取数据、选项、可见性
create_tablepress_table 使用二维数据数组创建
update_tablepress_table 更新数据、选项、可见性
delete_tablepress_table 永久删除
Administration (7 tools)
工具 动作
list_plugins 列出已安装的插件+状态
toggle_plugin 激活或停用
list_users 按角色列出用户
manage_options 读/写WordPress设置
clear_cache 清空所有缓存
get_info 网站信息、版本、主题
list_sites 显示已配置的站点

项目结构

wordpress-mcp/
├── README.md                  ← This file
├── SETUP.md                   ← Full setup guide + troubleshooting
├── LICENSE                    ← MIT license
├── server.py                  ← Python MCP proxy (FastMCP + httpx)
├── sites.json.example         ← Site configuration template
├── wordpress/
│   ├── load-mcp-adapter.php   ← WordPress MU-plugin (server-side)
│   ├── composer.json          ← PHP dependencies
│   └── composer.lock
└── skill/
    └── wordpress-mcp/         ← Claude Code skill
        ├── SKILL.md
        └── references/        ← Tool documentation (7 files)

需求

本地(代理服务器):

  • Python 3.10+
  • 紫外线 包管理器
  • FastMCP和httpx(由自动安装 uv run)

WordPress服务器:

  • WordPress 5.6+(用于应用程序密码)
  • PHP 7.4+
  • 编辑器包: wordpress/abilities-api 和 wordpress/mcp-adapter

多站点管理

根据需要添加尽可能多的WordPress网站 sites.json:

{
  "blog": {
    "url": "https://blog.example.com/wp-json/mcp/mcp-adapter-default-server",
    "username": "admin",
    "password": "xxxx xxxx xxxx xxxx xxxx xxxx"
  },
  "shop": {
    "url": "https://shop.example.com/wp-json/mcp/mcp-adapter-default-server",
    "username": "admin",
    "password": "yyyy yyyy yyyy yyyy yyyy yyyy"
  },
  "docs": {
    "url": "https://docs.example.com/wp-json/mcp/mcp-adapter-default-server",
    "username": "editor",
    "password": "zzzz zzzz zzzz zzzz zzzz zzzz"
  }
}

每个网站都有自己的别名。针对任何网站 site="blog", site="shop"等等。添加新站点时不需要重新启动代理。

贡献

欢迎捐款。请打开问题或拉取请求。

许可证

麻省理工学院