使用说明
WordPress MCP服务器
用于与WordPress站点交互的模型上下文协议(MCP)服务器。该服务器提供了从任何启用REST API的WordPress安装中获取帖子、页面、类别和网站信息的工具。
先决条件
- Python 3.13
- 启用 REST API 的 WordPress 网站
- UV封装安装程序(推荐)
安装
- 安装UV(通用Virtualenv):
curl -LsSf https://astral.sh/uv/install.sh | sh
- 克隆存储库:
git clone <repository-url>
cd wordpress
- 创建并激活虚拟环境:
uv venv
source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
- 使用UV安装依赖项:
uv add "mcp[cli]" httpx
配置
- 创建一个
.env项目根目录中的文件:
WORDPRESS_URL="https://your-wordpress-site.com"
用法
将Claude用于桌面:
- 首先,启动服务器:
uv run main.py
- 在Claude for Desktop中,转到“设置”>“开发人员”
- 点击“编辑配置”
- 在Mac/Windows中使用VSCode的替代编辑配置方法:
# For Mac Users code ~/Library/Application\ Support/Claude/claude_desktop_config.json # For Windows Users code $env:AppData\Claude\claude_desktop_config.json - 将文件添加到配置:
{
"mcpServers": {
"weather": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/wordpress",
"run",
"main.py"
]
}
}
}
服务器提供以下可测试的工具:
fetch_wordpress_info:获取网站基本信息fetch_posts:获取最新帖子fetch_categories:列出所有类别fetch_posts_by_category:获取特定类别中的帖子fetch_pages:获取网站页面fetch_post_by_id:获得一个特定的职位fetch_page_by_id:获取特定页面
错误处理
该服务器包括强大的错误处理功能,用于:
- JSON响应无效
- 网络错误
- WordPress API错误
- URL无效
- API身份验证问题
