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

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 ping and server_info tools
  • 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:

  1. Site Management Tools

    • Adding, listing, updating, and removing sites
    • Site connectivity testing
    • Site information retrieval
  2. Content Management Tools

    • Posts: CRUD operations, filtering, searching
    • Pages: CRUD operations, hierarchical structure
    • Media: Upload, listing, metadata management
  3. User Management Tools

    • User CRUD operations
    • Role management
    • Capability testing
  4. Taxonomy Management Tools

    • Categories and tags
    • Custom taxonomies
    • Term assignments
  5. Custom Post Types Tools

    • Listing custom post types
    • CRUD operations for custom post type items
  6. Plugin Management Tools

    • Listing, installing, activating, and removing plugins
    • Plugin updates
    • Plugin search
  7. 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:

  1. Checks if the server is already running on port 3000
  2. Starts the server in SSE mode if it's not already running
  3. Runs the test client with the ping tool
  4. Runs the test client with the list_sites tool
  5. Stops the server if it was started by the script

Manual SSE Testing

You can also test the SSE transport manually:

  1. Start the server in SSE mode:

    npm run start:sse
    
  2. Run the test client with a specific tool:

    node test-sse-client.js --tool=ping --params='{"message":"Hello!"}'
    
  3. 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:

  1. Start the server:

    npm start
    
  2. Add a WordPress site using the add_site tool:

    {
      "name": "My WordPress Site",
      "url": "https://example.com",
      "username": "admin",
      "applicationPassword": "XXXX XXXX XXXX XXXX XXXX XXXX"
    }
    
  3. Test various tools manually:

    • List posts: list_posts
    • Create a post: create_post
    • List users: list_users
    • etc.

Integration Testing

Since this is an MCP server, you can also test it by integrating it with AI assistants:

  1. Add it to your MCP settings file:

    {
      "mcpServers": {
        "wordpress": {
          "command": "node",
          "args": ["/path/to/wordpress-mcp/index.js"],
          "env": {},
          "disabled": false,
          "autoApprove": []
        }
      }
    }
    
  2. Restart your AI assistant

  3. 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:

  1. For stdio transport (local use only):

    {
      "mcpServers": {
        "wordpress": {
          "command": "node",
          "args": ["/path/to/wordpress-mcp/index.js"],
          "env": {},
          "disabled": false,
          "autoApprove": []
        }
      }
    }
    
  2. 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:

  1. Start the server:

    # For stdio transport
    npm start
    
    # For SSE transport
    npm run start:sse
    
  2. Open Cline in VS Code or Claude Desktop

  3. 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.)
  4. Test more complex operations:

    • Creating and updating content
    • Managing users
    • Installing and activating plugins/themes

Common Cline Issues

  1. 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;
    
  2. Body Parsing Issues: If Cline reports "stream is not readable" errors, check your body parsing middleware.

    Solution: Exclude the /message endpoint from body parsing:

    app.use((req, res, next) => {
      if (req.path !== '/message') {
        bodyParser.json()(req, res, next);
      } else {
        next();
      }
    });
    
  3. 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.

  4. 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

  1. Connection Refused: Make sure the server is running and listening on the expected port.
  2. Authentication Errors: Verify that the WordPress site credentials are correct.
  3. Permission Errors: Ensure the WordPress user has the necessary permissions.
  4. Missing Dependencies: Check that all required npm packages are installed.
  5. Session ID Issues: For SSE transport, ensure you're using the session ID from SSEServerTransport.
  6. Body Parsing Problems: Make sure the /message endpoint doesn't use body-parser middleware.
  7. Transport Compatibility: Verify your transport implementation follows the MCP protocol specification.

Debugging

For more detailed debugging:

  1. Enable verbose logging:

    DEBUG=* npm start
    
  2. Check the server logs:

    cat server.log
    
  3. For SSE issues, use the debug-sse.js script as mentioned above.

  4. 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"
    
  5. 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:

  1. Check the existing issues on GitHub
  2. Create a new issue with detailed information about the problem
  3. Include relevant logs and error messages