@automattic/mcp-wordpress-remote

中文文档
0.5.5发布于 2026/11/06MITTypeScriptES Module构建来源已验证近 30 天下载 12.3万

MCP WordPress Remote proxy server

原始使用文档
文档目录38 节
  1. Features
  2. When to use this proxy
  3. Quick Start
  4. Installation
  5. Configuration
  6. Custom Headers
  7. First Run
  8. WordPress MCP Plugin
  9. Forwarding behavior
  10. Authentication Methods
  11. 1. OAuth 2.1 (Recommended)
  12. 2. JWT Token Authentication
  13. 3. WordPress Application Passwords (Legacy)
  14. Advanced Configuration
  15. Custom OAuth Settings
  16. WooCommerce Integration
  17. Environment Variables
  18. Disable OAuth
  19. Development Mode
  20. Setup
  21. Configuration
  22. Development Workflow
  23. Token Management
  24. OAuth Token Storage
  25. Manual Management
  26. Token Security
  27. Multi-Instance Support
  28. Troubleshooting
  29. Authentication Issues
  30. Connection Issues
  31. Port Conflicts
  32. Multi-instance Messages
  33. Log Analysis
  34. Security Features
  35. Requirements
  36. License
  37. Contributing
  38. Support

MCP WordPress Remote

A stdio-to-HTTP pass-through proxy for WordPress MCP servers

Connect AI assistants like Claude Desktop to your WordPress sites with multiple authentication methods including OAuth 2.0, JWT tokens, and application passwords.

Features

  • MCP OAuth Client - Authorization-code PKCE, validated discovery, issuer-bound credentials, and coordinated renewal
  • OAuth 2.1 with PKCE - Secure authorization code flow with PKCE (RFC 7636)
  • Resource Indicators - RFC 8707 compliance for token audience binding
  • Dynamic Client Registration - RFC 7591 support for automatic client registration
  • Protected Resource Metadata Discovery - RFC 9728 for automatic endpoint discovery
  • Multiple Authentication Methods - OAuth 2.1, JWT tokens, and WordPress application passwords
  • Persistent Token Storage - OAuth tokens stored securely with automatic validation
  • Multi-instance Coordination - Lockfiles prevent authentication conflicts
  • Automatic Token Management - Handles validation, refresh, and cleanup
  • Enhanced Error Handling - Detailed error messages with proper categorization
  • Comprehensive Logging - Structured logging with categories and levels
  • Complete MCP Support - Tools, resources, prompts, and more

When to use this proxy

If your MCP client supports the Streamable HTTP transport and can authenticate to your site, connect it to the MCP Adapter endpoint directly. You don't need this proxy. For example, in Claude Code (.mcp.json), using an application password:

{
  "mcpServers": {
    "wordpress": {
      "type": "http",
      "url": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
      "headers": {
        "Authorization": "Basic <base64 of username:application-password>"
      }
    }
  }
}

Other clients use their own config format. Check your client's documentation for remote or HTTP MCP servers.

Use the proxy when one of these applies:

  1. Your client only supports stdio. It can launch a local command but cannot connect to an HTTP MCP server.
  2. Your client can't authenticate the way your site requires. The proxy can send application passwords, JWT tokens, WooCommerce keys, or custom headers, and it can run the OAuth flow and store tokens for clients that can't.
  3. Your traffic must go through a proxy. Set SOCKS_PROXY, HTTPS_PROXY, ALL_PROXY or HTTP_PROXY to route requests through it. On macOS, set USE_SYSTEM_PROXY=true to use the system PAC file or SOCKS proxy instead.
  4. Your site is slow or unreliable. WP_API_TIMEOUT_MS and WP_API_INIT_TIMEOUT_MS set the timeouts, and a failed initialize returns a degraded response instead of a broken connection (see Forwarding behavior).
  5. You need a local record of the connection. LOG_FILE with LOG_LEVEL=3 logs each forwarded method plus connection and authentication events (see Log Analysis).
  6. You are building a packaged integration. Tool-call hooks from the /lib bundle can send extra requests over the proxy's authenticated connection, for example for usage telemetry.

Quick Start

Installation

npm install @automattic/mcp-wordpress-remote

Configuration

Add to your MCP client configuration (e.g., Claude Desktop's claude_desktop_config.json):

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@automattic/mcp-wordpress-remote"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server"
      }
    }
  }
}

Custom Headers

You can add custom headers to all API requests using the CUSTOM_HEADERS environment variable. This is useful for API keys, custom authentication, or other header requirements.

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@automattic/mcp-wordpress-remote"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
        "CUSTOM_HEADERS": "{\"X-MCP-API-Key\": \"*Ibo7tweixlbfuwaiufxgakjyefctwajcetb*\", \"X-Custom-Header\": \"value\"}"
      }
    }
  }
}

