WordPress MCP Python
A lightweight MCP server that connects to WordPress via REST API, enabling content management (posts, pages, categories, etc.) and site configuration through natural language commands.
README
WordPress MCP Python
A lightweight standalone Python MCP server that connects to WordPress via REST API.
Features
- Standalone Python package - Runs independently, no WordPress plugin needed
- Easy setup with
pip install - Full WordPress REST API support: Posts, Pages, Categories, Tags, Users, Media, Settings
- WooCommerce support: Products, Orders (optional)
- MCP SDK integration for Claude Desktop
- Async/await for better performance
Requirements
- Python 3.8+
- WordPress site with REST API enabled
- Application Password or JWT token
Installation
From PyPI (recommended)
pip install wordpress-mcp
From source
git clone https://github.com/tannht/wordpress-mcp-python.git
cd wordpress-mcp-python
pip install -e .
Configuration
1. Get WordPress Application Password
- Go to WordPress Admin → Users → Profile
- Scroll down to Application Passwords
- Create a new one (name it "MCP")
- Copy the generated password
Format: abcd-efgh-ijkl-mnop (4 groups of 4 chars)
2. Set Environment Variables
export WP_URL="https://yoursite.com"
export WP_USERNAME="your_username"
export WP_PASSWORD="your_application_password"
Or use JWT token:
export WP_URL="https://yoursite.com"
export WP_JWT_TOKEN="your_jwt_token"
Usage
As a Library
import asyncio
from wordpress_mcp import WordPressClient
async def main():
client = WordPressClient(
base_url="https://yoursite.com",
username="your_username",
password="your_app_password"
)
# Create a post
post = await client.create_post(
title="Hello from Python!",
content="This post was created via Python MCP.",
status="draft"
)
print(f"Created post: {post['id']}")
asyncio.run(main())
As MCP Server (for Claude Desktop)
# Run the MCP server
python -m wordpress_mcp
Claude Desktop Integration
Add to your Claude Desktop config:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"wordpress": {
"command": "python",
"args": ["-m", "wordpress_mcp"],
"env": {
"WP_URL": "https://yoursite.com",
"WP_USERNAME": "your_username",
"WP_PASSWORD": "your_application_password"
}
}
}
}
Docker
Build and run the MCP server using Docker:
# Build and start the server
docker compose up -d --build
# View logs
docker compose logs -f
# Stop the server
docker compose down
The server runs on stdio transport and connects to WordPress via REST API.
Environment Variables
Create a .env file in the project root:
WP_URL=https://yoursite.com
WP_USERNAME=your_username
WP_PASSWORD=your_application_password
# Or use JWT token
# WP_JWT_TOKEN=your_jwt_token
Claude Code Integration
Add the WordPress MCP server to Claude Code:
claude mcp add --transport stdio wordpress \
--env WP_URL=https://yoursite.com \
--env WP_USERNAME=your_username \
--env WP_PASSWORD=your_application_password \
-- wordpress-mcp
Verify connection:
claude mcp list
MCP Tools Available
Posts
wp_posts_search- Search posts with paginationwp_get_post- Get post by IDwp_add_post- Create new postwp_update_post- Update postwp_delete_post- Delete post
Pages
wp_pages_search- Search pageswp_get_page- Get page by IDwp_add_page- Create new page
Categories
wp_list_categories- List all categorieswp_add_category- Add new category
Tags
wp_list_tags- List all tagswp_add_tag- Add new tag
Users
wp_users_search- Search userswp_get_user- Get user by ID
Media
wp_media_search- Search media items
Settings
wp_get_site_info- Get site informationwp_get_settings- Get site settings
WooCommerce (optional)
wc_products_search- Search productswc_get_product- Get product by IDwc_add_product- Create productwc_orders_search- Search orderswc_get_order- Get order by ID
Development
Setup Development Environment
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=wordpress_mcp
# Format code
black src/ tests/
# Lint
ruff check src/ tests/
Project Structure
wordpress-mcp-python/
├── pyproject.toml # Project metadata, dependencies
├── README.md
├── .gitignore
├── src/
│ └── wordpress_mcp/
│ ├── __init__.py # Package init, entry point
│ ├── client.py # WordPress REST API client
│ └── server.py # MCP server implementation
├── tests/
│ ├── __init__.py
│ ├── conftest.py # Pytest fixtures
│ └── test_client.py # Client tests
└── scripts/
└── test_connection.py # Connection test script
Troubleshooting
Connection refused
- Make sure WordPress REST API is enabled
- Check your site URL is correct (include https://)
Authentication failed
- Verify Application Password is correct
- Ensure username has proper permissions
Import errors
- Check Python version (3.8+ required)
- Install with
pip install -e .for development
Comparison: Python vs PHP
| Feature | Python MCP | PHP Plugin |
|---|---|---|
| Installation | pip install | Upload plugin |
| Size | ~50KB | ~160KB |
| Dependencies | mcp, httpx, pyjwt | firebase/php-jwt |
| Location | Runs anywhere | Must be in WordPress |
| Update | git pull | Plugin update |
License
MIT
Credits
Based on WordPress MCP by Automattic.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器