mcpField
W
wordpress-mcp

wordpress-mcp

github.com/5unnykum4r营销与增长344 次安装35 周前更新
代码仓库

关于 wordpress-mcp

wordpress-mcp 是一项通过 Python MCP 代理服务管理 WordPress 站点的技能。它支持跨已配置站点操作内容、媒体、评论、设置、插件、重定向、Gutenberg 区块和 TablePress。

主要功能

  1. 01创建、读取、更新和删除文章
  2. 02管理分类、标签、媒体和评论
  3. 03处理 Rank Math SEO 字段与重定向
  4. 04查看和编辑 Gutenberg 区块及模式
  5. 05管理插件、设置和缓存
  6. 06创建和更新 TablePress 表格

适用场景

  1. 01发布文章并优化内容
  2. 02审查和更新文章 SEO 元数据
  3. 03修改别名并创建重定向
  4. 04使用自定义区块或表格构建文章

MCP 相关

Python FastMCP 代理向 MCP 客户端提供 WordPress 站点管理工具。每个工具指定一个已配置站点,并将请求转发到该站点的 WordPress MCP 适配器。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/5unnykum4r/wordpress-mcp --skill wordpress-mcp

安装后在 Claude Code 中输入/wordpress-mcp确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
admin.md
categories-tags.md
comments.md
media.md
posts.md
redirections.md
tablepress.md

详细介绍

WordPress MCP 网站管理

通过单个 Python MCP 代理服务(~/.claude.json 中的 wordpress)管理 WordPress 网站。所有工具都需要一个用于标识目标网站的 site 参数。网站配置在 sites.json 中。

设置

此技能需要 WordPress MCP 服务。如果尚未提供 wordpress MCP 工具,请从 https://github.com/5unnykum4r/wordpress-mcp 设置完整项目:

  1. 克隆仓库,并在 WordPress 网站上安装 PHP 适配器(wordpress/ 目录)
  2. 创建 WordPress 应用程序密码,并将网站添加到 sites.json
  3. 将 MCP 服务添加到 ~/.claude.json:
{
  "mcpServers": {
    "wordpress": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--with", "fastmcp", "--with", "httpx", "python", "/path/to/wordpress-mcp/server.py"]
    }
  }
}

完整的分步指南请参阅仓库中的 SETUP.md。

工作原理

Python FastMCP 服务会将工具调用代理到任意 WordPress 网站:

  1. 每个工具都将 site 作为第一个参数(例如,site="myblog")
  2. 代理会在 sites.json 中查找凭据
  3. 向 WordPress MCP 适配器端点发送 JSON-RPC 请求
  4. 通过 HTTP Basic Auth 使用 WordPress 应用程序密码进行身份验证

使用 list_sites 查看所有已配置的网站。

可用工具

有关完整的参数详情,请参阅 references/posts.md、references/categories-tags.md、references/media.md、references/comments.md、references/redirections.md、references/admin.md 和 references/tablepress.md。

快速参考

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

工具操作关键参数
list_posts列出文章/页面status, category, tag, search, post_type, page
read_post读取完整文章及 SEO 信息post_id
create_post创建文章/页面title, content, slug, status, author, categories, tags, rank_math
update_post更新文章/页面post_id + 要更改的任意字段(包括 author)
delete_post移入回收站/删除post_id, permanent
bulk_update_status批量更改状态post_ids[], status
list_revisions查看修订历史post_id
restore_revision恢复修订版本revision_id
search_replace在文章中查找/替换search, replace, dry_run
list_categories列出分类及 SEO 信息hide_empty, parent, search
create_category创建分类name, slug, description, parent_id, rank_math
update_category编辑分类category_id + 字段,rank_math
delete_category删除分类category_id
list_tags列出标签hide_empty, search
create_tag创建标签name, slug, description
update_tag编辑标签tag_id + 字段
delete_tag删除标签tag_id
upload_image从 URL 上传image_url, title, alt_text, filename
list_media浏览媒体库mime_type, search, page
update_media编辑媒体元数据attachment_id, title, alt_text, caption
delete_media删除媒体项attachment_id
list_comments列出评论post_id, status, search
update_comment批准/标记为垃圾评论/回复comment_id, status, reply
delete_comment删除评论comment_id
list_redirections列出 Rank Math 重定向search
create_redirection创建重定向from_url, to, type (301/302)
update_redirection编辑重定向redirection_id + 字段
delete_redirection删除重定向redirection_id
list_plugins列出已安装的插件—
toggle_plugin启用/停用plugin, action
list_users列出用户role, search
manage_options读取/写入 WP 设置read[], write{}
clear_cache清除所有缓存—
get_info获取站点信息及统计数据—
list_block_types列出 Gutenberg 区块namespace, custom_only
list_patterns列出已同步的样板search
read_pattern读取样板内容pattern_id
create_pattern创建已同步的样板title, content
update_pattern更新样板pattern_id + 字段
delete_pattern删除样板pattern_id
list_tablepress_tables列出 TablePress 表格—
read_tablepress_table读取表格数据及选项table_id
create_tablepress_table创建新表格name, data[][], options
update_tablepress_table更新表格table_id + 任意字段
delete_tablepress_table删除表格table_id
list_sites显示已配置的站点—

