W

WordPress REST API管理器

@emzimmer/server-wp-mcp
0 Stars 590 次浏览 emzimmer 更新于 2026-08-23

启用AI助手通过WordPress REST API与[WordPress](https://wordpress.com/)网站进行交互。支持带有安全认证的多个WordPress网站,能够通过自然语言进行内容管理、帖子操作和站点配置。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "wordpress": {
      "args": [
        "path/to/server/dist/index.js"
      ],
      "command": "node",
      "env": {
        "WP_SITES_PATH": "/absolute/path/to/wp-sites.json"
      }
    }
  }
}

该服务需要配置环境变量:WP_SITES_PATH

服务介绍

WordPress MCP 服务器

smithery 徽章

一个 模型上下文协议 (MCP) 服务器,使 AI 助手能够通过 WordPress REST API 与 WordPress 站点进行交互。支持多个 WordPress 站点的安全认证,允许通过自然语言进行内容管理、发布操作和站点配置。

特性

  • 多站点支持:同时连接到多个 WordPress 站点
  • REST API 集成:完全访问 WordPress REST API 端点
  • 安全认证:使用应用程序密码进行安全的 API 访问
  • 动态端点发现:自动映射每个站点可用的端点
  • 灵活的操作:支持 GET、POST、PUT、DELETE 和 PATCH 方法
  • 错误处理:优雅的错误处理,并提供有意义的信息
  • 简单配置:易于维护的 JSON 配置文件

安装

通过 Smithery 安装

要通过 Smithery 自动安装适用于 Claude 桌面版的 WordPress 服务器:

npx -y @smithery/cli install server-wp-mcp --client claude

手动安装

npm install server-wp-mcp

工具参考

wp_discover_endpoints

在 WordPress 站点上映射所有可用的 REST API 端点。

参数:

{
    "site": {
        "type": "string",
        "description": "Site alias (as defined in configuration)",
        "required": true
    }
}

返回:
带有方法和命名空间的可用端点列表。

wp_call_endpoint

执行对 WordPress 站点的 REST API 请求。

参数:

{
    "site": {
        "type": "string",
        "description": "Site alias",
        "required": true
    },
    "endpoint": {
        "type": "string",
        "description": "API endpoint path",
        "required": true
    },
    "method": {
        "type": "string",
        "enum": ["GET", "POST", "PUT", "DELETE", "PATCH"],
        "description": "HTTP method",
        "default": "GET"
    },
    "params": {
        "type": "object",
        "description": "Request parameters or body data",
        "required": false
    }
}

配置

获取应用程序密码

  1. 登录您的 WordPress 管理后台
  2. 转到 用户 → 个人资料
  3. 滚动到 "应用程序密码" 部分
  4. 输入应用程序名称(例如,“MCP 服务器”)
  5. 单击“添加新应用程序密码”
  6. 复制生成的密码(您将无法再次查看它)

注意:应用程序密码要求 WordPress 5.6 或更高版本以及 HTTPS。

配置文件设置

创建一个包含您的 WordPress 站点详细信息的 JSON 配置文件(例如,wp-sites.json):

{
    "myblog": {
        "URL": "https://myblog.com",
        "USER": "yourusername",
        "PASS": "abcd 1234 efgh 5678"
    },
    "testsite": {
        "URL": "https://test.example.com",
        "USER": "anotherusername",
        "PASS": "wxyz 9876 lmno 5432"
    }
}

每个站点配置需要:

  • URL:WordPress 站点 URL(必须包括 http:// 或 https://)
  • USER:WordPress 用户名
  • PASS:应用程序密码(空格将被自动删除)

配置键(例如,"myblog","testsite")将成为您与服务器交互时使用的站点别名。

与 Claude 桌面版一起使用

将以下内容添加到您的 claude_desktop_config.json 中:

{
    "mcpServers": {
        "wordpress": {
            "command": "node",
            "args": ["path/to/server/dist/index.js"],
            "env": {
                "WP_SITES_PATH": "/absolute/path/to/wp-sites.json"
            }
        }
    }
}

WP_SITES_PATH 环境变量必须指向您的配置文件的绝对路径。

示例用法

配置完成后,您可以请求 Claude 执行各种 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 learning
Add a new category called "Tech News" to myblog

管理评论

Show me all pending comments on myblog's latest post
Find comments from testsite that might be spam
List the most engaged commenters on myblog

插件管理

What plugins are currently active on myblog?
Check if any plugins on testsite need updates
Tell me about the security plugins installed on myblog

用户管理

Show me all users with editor role on testsite
Create a new author account on myblog
Update user roles and permissions on testsite

站点设置和配置

What theme is currently active on myblog?
Check the permalink structure on testsite
Show me the current media library settings on myblog

维护和诊断

Check if there are any broken links on myblog
Show me the PHP version and other system info for testsite
List any pending database updates on myblog

错误处理

服务器处理的常见错误包括:

  • 无效的配置文件路径或格式
  • 无效的站点配置
  • 身份验证失败
  • 缺失或无效的端点
  • API 速率限制
  • 网络错误

所有错误都附带描述性消息,以帮助诊断问题。

安全注意事项

  • 确保您的 wp-sites.json 文件安全,并且不要将其提交到版本控制系统
  • 在生产环境中考虑使用环境变量来存储敏感数据
  • 将配置文件存储在公共目录之外
  • 对所有 WordPress 站点使用 HTTPS
  • 定期更换应用程序密码
  • 在分配用户角色时遵循最小权限原则

依赖项

  • @modelcontextprotocol/sdk - MCP 协议实现
  • axios - 用于 API 请求的 HTTP 客户端

许可证

MIT

相关 MCP 服务