Comma-Separated Format:

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@automattic/mcp-wordpress-remote"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
        "CUSTOM_HEADERS": "X-MCP-API-Key:IOskncfyes78U8on3q7ry43o487tybrc,X-Custom-Header:value"
      }
    }
  }
}

Command Line Usage:

CUSTOM_HEADERS='{"X-MCP-API-Key": "wc_mcp_FaQduhQcW0mfVaZgP3yaaqDuXaZ3mw7j"}' \
WP_API_URL="https://your-site.com/wp-json/mcp/mcp-adapter-default-server" \
npx @automattic/mcp-wordpress-remote

Custom headers are included in:

  • All WordPress API requests
  • OAuth discovery requests
  • OAuth token exchange requests
  • OAuth client registration requests

First Run

  1. Start your MCP client (Claude Desktop, etc.)
  2. Choose authentication method based on your preference:
    • OAuth 2.0: Enable OAUTH_ENABLED=true to open the browser for authorization
    • JWT Token: Set JWT_TOKEN environment variable
    • Application Password: Set WP_API_USERNAME and WP_API_PASSWORD
  3. Start using WordPress features in your AI assistant

WordPress MCP Plugin

Install the MCP Adapter plugin on your WordPress site. Once active, it registers a default MCP server at /wp-json/mcp/mcp-adapter-default-server — set WP_API_URL to that full URL (examples throughout this README show the pattern). To target a custom server id or namespace, pass the full URL of that server instead.

Forwarding behavior

The proxy forwards the MCP client's messages to the configured endpoint and returns the server's messages. It does not send its own initialization probe, select an MCP version, or register a fixed set of methods. The client and server own version negotiation, capabilities, and result validation. Requests, notifications, server requests, IDs, and metadata travel through the bridge; JSON and SSE responses are supported.

For initialization-based MCP connections, the server's selected version and session ID are used in subsequent HTTP headers. Requests carrying io.modelcontextprotocol/protocolVersion in params._meta use that version directly and do not require a proxy-generated handshake. This removes the proxy's version allowlist; it does not translate between protocol revisions or establish full compliance with every newer transport feature.

Existing authentication, custom headers, timeout, logging, token-storage, and system-proxy settings remain available. A bare-domain WP_API_URL now resolves to /?rest_route=/mcp/mcp-adapter-default-server. Full endpoint URLs remain configurable. The archived wordpress-mcp plugin's method-only request format and automatic transport fallback have been removed.

If the upstream connection fails during initialization, the proxy retains its degraded response with experimental.connectionFailed and no usable capabilities, using the client's offered version. Follow-up requests are rejected locally. Server-generated JSON-RPC errors are forwarded rather than converted to a successful handshake. The proxy does not silently reinitialize or retry failed client requests.

Tool-call hooks and wpRequest from the /lib bundle share the live authenticated connection when the proxy is running. Hook responses remain internal and hook failures cannot change the client response. Standalone wpRequest retains its result-returning interface and optional session recovery; both its existing argument shapes are encoded as standard JSON-RPC.

Authentication Methods

OAuth 2.1 uses a public native client with PKCE S256, validated MCP discovery, and coordinated token renewal. See OAuth client behavior for the supported profile, migration behavior, and optional features.

For Self-Hosted WordPress Sites:

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@automattic/mcp-wordpress-remote"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
        "OAUTH_ENABLED": "true"
      }
    }
  }
}

MCP Authorization Specification Features:

  • OAuth 2.1 authorization code flow with PKCE (RFC 7636)
  • Resource Indicators (RFC 8707) for token audience binding
  • Dynamic Client Registration (RFC 7591) when supported
  • Protected Resource Metadata Discovery (RFC 9728)
  • Authorization Server Metadata Discovery (RFC 8414)

Benefits:

  • Public native-client authorization following the MCP 2026-07-28 authorization requirements
  • Enhanced security with PKCE protection
  • Shared browser authorization and refresh-token renewal when supported
  • Tokens stored securely with automatic validation
  • Automatic endpoint discovery
  • No need to manage passwords
  • Automatic expiration handling

2. JWT Token Authentication

For server-to-server authentication or when OAuth is not available.

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@automattic/mcp-wordpress-remote"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
        "JWT_TOKEN": "your-jwt-token-here"
      }
    }
  }
}

3. WordPress Application Passwords (Legacy)

Uses WordPress username and application password for basic authentication.

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@automattic/mcp-wordpress-remote"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
        "WP_API_USERNAME": "your-username",
        "WP_API_PASSWORD": "your-application-password",
        "OAUTH_ENABLED": "false"
      }
    }
  }
}

