WordPress MCP Server

WordPress MCP Server

镜像站点

简介

这是一个模型上下文协议(MCP)服务器,允许AI助手通过WordPress REST API与WordPress站点进行交互,提供创建、检索和更新文章的功能。

前提条件

  • Node.js v18+
  • WordPress站点(REST API已启用)
  • WordPress应用程序密码

快速开始

1. 安装

git clone https://github.com/stefans71/wordpress-mcp-server.git
cd wordpress-server
npm install
npm run build

2. 获取WordPress应用程序密码

  1. 登录WordPress管理面板
  2. 进入用户 → 个人资料
  3. 滚动到"应用程序密码"部分
  4. 输入名称(如"MCP 服务器")并点击"添加"
  5. 保存生成的密码

3. 配置MCP服务器

将服务器添加到MCP设置文件(~/AppData/Roaming/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json):

{
  "mcpServers": {
    "wordpress": {
      "command": "node",
      "args": ["path/to/wordpress-server/build/index.js"]
    }
  }
}

可用工具

创建文章

{
  "tool": "create_post",
  "siteUrl": "https://example.com",
  "username": "admin",
  "password": "xxxx xxxx xxxx xxxx",
  "title": "我的文章标题",
  "content": "文章内容",
  "status": "draft"
}

获取文章列表

{
  "tool": "get_posts",
  "siteUrl": "https://example.com",
  "username": "admin",
  "password": "xxxx xxxx xxxx xxxx",
  "perPage": 5,
  "page": 1
}

更新文章

{
  "tool": "update_post",
  "siteUrl": "https://example.com",
  "username": "admin",
  "password": "xxxx xxxx xxxx xxxx",
  "postId": 123,
  "title": "更新的标题",
  "content": "更新的内容",
  "status": "publish"
}

安全提示

  • 使用HTTPS URL
  • 定期更换应用程序密码
  • 不要分享密码凭据

许可证

许可证: MIT