Skip to main content
Glama

WordPress MCP 服务器

一个生产就绪的 WordPress 集成 Model Context Protocol (MCP) 服务器。使 AI 代理能够通过结构化工具与 WordPress 网站交互。

功能特性

  • 39 个 WordPress 工具,涵盖文章、页面、媒体、用户、分类、标签、插件、主题、菜单和 WooCommerce

  • 安全认证,使用 WordPress 应用程序密码

  • 破坏性操作保护,需要明确确认

  • 结构化错误处理,带有详细错误代码

  • 分页支持,用于列表操作

  • 基于环境的配置,用于凭据

Related MCP server: WordPress MCP Server

前提条件

  • Node.js 18+

  • WordPress 网站,已启用 REST API

  • WordPress 应用程序密码用于认证

安装

npm install
npm run build

配置

在项目根目录创建 .env 文件:

WORDPRESS_URL=https://your-wordpress-site.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=your-application-password

生成应用程序密码

  1. 转到 WordPress 后台 → 用户 → 您的个人资料

  2. 滚动到“应用程序密码”

  3. 输入名称(例如“MCP 服务器”)

  4. 点击“添加新应用程序密码”

  5. 复制生成的密码

用法

运行服务器

# Development
npm run dev

# Production
npm start

与 MCP 客户端集成

添加到您的 MCP 客户端配置:

{
  "mcp": {
    "wordpress": {
      "type": "local",
      "command": ["node", "/path/to/wordpress-mcp-server/dist/index.js"],
      "environment": {
        "WORDPRESS_URL": "https://your-site.com",
        "WORDPRESS_USERNAME": "your-username",
        "WORDPRESS_APP_PASSWORD": "your-app-password"
      }
    }
  }
}

可用工具

站点操作

工具

描述

get_site_info

获取站点名称、描述、URL

get_site_settings

获取站点配置

get_site_health

获取健康诊断

get_performance

获取性能指标

search_site

搜索整个站点内容

文章操作

工具

描述

list_posts

列出文章(支持筛选)

get_post

根据 ID 获取单篇文章

create_post

创建新文章

update_post

更新现有文章

delete_post

删除文章(需要确认)

publish_post

发布草稿文章

页面操作

工具

描述

list_pages

列出页面(支持筛选)

get_page

根据 ID 获取单个页面

create_page

创建新页面

update_page

更新现有页面

delete_page

删除页面(需要确认)

媒体操作

工具

描述

list_media

列出媒体库项目

upload_media

上传媒体文件

delete_media

删除媒体(需要确认)

用户操作

工具

描述

list_users

列出用户(支持筛选)

get_user

根据 ID 获取单个用户

create_user

创建新用户

update_user

更新现有用户

分类法操作

工具

描述

list_categories

列出分类

create_category

创建新分类

list_tags

列出标签

create_tag

创建新标签

插件操作

工具

描述

list_plugins

列出已安装的插件

activate_plugin

激活插件(需要确认)

deactivate_plugin

停用插件(需要确认)

主题操作

工具

描述

list_themes

列出已安装的主题

activate_theme

激活主题(需要确认)

菜单操作

工具

描述

get_menus

获取导航菜单

update_menu

更新菜单

WooCommerce 操作

工具

描述

get_woocommerce_products

列出产品

create_woocommerce_product

创建产品

update_woocommerce_product

更新产品

get_woocommerce_orders

列出订单

get_woocommerce_customer

列出客户

安全性

  • 凭据存储在环境变量中(绝不会在输出中暴露)

  • 破坏性操作需要明确确认

  • 只读操作自动执行

  • 对所有受保护资源进行认证

开发

# Run in development mode
npm run dev

# Build for production
npm run build

# Run tests
npm test

项目结构

wordpress-mcp-server/
├── src/
│   ├── index.ts          # Entry point
│   ├── server.ts         # MCP server setup
│   ├── client/
│   │   └── wordpress.ts  # WordPress API client
│   ├── tools/
│   │   ├── index.ts      # Tool registration
│   │   ├── definitions.ts # Tool schemas
│   │   ├── site.ts       # Site tools
│   │   ├── posts.ts      # Post tools
│   │   ├── pages.ts      # Page tools
│   │   ├── media.ts      # Media tools
│   │   ├── users.ts      # User tools
│   │   ├── taxonomies.ts # Taxonomy tools
│   │   ├── plugins.ts    # Plugin tools
│   │   ├── themes.ts     # Theme tools
│   │   ├── menus.ts      # Menu tools
│   │   └── woocommerce.ts # WooCommerce tools
│   ├── validation/
│   │   └── schemas.ts    # Zod validation schemas
│   ├── types/
│   │   └── index.ts      # TypeScript type definitions
│   └── utils/
│       ├── config.ts     # Environment configuration
│       └── logger.ts     # Structured logging
├── package.json
├── tsconfig.json
└── .env.example

许可证

MIT

Related MCP Connectors

Related MCP Servers