To create an application password:

  1. Go to your WordPress admin dashboard
  2. Navigate to Users > Profile
  3. Scroll down to "Application Passwords"
  4. Create a new application password for MCP access

Advanced Configuration

Custom OAuth Settings

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@automattic/mcp-wordpress-remote"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
        "OAUTH_CALLBACK_PORT": "7665",
        "OAUTH_HOST": "127.0.0.1",
        "WP_OAUTH_CLIENT_ID": "your-custom-client-id"
      }
    }
  }
}

WooCommerce Integration

For WooCommerce-specific tools and reports:

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@automattic/mcp-wordpress-remote"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
        "WOO_CUSTOMER_KEY": "ck_your-consumer-key",
        "WOO_CUSTOMER_SECRET": "cs_your-consumer-secret"
      }
    }
  }
}

Environment Variables

VariableDescriptionDefaultRequired
WP_API_URLWordPress site URL including the MCP endpoint path (e.g. …/wp-json/mcp/mcp-adapter-default-server). A bare domain resolves to the MCP Adapter default server.-✅
OAUTH_ENABLEDEnable OAuth authenticationfalse-
OAUTH_CALLBACK_PORTOAuth callback port7665-
OAUTH_HOSTOAuth callback hostname127.0.0.1-
OAUTH_TIMEOUT_MSTime to wait for the browser OAuth login (ms)30000-
WP_OAUTH_CLIENT_IDCustom OAuth client ID--
OAuth Endpoints
OAUTH_AUTHORIZE_ENDPOINTOAuth authorization endpoint-✅ (for custom OAuth)
OAUTH_TOKEN_ENDPOINTOAuth token endpoint-✅ (for custom OAuth)
OAUTH_AUTHENTICATE_ENDPOINTOAuth authenticate endpoint--
MCP OAuth 2.1 Settings
OAUTH_FLOW_TYPEOAuth flow type (authorization_code or implicit)authorization_code-
OAUTH_USE_PKCEUse PKCE (required for OAuth 2.1)true-
OAUTH_DYNAMIC_REGISTRATIONEnable dynamic client registrationtrue-
OAUTH_RESOURCE_INDICATORUse resource indicators (RFC 8707)true-
Configuration
WP_MCP_CONFIG_DIRConfig directory override~/.mcp-auth-
LOG_FILELog file path--
LOG_LEVELLog level (0-3)2-
LOG_TO_STDERRMirror all log levels to stderr (errors always are)false-
WP_API_TIMEOUT_MSRequest timeout for tool calls (ms)120000-
WP_API_INIT_TIMEOUT_MSInitialize timeout (ms), after OAuth login25000-
PROXY_PAC_TIMEOUT_MSTimeout for PAC download and resolver setup (ms)5000-
Network Proxy
SOCKS_PROXYSOCKS proxy URL (socks5h:// resolves DNS on the proxy)--
HTTPS_PROXYHTTP(S) proxy URL, used when SOCKS_PROXY is unset--
ALL_PROXYProxy URL, used when the above are unset--
HTTP_PROXYProxy URL, used when the above are unset--
NO_PROXYComma-separated hosts that bypass the proxy--
USE_SYSTEM_PROXYAlso detect the macOS system PAC file or SOCKS proxy when no proxy URL is setfalse-
TLS / Certificates
NODE_EXTRA_CA_CERTSPath to an extra CA file to trust (mkcert/corporate CA)--
NODE_USE_SYSTEM_CATrust the OS certificate store (Node 22.15+)--
Legacy Authentication
JWT_TOKENJWT token for authentication--
WP_API_USERNAMEWordPress username (legacy)--
WP_API_PASSWORDWordPress app password (legacy)--
WOO_CUSTOMER_KEYWooCommerce consumer key--
WOO_CUSTOMER_SECRETWooCommerce consumer secret--

Disable OAuth

To use only JWT or Basic Auth:

{
  "env": {
    "OAUTH_ENABLED": "false",
    "JWT_TOKEN": "your-jwt-token"
  }
}

Development Mode

For development and testing, you can use the local repository:

Setup

  1. Clone the repository:

    git clone https://github.com/Automattic/mcp-wordpress-remote.git
    cd mcp-wordpress-remote
    
  2. Install dependencies:

    npm install
    
  3. Build the project:

    npm run build
    

Configuration

Configure your MCP client to use the local version:

{
  "mcpServers": {
    "wordpress": {
      "command": "node",
      "args": ["/path/to/your/mcp-wordpress-remote/dist/proxy.js"],
      "env": {
        "WP_API_URL": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server"
      }
    }
  }
}

Development Workflow

  • Watch mode: npm run build:watch - Automatically rebuilds on file changes
  • Testing: npm test - Run the test suite
  • Type checking: npm run check - Run TypeScript and Prettier checks

Token Management

OAuth Token Storage

Tokens are automatically stored in:

~/.mcp-auth/wordpress-remote-{version}/

Manual Management

# View stored tokens
ls -la ~/.mcp-auth/wordpress-remote-*/

# Clear all tokens (forces re-authentication)
rm -rf ~/.mcp-auth/wordpress-remote-*/

# Clear tokens for specific version
rm -rf ~/.mcp-auth/wordpress-remote-0.2.1/

Token Security

  • Secure file permissions (600) on all token files
  • Automatic token validation before each request
  • Expired token cleanup during startup
  • Version isolation - each version stores tokens separately

Multi-Instance Support

The proxy automatically coordinates between multiple instances:

  • Lockfiles prevent simultaneous OAuth flows
  • Process coordination ensures only one authentication at a time
  • Graceful waiting when another instance is authenticating
  • Automatic cleanup of stale locks

If you see "waiting for other instance" messages, this is normal behavior.

Troubleshooting

Authentication Issues

OAuth browser doesn't open:

  • Check if port 3000 is available
  • Try a different port with OAUTH_CALLBACK_PORT
  • Manually open the URL shown in logs

OAuth authorization fails:

  • Verify WordPress site has MCP plugin installed and enabled
  • Check WordPress admin user permissions
  • Try clearing tokens and re-authenticating

JWT authentication fails:

  • Verify JWT token is valid and not expired
  • Check token format and encoding
  • Ensure WordPress site supports JWT authentication

Basic Auth fails:

  • Verify username and application password
  • Check application password is active
  • Ensure user has sufficient permissions

Connection Issues

API endpoint not found:

  • Verify the MCP Adapter plugin is installed and active
  • Confirm WP_API_URL points at the server route (e.g. …/wp-json/mcp/mcp-adapter-default-server)

Permission denied:

  • Check user permissions in WordPress
  • Verify authentication credentials
  • Review WordPress user roles

Port Conflicts

If port 3000 is already in use:

{
  "env": {
    "OAUTH_CALLBACK_PORT": "8080"
  }
}

Multi-instance Messages

"Waiting for other instance" messages are normal when multiple MCP clients start simultaneously. The system coordinates authentication to prevent conflicts.

Log Analysis

Enable detailed logging:

{
  "env": {
    "LOG_LEVEL": "3",
    "LOG_FILE": "/path/to/logfile.log"
  }
}

Log levels:

  • 0 - Errors only
  • 1 - Warnings and errors
  • 2 - Info, warnings, and errors (default)
  • 3 - Debug, info, warnings, and errors

Security Features

  • Secure OAuth flow with state parameters and PKCE
  • Token encryption with secure file permissions
  • Automatic validation before each API request
  • Expired token cleanup and refresh handling
  • Multi-instance coordination prevents authentication conflicts

Requirements

  • Node.js 22+ (required for fetch API support)
  • WordPress site with the MCP Adapter plugin installed and active
  • WordPress user account with appropriate permissions

License

GPL v2 or later

Contributing

Contributions welcome! This project is maintained by Automattic Inc.

Support


Need help? Check the troubleshooting section or open an issue.

版本与发布记录

@automattic/mcp-wordpress-remote 共发布 42 个版本,首次发布于 2025/04/30;过去 12 个月发布了 15 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.5latest2026/11/062 天前
0.5.42026/10/2018 天前
0.5.32026/10/2018 天前
0.5.22026/10/2019 天前
0.5.12026/10/071 个月前
0.5.02026/10/071 个月前

其他发布通道:canary → 0.2.21。

关于 @automattic/mcp-wordpress-remote 的常见问题

@automattic/mcp-wordpress-remote 是什么?

MCP WordPress Remote proxy server

如何安装 @automattic/mcp-wordpress-remote?

在项目目录运行 npm install @automattic/mcp-wordpress-remote,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mcp-wordpress-remote,可以用 npx mcp-wordpress-remote 直接运行。

@automattic/mcp-wordpress-remote 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@automattic/mcp-wordpress-remote 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@automattic/mcp-wordpress-remote 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@automattic/mcp-wordpress-remote 可以商用吗?

@automattic/mcp-wordpress-remote 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@automattic/mcp-wordpress-remote 的下载量有多少?

根据 npm 官方下载统计,@automattic/mcp-wordpress-remote 在 2026/10/07 – 2026/11/05 这 30 天内被下载 122,667 次,日均约 4,089 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@automattic/mcp-wordpress-remote 还在维护吗?

最新版本 0.5.5 发布于 2026/11/06(2 天前);至今共发布 42 个版本,其中过去 12 个月发布了 15 个;首次发布于 2025/04/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。