Testing the WordPress MCP Server
April 6, 2025 ยท View on GitHub
This document provides information on how to test the WordPress MCP Server using various methods.
Table of Contents
- Testing the WordPress MCP Server
Basic Testing
The test.js script provides a basic test of the MCP server functionality:
node test.js
This script:
- Starts the server process
- Connects to it using the MCP client
- Lists available tools
- Executes the basic
pingandserver_infotools - Disconnects and terminates the server
This is useful for verifying that the server is running correctly and that the basic MCP protocol is working.
Feature-Specific Testing
The project includes specialized test scripts for specific features:
Theme Management Testing
node test-theme-tools.js
This script tests the theme management tools by:
- Starting the server
- Connecting to it
- Checking for theme management tools
- Getting the active site
- Listing themes
- Searching for themes
- Getting theme details
Plugin Management Testing
node test-plugin-tools.js
Similar to the theme tools test, this script tests plugin management functionality.
Site Management Testing
node test-site-tools.js
This script tests site management functionality.
Comprehensive Testing
To ensure all tools are working correctly, we provide a comprehensive testing framework that systematically tests all tool categories.
Using the Test-All Script
The test-all-tools.js script provides a comprehensive test of all MCP server tools:
node test-all-tools.js
This script:
- Tests all tool categories sequentially
- Verifies both success and error handling
- Provides detailed reporting of test results
- Cleans up after tests to avoid side effects
You can also test specific categories:
# Test only site management tools
node test-all-tools.js --category=site
# Test multiple categories
node test-all-tools.js --category=site,post,user
# Test with verbose logging
node test-all-tools.js --verbose
Test Coverage
The comprehensive testing framework covers:
-
Site Management Tools
- Adding, listing, updating, and removing sites
- Site connectivity testing
- Site information retrieval
-
Content Management Tools
- Posts: CRUD operations, filtering, searching
- Pages: CRUD operations, hierarchical structure
- Media: Upload, listing, metadata management
-
User Management Tools
- User CRUD operations
- Role management
- Capability testing
-
Taxonomy Management Tools
- Categories and tags
- Custom taxonomies
- Term assignments
-
Custom Post Types Tools
- Listing custom post types
- CRUD operations for custom post type items
-
Plugin Management Tools
- Listing, installing, activating, and removing plugins
- Plugin updates
- Plugin search
-
Theme Management Tools
- Listing, installing, activating, and removing themes
- Theme updates
- Theme search
SSE Transport Testing
The WordPress MCP Server supports two transport modes: stdio (default) and SSE (Server-Sent Events). The SSE transport allows for remote access to the server via HTTP.
Using the Test Script
The easiest way to test the SSE transport is to use the provided test script:
./test-sse.sh
This script:
- Checks if the server is already running on port 3000
- Starts the server in SSE mode if it's not already running
- Runs the test client with the ping tool
- Runs the test client with the list_sites tool
- Stops the server if it was started by the script
Manual SSE Testing
You can also test the SSE transport manually:
-
Start the server in SSE mode:
npm run start:sse -
Run the test client with a specific tool:
node test-sse-client.js --tool=ping --params='{"message":"Hello!"}' -
Test with other tools:
node test-sse-client.js --tool=list_sites node test-sse-client.js --tool=get_site --params='{"id":"site-1"}'
SSE Debugging
If you encounter issues with the SSE transport, you can use the debug-sse.js script to get more detailed information:
node debug-sse.js
This script starts a simple SSE server with detailed logging of all operations.
Manual Testing
For more comprehensive testing:
-
Start the server:
npm start -
Add a WordPress site using the
add_sitetool:{ "name": "My WordPress Site", "url": "https://example.com", "username": "admin", "applicationPassword": "XXXX XXXX XXXX XXXX XXXX XXXX" } -
Test various tools manually:
- List posts:
list_posts - Create a post:
create_post - List users:
list_users - etc.
- List posts:
Integration Testing
Since this is an MCP server, you can also test it by integrating it with AI assistants:
-
Add it to your MCP settings file:
{ "mcpServers": { "wordpress": { "command": "node", "args": ["/path/to/wordpress-mcp/index.js"], "env": {}, "disabled": false, "autoApprove": [] } } } -
Restart your AI assistant
-
Ask the AI to interact with your WordPress sites through the MCP server
Cline Integration Testing
Cline is an AI assistant that can use MCP servers to interact with external systems. Testing the WordPress MCP Server with Cline requires special considerations.
Configuration
To configure Cline to use the WordPress MCP Server:
-
For stdio transport (local use only):
{ "mcpServers": { "wordpress": { "command": "node", "args": ["/path/to/wordpress-mcp/index.js"], "env": {}, "disabled": false, "autoApprove": [] } } } -
For SSE transport (remote access):
{ "mcpServers": { "wordpress": { "autoApprove": [], "disabled": false, "timeout": 60, "url": "http://localhost:3000/sse", "transportType": "sse" } } }
Add this configuration to:
- VS Code:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json - Claude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json
Testing with Cline
To test the WordPress MCP Server with Cline:
-
Start the server:
# For stdio transport npm start # For SSE transport npm run start:sse -
Open Cline in VS Code or Claude Desktop
-
Test basic functionality:
- Ask Cline to list available WordPress sites
- Ask Cline to get information about a site
- Ask Cline to perform simple operations (list posts, etc.)
-
Test more complex operations:
- Creating and updating content
- Managing users
- Installing and activating plugins/themes
Common Cline Issues
-
Session ID Mismatch: If Cline can't connect to the server, check the session ID handling in your SSE implementation.
Solution: Use the session ID from the SSEServerTransport:
const transport = new SSEServerTransport('/message', res); const sessionId = transport.sessionId; -
Body Parsing Issues: If Cline reports "stream is not readable" errors, check your body parsing middleware.
Solution: Exclude the
/messageendpoint from body parsing:app.use((req, res, next) => { if (req.path !== '/message') { bodyParser.json()(req, res, next); } else { next(); } }); -
Tool Not Found: If Cline reports that a tool is not found, check that the tool is properly registered.
Solution: Verify tool registration in your server code and check the tool name in Cline's request.
-
Connection Timeout: If Cline reports connection timeouts, check your server's timeout settings.
Solution: Increase the timeout value in your server configuration and in the Cline MCP settings.
Troubleshooting
Common Issues
- Connection Refused: Make sure the server is running and listening on the expected port.
- Authentication Errors: Verify that the WordPress site credentials are correct.
- Permission Errors: Ensure the WordPress user has the necessary permissions.
- Missing Dependencies: Check that all required npm packages are installed.
- Session ID Issues: For SSE transport, ensure you're using the session ID from SSEServerTransport.
- Body Parsing Problems: Make sure the
/messageendpoint doesn't use body-parser middleware. - Transport Compatibility: Verify your transport implementation follows the MCP protocol specification.
Debugging
For more detailed debugging:
-
Enable verbose logging:
DEBUG=* npm start -
Check the server logs:
cat server.log -
For SSE issues, use the debug-sse.js script as mentioned above.
-
Monitor network traffic for SSE transport:
# Using tcpdump sudo tcpdump -i lo0 port 3000 -A # Using browser developer tools # Open Chrome/Firefox dev tools, go to Network tab, and filter for "sse" or "message" -
Debug Cline integration issues:
- Check Cline's logs in VS Code or Claude Desktop
- Verify the MCP settings file is correctly formatted
- Test with the test-sse-client.js script to isolate Cline-specific issues
Getting Help
If you encounter issues that you can't resolve, please:
- Check the existing issues on GitHub
- Create a new issue with detailed information about the problem
- Include relevant logs and error messages