返回市场
wordpress-mcp服务器

wordpress-mcp服务器

作者:prathammanocha46 星标更新:2025-05-15

项目介绍

MseeP.ai 安全评估徽章

综合型WordPress MCP服务器

这是一个全面的模型上下文协议(MCP)服务器,使AI助手能够通过WordPress REST API与WordPress站点进行交互。该服务器提供了管理WordPress所有方面的工具,包括文章、用户、评论、分类、标签和自定义端点。

<a href="https://glama.ai/mcp/servers/@prathammanocha/wordpress-mcp-server"> <img width="380" height="200" src="https://gips1.baidu.com/it/u=412732315,3367631977&fm=3081&app=3081&f=PNG?w=760&h=400" alt="WordPress Server MCP服务器" /> </a>

功能

文章管理

  • 创建、检索、更新和删除WordPress文章
  • 根据各种参数过滤文章
  • 文章列表的分页支持

用户管理

  • 根据ID或登录名检索用户信息
  • 更新用户详细信息
  • 删除用户

评论管理

  • 创建、检索、更新和删除评论
  • 根据文章过滤评论
  • 评论列表的分页支持

税务管理

  • 管理类别和标签
  • 创建、检索、更新和删除税务
  • 根据别名查找类别和标签

站点信息

  • 检索通用的WordPress站点信息

自定义请求

  • 支持自定义REST API端点
  • 自定义HTTP方法(GET、POST、PUT、DELETE)
  • 自定义数据和参数

预备条件

  • Node.js v18或更高版本
  • 启用了REST API的WordPress站点
  • 用于身份验证的WordPress应用程序密码

安装

  1. 克隆此仓库:
git clone [repository-url]
cd wordpress-mcp-server
  1. 安装依赖项:
npm install
  1. 构建服务器:
npm run build

WordPress配置

在使用服务器之前,您需要设置您的WordPress站点:

  1. 确保您的WordPress站点启用了REST API(默认情况下在WordPress 4.7+中启用)
  2. 创建一个应用程序密码:
    • 登录到您的WordPress管理面板
    • 转到用户→个人资料
    • 滚动到“应用程序密码”
    • 输入应用程序名称(例如,“MCP服务器”)
    • 单击“添加新应用程序密码”
    • 复制生成的密码(您将无法再次看到它)

MCP配置

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

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

可用工具

文章管理

1. create_post

创建一个新的WordPress文章。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • title(必需):文章标题
  • content(必需):文章内容
  • status(可选):文章状态('draft','publish'或'private',默认为'draft')

示例:

{
  "tool": "create_post",
  "siteUrl": "https://example.com",
  "username": "admin",
  "password": "xxxx xxxx xxxx xxxx",
  "title": "我的第一篇文章",
  "content": "你好,世界!",
  "status": "draft"
}

2. get_posts

带有分页的支持检索WordPress文章。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • perPage(可选):每页的文章数量(默认:10)
  • page(可选):页码(默认:1)
  • customParams(可选):额外的查询参数

示例:

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

3. update_post

更新现有的WordPress文章。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • postId(必需):要更新的文章ID
  • title(可选):新的文章标题
  • content(可选):新的文章内容
  • status(可选):新的文章状态('draft','publish'或'private')

示例:

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

4. delete_post

删除WordPress文章。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • postId(必需):要删除的文章ID

示例:

{
  "tool": "delete_post",
  "siteUrl": "https://example.com",
  "username": "admin",
  "password": "xxxx xxxx xxxx xxxx",
  "postId": 123
}

用户管理

1. get_users

检索WordPress用户。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • perPage(可选):每页的用户数量(默认:10)
  • page(可选):页码(默认:1)

2. get_user

根据ID检索特定的WordPress用户。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • userId(必需):要检索的用户的ID

3. get_user_by_login

根据登录名检索WordPress用户。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • userLogin(必需):要检索的用户的登录名

评论管理

1. get_comments

检索WordPress评论。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • perPage(可选):每页的评论数量(默认:1 10)
  • page(可选):页码(默认:1)
  • postIdForComment(可选):根据文章ID过滤评论

2. create_comment

在文章上创建新的评论。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • postIdForComment(必需):要评论的文章ID
  • commentContent(必需):评论内容
  • customData(可选):附加的评论数据

分类和标签管理

1. get_categories

检索WordPress分类。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • perPage(可选):每页的分类数量(默认:10)
  • page(可选):页码(默认:1)

2. create_category

创建一个新的WordPress分类。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • categoryName(必需):要创建的分类名称
  • customData(可选):附加的分类数据(描述、父级等)

自定义请求

1. custom_request

向任何WordPress REST API端点发出自定义请求。

参数:

  • siteUrl(必需):您的WordPress站点URL
  • username(必需):WordPress用户名
  • password(必需):WordPress应用程序密码
  • customEndpoint(必需):API端点路径
  • customMethod(可选):HTTP方法('GET','POST','PUT','DELETE',默认:'GET')
  • customData(可选):POST/PUT请求的数据
  • customParams(可选):GET请求的URL参数

示例:

{
  "tool": "custom_request",
  "siteUrl": "https://example.com",
  "username": "admin",
  "password": "xxxx xxxx xxxx xxxx",
  "customEndpoint": "wp/v2/media",
  "customMethod": "GET",
  "customParams": {
    "per_page": 5
  }
}

响应格式

所有工具返回响应的格式如下:

成功响应

{
  "success": true,
  "data": {
    // WordPress API响应数据
  },
  "meta": {
    // 可选元数据(分页信息等)
  }
}

错误响应

{
  "success": false,
  "error": "错误消息在这里"
}

安全注意事项

  • 始终使用HTTPS URL访问您的WordPress站点
  • 使用应用程序密码而不是您的主要WordPress密码
  • 保护好您的应用程序密码,不要分享
  • 考虑使用WordPress角色和权限来限制访问
  • 定期轮换应用程序密码

开发

为了贡献于开发:

  1. 分叉仓库
  2. 创建功能分支
  3. 进行更改
  4. 运行测试(如果有)
  5. 提交拉取请求

对于自动重新编译的开发模式:

npm run dev

许可证

本项目采用ISC许可证。

贡献

欢迎贡献!请随时提交拉取请求。