这是一个用于 WordPress 集成的 Model Context Protocol (MCP) 服务器,支持 Windows、macOS 和 Linux 系统,能借助 WordPress REST API 与 WordPress 站点进行交互。
此 MCP 服务器可通过 WordPress REST API 与 WordPress 站点交互,提供了使用 JSON - RPC 2.0 协议创建、获取和更新文章的功能。
npm install
npm run build
将服务器添加到 MCP 设置文件中,并使用环境变量设置 WordPress 凭证:
{
"mcpServers": {
"wordpress": {
"command": "node",
"args": ["path/to/build/index.js"],
"env": {
"WORDPRESS_SITE_URL": "https://your-wordpress-site.com",
"WORDPRESS_USERNAME": "your-username",
"WORDPRESS_PASSWORD": "your-app-password"
}
}
}
}
环境变量包括:
你也可以在请求参数中提供这些凭证,如果你不想使用环境变量的话。
创建新的 WordPress 文章。
参数:
获取 WordPress 文章。
参数:
更新现有的 WordPress 文章。
参数:
使用环境变量:
{
"jsonrpc": "2.0",
"id": 1,
"method": "create_post",
"params": {
"title": "My New Post",
"content": "Hello World!",
"status": "draft"
}
}
不使用环境变量:
{
"jsonrpc": "2.0",
"id": 1,
"method": "create_post",
"params": {
"siteUrl": "https://your-wordpress-site.com",
"username": "your-username",
"password": "your-app-password",
"title": "My New Post",
"content": "Hello World!",
"status": "draft"
}
}
此服务器使用 JSON - RPC 2.0 协议与 WordPress 站点进行交互,通过 WordPress REST API 实现文章的创建、获取和更新操作。在配置方面,支持使用环境变量或请求参数来设置 WordPress 凭证,提高了使用的灵活性。
出于安全考虑,建议使用 WordPress 应用程序密码而不是你的主账户密码。你可以在 WordPress 仪表盘的 用户 → 安全 → 应用程序密码 下生成应用程序密码。