这是一个用于 WordPress 集成的 Model Context Protocol (MCP) 服务器,兼容 Windows、macOS 和 Linux。
此 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 文章。
参数:
为了安全起见,建议使用 WordPress 应用程序密码而不是您的主账户密码进行身份验证。您可以在 WordPress 后台的“用户”→“安全性”→“应用程序密码”中生成一个应用程序密码。
使用环境变量:
{
"jsonrpc": "2.0",
"id": 1,
"method": "create_post",
"params": {
"title": "我的新文章",
"content": "你好,世界!",
"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": "我的新文章",
"content": "你好,世界!",
"status": "draft"
}
}
MIT 许可证 - 查看 LICENSE 文件获取详细信息