Lightweight connector plugin for WordPress 6.9+ to allow a Management Control Plane (MCP) to perform safe management actions via REST API and WP-CLI.
- π REST API β Full remote management via authenticated endpoints
- π₯οΈ WP-CLI β Command-line interface for SSH-based automation
- π Secure β API key authentication with env var support
- π¦ Plugin Management β List, update single, or bulk update all plugins
- π Content Management β Create posts remotely
- π§Ή Cache Control β Flush object cache on demand
- π‘ Site Registration β Register your site with an external MCP server
- Download the latest release from GitHub Releases.
- In WP Admin go to Plugins β Add New β Upload Plugin, select the zip and click Install Now.
- Activate the plugin.
composer require apicentraal/mcp-wp-connectorcd /path/to/wordpress/wp-content/plugins
git clone https://github.com/ApiCentraal/mcp-wp-connector.gitThen activate in WP Admin.
- Go to Settings β MCP Connector.
- Enter your MCP API URL (e.g.
https://mcp.example.com/api). - Enter your MCP API Key (generate with
openssl rand -hex 32). - Click Save Changes.
- Optionally click Register site to POST site metadata to the MCP.
# Add to your server environment or wp-config.php
export MCP_API_KEY="your_64_char_hex_key_here"The plugin will automatically read from the MCP_API_KEY env var if set.
All endpoints require authentication via Authorization: Bearer <API_KEY> header or X-MCP-API-Key: <API_KEY> header.
| Endpoint | Method | Description |
|---|---|---|
/wp-json/mcp/v1/action/ping |
POST | Returns site URL, WP version, PHP version, time |
/wp-json/mcp/v1/action/status |
POST | Returns DB prefix, active plugin count, WP version |
/wp-json/mcp/v1/action/create_post |
POST | Create a post |
/wp-json/mcp/v1/action/clear_cache |
POST | Flushes object cache |
/wp-json/mcp/v1/action/list_plugins |
POST | Returns list of all plugins |
/wp-json/mcp/v1/action/update_plugin |
POST | Update single plugin |
/wp-json/mcp/v1/action/update_all_plugins |
POST | Update all plugins with available updates |
/wp-json/mcp/v1/register |
POST | Register site with MCP server |
curl -X POST https://example.com/wp-json/mcp/v1/action/ping \
-H "Authorization: Bearer YOUR_API_KEY"Response:
{
"url": "https://example.com",
"wp_version": "6.9",
"php_version": "8.2.0",
"time": "2025-12-13 18:00:00"
}curl -X POST https://example.com/wp-json/mcp/v1/action/create_post \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title": "Hello World", "content": "<p>My content</p>", "status": "draft"}'Response:
{"post_id": 123}curl -X POST https://example.com/wp-json/mcp/v1/action/list_plugins \
-H "Authorization: Bearer YOUR_API_KEY"Response:
{
"plugins": [
{"slug": "akismet/akismet.php", "name": "Akismet", "version": "5.0", "active": true},
{"slug": "hello-dolly/hello.php", "name": "Hello Dolly", "version": "1.7", "active": false}
]
}curl -X POST https://example.com/wp-json/mcp/v1/action/update_plugin \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"plugin": "akismet/akismet.php"}'curl -X POST https://example.com/wp-json/mcp/v1/action/update_all_plugins \
-H "Authorization: Bearer YOUR_API_KEY"Response:
{"updated": ["plugin-a/plugin-a.php"], "failed": []}If WP-CLI is available, the plugin registers these commands:
| Command | Description |
|---|---|
wp mcp ping |
Show site info |
wp mcp status |
Show DB prefix, active plugins, WP version |
wp mcp clear-cache |
Flush object cache |
wp mcp list-plugins |
List all plugins with status |
wp mcp update-plugin <slug> |
Update a single plugin |
wp mcp update-all-plugins |
Update all plugins with available updates |
wp mcp create-post |
Create a post |
wp mcp register |
Register site with MCP server |
# Basic info
wp mcp ping
wp mcp status
# Plugin management
wp mcp list-plugins
wp mcp update-plugin akismet/akismet.php
wp mcp update-all-plugins
# Create content
wp mcp create-post --title="New Post" --content="Content here" --status=publish
# Register with MCP
wp mcp register| Aspect | Recommendation |
|---|---|
| API Key Storage | Use MCP_API_KEY env var instead of database |
| HTTPS | Always use HTTPS for API calls |
| IP Restriction | Restrict endpoint access via firewall/Cloudflare |
| Key Rotation | Rotate API keys periodically |
| Permissions | Plugin update endpoints modify files β use carefully |
- Never commit API keys to version control
- Use environment variables for sensitive configuration
- Restrict IP access to the REST endpoints if possible
- Monitor logs for unauthorized access attempts
- Keep plugins updated including this connector
mcp-wp-connector/
βββ mcp-wp-connector.php # Main plugin loader (v1.1.0)
βββ README.md # This file
βββ LICENSE # MIT License
βββ includes/
βββ helpers.php # API key/URL helpers, registration, auth
βββ admin.php # WP Admin settings page
βββ rest.php # REST API routes and handlers
βββ cli.php # WP-CLI commands
- Activate the plugin
- Configure API URL and Key in Settings β MCP Connector
- Test with cURL:
curl -X POST https://yoursite.com/wp-json/mcp/v1/action/ping \ -H "Authorization: Bearer YOUR_KEY"
wp mcp ping
wp mcp list-plugins# 1. Ping
curl -s -X POST https://yoursite.com/wp-json/mcp/v1/action/ping \
-H "Authorization: Bearer $MCP_KEY" | jq
# 2. Status
curl -s -X POST https://yoursite.com/wp-json/mcp/v1/action/status \
-H "Authorization: Bearer $MCP_KEY" | jq
# 3. List plugins
curl -s -X POST https://yoursite.com/wp-json/mcp/v1/action/list_plugins \
-H "Authorization: Bearer $MCP_KEY" | jq
# 4. Clear cache
curl -s -X POST https://yoursite.com/wp-json/mcp/v1/action/clear_cache \
-H "Authorization: Bearer $MCP_KEY" | jq
# 5. Create test post
curl -s -X POST https://yoursite.com/wp-json/mcp/v1/action/create_post \
-H "Authorization: Bearer $MCP_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"Test","status":"draft"}' | jq- β¨ Added
list_plugins,update_plugin,update_all_pluginsREST actions - β¨ Added WP-CLI integration (
wp mcp ...) - π Improved README with full documentation
- β»οΈ Refactored into modular structure (
includes/)
- π Initial release
- Basic REST endpoints: ping, status, create_post, clear_cache, register
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT Β© ApiCentraal
- GitHub Repository
- Releases
- Issues
- Improved README with full documentation.
- Refactored into modular structure (includes/).
- Initial release.
MIT Β© ApiCentraal