Rank Math SEO

创建/更新时,文章和分类都支持 rank_math 对象。

文章字段:

title, description, focus_keyword, canonical_url, robots[],
primary_category, pillar_content, breadcrumb_title, schema_type,
og_title, og_description, og_image, twitter_title, twitter_description

分类字段:

title, description, focus_keyword, canonical_url, robots[],
breadcrumb_title, og_title, og_description, og_image,
twitter_title, twitter_description

read_post 和 list_categories 会返回所有 Rank Math 字段。

Gutenberg 区块

文章内容以 Gutenberg 区块标记的形式存储。read_post 会返回原始区块 HTML,其中包含 `` 分隔符。create_post 和 update_post 的 content 字段接受完整的区块标记,区块注释会原样保留。

使用 list_block_types 可发现所有已注册的区块(核心区块 + 自定义区块)。传入 custom_only=True 可仅查看主题/插件区块,或传入 namespace="your-theme" 按命名空间筛选。每个区块条目都包含其属性架构,方便你构造有效的区块标记。

区块标记格式:


<div class="wp-block-namespace-block-name">Inner HTML</div>

更新现有文章的内容时,务必先执行 read_post 获取完整的区块标记,修改指定区块,然后将完整内容传回。

常见工作流

创建优化后的文章
  1. upload_image(site="myblog", image_url="...") — 上传特色图片
  2. create_post(site="myblog", title="...", content="...", categories=["Tech"], rank_math={...}) — 创建文章并设置 SEO
  3. read_post(site="myblog", post_id=123) — 验证
  4. update_post(site="myblog", post_id=123, status="publish") — 发布
批量 SEO 审核
  1. list_posts(site="myblog", number=50) — 获取所有已发布的文章
  2. read_post(site="myblog", post_id=X) — 检查 rank_math 字段
  3. update_post(site="myblog", post_id=X, rank_math={...}) — 修复缺失的 SEO 信息
更改 slug 后管理重定向
  1. read_post(site="myblog", post_id=123) — 获取当前 slug
  2. update_post(site="myblog", post_id=123, slug="new-slug") — 更改 slug
  3. create_redirection(site="myblog", from_url="/old-slug", to="/new-slug", type=301) — 设置重定向
搜索和替换
  1. search_replace(site="myblog", search="old text", replace="new text", dry_run=True) — 预览
  2. search_replace(site="myblog", search="old text", replace="new text", dry_run=False) — 执行
创建可重复使用的同步样式
  1. create_pattern(site="myblog", title="CTA Banner", content="...") — 返回引用区块标记
  2. 在任意文章内容中使用返回的 ref_block(例如 ``)
  3. 更新样式会自动更新所有引用它的文章
使用自定义 Gutenberg 区块创建文章
  1. list_block_types(site="myblog", custom_only=True) — 查找自定义区块及其属性
  2. 构建区块标记:\n<div>...</div>\n
  3. create_post(site="myblog", title="...", content="...block markup...", rank_math={...}) — 创建文章
  4. read_post(site="myblog", post_id=123) — 验证区块内容是否保留
编辑现有文章中的区块
  1. read_post(site="myblog", post_id=123) — 从 content 获取当前区块标记
  2. 修改内容字符串中的指定 `` 区块
  3. update_post(site="myblog", post_id=123, content="...updated full content...") — 保存修改
创建并嵌入 TablePress 表格
  1. create_tablepress_table(site="myblog", name="Pricing", data=[["Plan","Price"],["Basic","$9"],["Pro","$29"]]) — 返回 id 和简码
  2. update_post(site="myblog", post_id=123, content="... [table id=5 /] ...") — 嵌入文章
  3. read_tablepress_table(site="myblog", table_id="5") — 验证

管理站点

站点配置在 sites.json 中:

{
  "myblog": {
    "url": "https://example.com/wp-json/mcp/mcp-adapter-default-server",
    "username": "AdminUsername",
    "password": "xxxx xxxx xxxx xxxx xxxx xxxx"
  }
}

添加新站点:在 WordPress 服务器上安装 MCP 适配器(参见 SETUP.md),创建应用程序密码,并在 sites.json 中添加条目。无需重启。

站点专属扩展

对于具有自定义工作流的站点(例如 ACF 自定义字段、特定内容模板、SEO 恢复计划),请在此文件旁创建其他技能文件,并在项目的 CLAUDE.md 或 .claude/skills/ 目录中引用它们。

示例结构:

~/.claude/skills/
├── wordpress-mcp/         ← This skill (generic WordPress tools)
│   ├── SKILL.md
│   └── references/
└── my-site-workflow/      ← Your custom skill (site-specific context)
    └── SKILL.md

评论

支持 Markdown