kungtekno/wordpress-mcp-server
If you are the rightful owner of wordpress-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The WordPress MCP Server is a TypeScript-based server that facilitates interaction between AI assistants and WordPress sites using the Model Context Protocol (MCP).
create_post
Create a new blog post
update_post
Update an existing post
delete_post
Delete a post
get_post
Retrieve a specific post
list_posts
List posts with filtering options
WordPress MCP Server
A comprehensive TypeScript-based STDIO MCP (Model Context Protocol) server for WordPress integration that enables AI assistants to interact with WordPress sites through a standardized interface. Built with enterprise-grade security, performance optimization, and extensibility in mind.
Features
- Full WordPress REST API Integration - Complete access to posts, pages, media, users, comments, and more
- MCP Protocol Compliant - Standard JSON-RPC over STDIO communication
- Type-Safe - Built with TypeScript for reliability and developer experience
- Caching - Multi-level caching for optimal performance
- Error Handling - Comprehensive error handling with detailed logging
- Configuration Management - Flexible configuration via files, environment variables, or CLI args
- Security - Built-in authentication, rate limiting, and security features
- Zero External Dependencies - Minimal dependencies for maximum reliability
Quick Start
Installation
# Install globally
npm install -g wordpress-mcp-server
# Or run directly with npx
npx wordpress-mcp-server
Configuration
Create a config.json
file:
{
"wordpress": {
"url": "https://your-wordpress-site.com",
"username": "your-username",
"password": "your-application-password"
}
}
Usage
# Start the MCP server
wordpress-mcp-server
# Or with custom config
wordpress-mcp-server --config /path/to/config.json
# Environment variables
WP_URL=https://example.com WP_USERNAME=admin WP_PASSWORD=pass wordpress-mcp-server
Configuration
File-based Configuration
The server looks for configuration files in this order:
./config.json
(current directory)~/.wordpress-mcp-config.json
(home directory)- Default configuration
Environment Variables
WP_URL
- WordPress site URLWP_USERNAME
- WordPress usernameWP_PASSWORD
- WordPress password or application passwordLOG_LEVEL
- Logging level (TRACE, DEBUG, INFO, WARN, ERROR, FATAL)CACHE_ENABLED
- Enable/disable caching (true/false)NODE_ENV
- Environment (development, production, test)
Command Line Arguments
wordpress-mcp-server \\
--wp-url https://example.com \\
--wp-username admin \\
--wp-password password \\
--log-level DEBUG \\
--cache-enabled
Available Tools
The server provides the following MCP tools:
Content Management
create_post
- Create a new blog postupdate_post
- Update an existing postdelete_post
- Delete a postget_post
- Retrieve a specific postlist_posts
- List posts with filtering options
Page Management
create_page
- Create a new pageupdate_page
- Update an existing pagedelete_page
- Delete a pageget_page
- Retrieve a specific pagelist_pages
- List pages with filtering options
Media Management
upload_media
- Upload media filesget_media
- Retrieve media informationlist_media
- List media filesdelete_media
- Delete media files
User Management
get_user
- Retrieve user informationlist_users
- List userscreate_user
- Create new usersupdate_user
- Update user information
Comment Management
get_comment
- Retrieve comment informationlist_comments
- List commentsapprove_comment
- Approve commentsdelete_comment
- Delete comments
Analytics (if enabled)
get_site_stats
- Retrieve site statisticsget_popular_posts
- Get most popular postsget_recent_activity
- Get recent site activity
Available Resources
The server exposes these MCP resources:
wordpress://posts
- Dynamic list of postswordpress://pages
- Dynamic list of pageswordpress://media
- Dynamic list of media fileswordpress://users
- Dynamic list of userswordpress://site-info
- WordPress site information
Development
Prerequisites
- Node.js 18+
- npm 8+
Setup
# Clone the repository
git clone https://github.com/wordpress-mcp/wordpress-mcp-server.git
cd wordpress-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Start in development mode
npm run dev
Project Structure
src/
āāā index.ts # Main entry point
āāā server.ts # MCP server implementation
āāā config/ # Configuration management
āāā handlers/ # MCP request handlers
āāā tools/ # WordPress tool implementations
āāā resources/ # MCP resource providers
āāā wordpress/ # WordPress API client
āāā utils/ # Utilities (logging, caching, etc.)
āāā cli/ # CLI commands
Testing
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch
# Run specific test file
npm test -- --testPathPattern=posts.test.ts
Security
Authentication
The server supports WordPress application passwords for secure authentication:
- Go to your WordPress admin ā Users ā Profile
- Scroll down to "Application Passwords"
- Create a new application password
- Use this password in your configuration
Rate Limiting
Built-in rate limiting prevents API abuse:
{
"wordpress": {
"rateLimit": {
"maxRequests": 100,
"windowMs": 60000
}
}
}
Security Features
- IP allowlisting
- API key authentication
- Request timeout limits
- Input validation
- Error message sanitization
Performance
Caching
Multi-level caching improves performance:
- Memory Cache: LRU cache for frequently accessed data
- Request Cache: Per-request caching to avoid duplicate API calls
- Response Cache: HTTP response caching with ETags
Configuration
{
"cache": {
"enabled": true,
"ttl": 300,
"maxSize": 1000,
"strategy": "lru"
}
}
Monitoring
Logging
Structured logging with multiple levels:
{
"logging": {
"level": "INFO",
"format": "json",
"colorize": false
}
}
Metrics
Enable metrics collection:
{
"server": {
"enableMetrics": true
}
}
Troubleshooting
Common Issues
-
Connection Failed
- Verify WordPress URL is correct
- Check if WordPress REST API is enabled
- Ensure application password is valid
-
Permission Denied
- Verify user has necessary capabilities
- Check WordPress user role permissions
- Ensure application password is for correct user
-
Rate Limited
- Reduce request frequency
- Adjust rate limit settings
- Check WordPress server limits
Debug Mode
Enable debug logging:
LOG_LEVEL=DEBUG wordpress-mcp-server
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see file for details.