newspack-lit-mcp

Automattic/newspack-lit-mcp

3.1

If you are the rightful owner of newspack-lit-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

Newspack Lit MCP is a WordPress MCP server plugin designed for migration operations, utilizing the Abilities API and MCP Adapter to expose WordPress abilities as MCP tools.

Tools
2
Resources
0
Prompts
0

Newspack Lit MCP

Newspack Launch and Infrastructure MCP server plugin is a WordPress MCP server for migration operations built using the Abilities API and MCP Adapter. This plugin demonstrates how to create an MCP server that exposes WordPress abilities as MCP tools.

Important note: this early version is an illustrative POC, and both its transport mechanisms (authentication) and functional elements (tools and value of the effect) are to be improved.

Key Features

  • Two MCP Tools Available:
    • lit-mcp-read-json-file - Reads JSON files from wp-content/uploads/mcp_data/
    • lit-mcp-write-json-file - Writes JSON content to files in the wp-content/uploads/mcp_data/ directory
  • Modern WordPress Architecture:
    • Uses Abilities API for ability registration and management
    • Uses MCP Adapter for MCP server functionality
    • REST transport with proper JSON-RPC handling
    • Error handling and observability
  • Security:
    • Basic HTTP authentication support
    • WordPress user capability checking (edit_posts required)
    • Proper permission validation
  • Data Management:
    • Files stored in wp-content/uploads/mcp_data/ directory
    • Automatic directory creation
    • JSON validation and pretty-printing

Requirements

Installation

  1. Install Dependencies (via WP-CLI):

    wp plugin install https://github.com/WordPress/abilities-api/releases/latest/download/abilities-api.zip --activate
    wp plugin install https://github.com/WordPress/mcp-adapter/releases/latest/download/mcp-adapter.zip --activate
    
  2. Install Lit MCP:

    # Clone or copy the plugin to your plugins directory
    wp plugin activate lit-mcp
    
  3. Install Composer Dependencies:

    cd /path/to/wordpress/wp-content/plugins/lit-mcp
    composer install
    

MCP Configuration

  • Claude Desktop

Add this configuration to your MCP settings file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS).

  • Cursor IDE

Add this configuration to your .cursor/mcp.json file.

Note: Update the path to mcp-command.php to match your installation directory.

{
  "mcpServers": {
    "newspack-lit-mcp": {
      "command": "php",
      "args": [
        "/usr/local/var/www/newspack-ai.test/public/wp-content/plugins/newspack-lit-mcp/mcp-command.php"
      ]
    }
  }
}

Testing Server Availability

There are two ways to test the MCP server:

Option 1: Command-Line MCP Server (Recommended for MCP Clients)

The mcp-command.php script provides a stdio-based MCP server that works with Claude Desktop and other MCP clients.

Test the command-line server:

# Test initialization
echo '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}},"id":1}' | \
php /usr/local/var/www/newspack-ai.test/public/wp-content/plugins/newspack-lit-mcp/mcp-command.php | jq .

# Test tools list
echo '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":2}' | \
php /usr/local/var/www/newspack-ai.test/public/wp-content/plugins/newspack-lit-mcp/mcp-command.php | jq .

# Test writing a file
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"lit-mcp-write-json-file","arguments":{"filename":"test.json","content":{"hello":"world"}}},"id":3}' | \
php /usr/local/var/www/newspack-ai.test/public/wp-content/plugins/newspack-lit-mcp/mcp-command.php | jq .

# Test reading a file
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"lit-mcp-read-json-file","arguments":{"filename":"test.json"}},"id":4}' | \
php /usr/local/var/www/newspack-ai.test/public/wp-content/plugins/newspack-lit-mcp/mcp-command.php | jq .

Multi-request test:

cat > /tmp/test_mcp.txt << 'EOF'
{"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}},"jsonrpc":"2.0","id":0}
{"method":"notifications/initialized","jsonrpc":"2.0"}
{"method":"tools/list","params":{},"jsonrpc":"2.0","id":1}
{"method":"prompts/list","params":{},"jsonrpc":"2.0","id":2}
{"method":"resources/list","params":{},"jsonrpc":"2.0","id":3}
EOF

php /usr/local/var/www/newspack-ai.test/public/wp-content/plugins/newspack-lit-mcp/mcp-command.php < /tmp/test_mcp.txt | jq .

Option 2: Direct HTTP REST API

You can also interact with the MCP server directly via HTTP requests to the WordPress REST API endpoint. This bypasses the command-line server and goes directly to the WordPress REST API endpoint.

Initialize:

curl -k -u admin:pass \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{},"id":1}' \
https://newspack-ai.test/wp-json/lit-mcp/jsonrpc/streamable | \
jq .

List Tools:

curl -k -u admin:pass \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":2}' \
https://newspack-ai.test/wp-json/lit-mcp/jsonrpc/streamable | \
jq .

Write JSON File:

curl -k -u admin:pass \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"lit-mcp-write-json-file","arguments":{"filename":"test.json","content":{"message":"Hello World"}}},"id":3}' \
https://newspack-ai.test/wp-json/lit-mcp/jsonrpc/streamable | \
jq .

Read JSON File:

curl -k -u admin:pass \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"lit-mcp-read-json-file","arguments":{"filename":"test.json"}},"id":4}' \
https://newspack-ai.test/wp-json/lit-mcp/jsonrpc/streamable | \
jq .

Troubleshooting

  • Connection timeouts:

    • Verify WordPress site is running and accessible
    • Check the URL in mcp-command.php matches your site
    • Ensure credentials (username/password) are correct in mcp-command.php
  • "HTTP request failed" errors:

    • Check if WordPress is returning non-200 status codes
    • Verify Basic Auth credentials in mcp-command.php
    • Test the REST API endpoint directly with curl
  • 401 Unauthorized Error:

    • Ensure the WordPress user has edit_posts capability
    • Check that Basic Auth credentials are correct
    • Verify the user exists and password is correct
  • 404 Not Found Error:

    • Ensure the plugin is activated
    • Check that Abilities API and MCP Adapter plugins are active
    • Verify the URL path is correct (/wp-json/lit-mcp/jsonrpc/streamable)
  • 500 Internal Server Error:

    • Check WordPress debug logs for specific error messages
    • Ensure the wp-content/uploads/mcp_data/ directory is writable
    • Verify all dependencies are properly installed

Debug Information

  • Check WordPress debug logs: /wp-content/debug.log
  • Verify plugin activation: wp plugin list
  • Test abilities registration: Check if abilities appear in WordPress admin
  • Test command-line server manually: Use the test commands in the Usage section above
  • Check Claude Desktop logs: ~/Library/Logs/Claude/mcp*.log on macOS

Technical Details

Architecture

  • WordPress Plugin: Registers abilities via Abilities API and exposes them through MCP Adapter
  • Command-Line Wrapper: mcp-command.php is a minimal stdio wrapper that:
    • Reads JSON-RPC messages from stdin (one per line)
    • Forwards them to WordPress REST API via HTTP
    • Returns responses to stdout (one per line)
    • Filters out empty responses from notifications
  • Data Directory: Files are stored in wp-content/uploads/mcp_data/
  • File Format: JSON files with pretty-printing
  • Authentication: Basic HTTP Auth with WordPress user validation
  • Permissions: Requires edit_posts WordPress capability
  • Transport: StreamableTransport (JSON-RPC 2.0 over HTTP with stdio wrapper for MCP clients)

mcp-command.php Implementation

The command wrapper is intentionally minimal:

  • No WordPress bootstrap: Avoids loading WordPress directly to prevent output pollution
  • Clean stdio protocol: Only JSON responses go to stdout, nothing else
  • Error suppression: Disables all PHP errors/warnings/notices to maintain clean output
  • HTTP proxy pattern: Forwards all protocol logic to WordPress REST API
  • Notification handling: Filters out empty responses from JSON-RPC notifications