@automattic/mcp-wordpress-remote 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -16
- package/dist/lib.d.ts +17 -29
- package/dist/lib.js +36556 -8066
- package/dist/proxy.js +46482 -25850
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MCP WordPress Remote
|
|
2
2
|
|
|
3
|
-
**A
|
|
3
|
+
**A stdio-to-HTTP pass-through proxy for WordPress MCP servers**
|
|
4
4
|
|
|
5
5
|
Connect AI assistants like Claude Desktop to your WordPress sites with multiple authentication methods including OAuth 2.0, JWT tokens, and application passwords.
|
|
6
6
|
|
|
@@ -19,6 +19,35 @@ Connect AI assistants like Claude Desktop to your WordPress sites with multiple
|
|
|
19
19
|
- **Comprehensive Logging** - Structured logging with categories and levels
|
|
20
20
|
- **Complete MCP Support** - Tools, resources, prompts, and more
|
|
21
21
|
|
|
22
|
+
## When to use this proxy
|
|
23
|
+
|
|
24
|
+
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:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"wordpress": {
|
|
30
|
+
"type": "http",
|
|
31
|
+
"url": "https://your-wordpress-site.com/wp-json/mcp/mcp-adapter-default-server",
|
|
32
|
+
"headers": {
|
|
33
|
+
"Authorization": "Basic <base64 of username:application-password>"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Other clients use their own config format. Check your client's documentation for remote or HTTP MCP servers.
|
|
41
|
+
|
|
42
|
+
Use the proxy when one of these applies:
|
|
43
|
+
|
|
44
|
+
1. **Your client only supports stdio.** It can launch a local command but cannot connect to an HTTP MCP server.
|
|
45
|
+
2. **Your client can't authenticate the way your site requires.** The proxy can send application passwords, JWT tokens, WooCommerce keys, or [custom headers](#custom-headers), and it can run the [OAuth flow](#authentication-methods) and store tokens for clients that can't.
|
|
46
|
+
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.
|
|
47
|
+
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](#forwarding-behavior)).
|
|
48
|
+
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](#log-analysis)).
|
|
49
|
+
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.
|
|
50
|
+
|
|
22
51
|
## Quick Start
|
|
23
52
|
|
|
24
53
|
### Installation
|
|
@@ -102,7 +131,7 @@ Custom headers are included in:
|
|
|
102
131
|
|
|
103
132
|
1. **Start your MCP client** (Claude Desktop, etc.)
|
|
104
133
|
2. **Choose authentication method** based on your preference:
|
|
105
|
-
- **OAuth 2.0
|
|
134
|
+
- **OAuth 2.0**: Enable `OAUTH_ENABLED=true` to open the browser for authorization
|
|
106
135
|
- **JWT Token**: Set `JWT_TOKEN` environment variable
|
|
107
136
|
- **Application Password**: Set `WP_API_USERNAME` and `WP_API_PASSWORD`
|
|
108
137
|
3. **Start using WordPress features** in your AI assistant
|
|
@@ -111,9 +140,17 @@ Custom headers are included in:
|
|
|
111
140
|
|
|
112
141
|
Install the [MCP Adapter](https://github.com/WordPress/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.
|
|
113
142
|
|
|
114
|
-
###
|
|
143
|
+
### Forwarding behavior
|
|
144
|
+
|
|
145
|
+
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.
|
|
115
146
|
|
|
116
|
-
|
|
147
|
+
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.
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
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.
|
|
117
154
|
|
|
118
155
|
## Authentication Methods
|
|
119
156
|
|
|
@@ -248,10 +285,11 @@ For WooCommerce-specific tools and reports:
|
|
|
248
285
|
|
|
249
286
|
| Variable | Description | Default | Required |
|
|
250
287
|
| ----------------------------- | ------------------------------------------------ | -------------------- | --------------------- |
|
|
251
|
-
| `WP_API_URL` | WordPress site URL including the MCP endpoint path (e.g. `…/wp-json/mcp/mcp-adapter-default-server`). A bare domain resolves to the
|
|
252
|
-
| `OAUTH_ENABLED` | Enable OAuth authentication | `
|
|
288
|
+
| `WP_API_URL` | WordPress 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. | - | ✅ |
|
|
289
|
+
| `OAUTH_ENABLED` | Enable OAuth authentication | `false` | - |
|
|
253
290
|
| `OAUTH_CALLBACK_PORT` | OAuth callback port | `7665` | - |
|
|
254
291
|
| `OAUTH_HOST` | OAuth callback hostname | `127.0.0.1` | - |
|
|
292
|
+
| `OAUTH_TIMEOUT_MS` | Time to wait for the browser OAuth login (ms) | `30000` | - |
|
|
255
293
|
| `WP_OAUTH_CLIENT_ID` | Custom OAuth client ID | - | - |
|
|
256
294
|
| **OAuth Endpoints** | | | |
|
|
257
295
|
| `OAUTH_AUTHORIZE_ENDPOINT` | OAuth authorization endpoint | - | ✅ (for custom OAuth) |
|
|
@@ -268,7 +306,15 @@ For WooCommerce-specific tools and reports:
|
|
|
268
306
|
| `LOG_LEVEL` | Log level (0-3) | `2` | - |
|
|
269
307
|
| `LOG_TO_STDERR` | Mirror all log levels to stderr (errors always are) | `false` | - |
|
|
270
308
|
| `WP_API_TIMEOUT_MS` | Request timeout for tool calls (ms) | `120000` | - |
|
|
271
|
-
| `WP_API_INIT_TIMEOUT_MS` |
|
|
309
|
+
| `WP_API_INIT_TIMEOUT_MS` | Initialize timeout (ms), after OAuth login | `25000` | - |
|
|
310
|
+
| `PROXY_PAC_TIMEOUT_MS` | Timeout for PAC download and resolver setup (ms) | `5000` | - |
|
|
311
|
+
| **Network Proxy** | | | |
|
|
312
|
+
| `SOCKS_PROXY` | SOCKS proxy URL (`socks5h://` resolves DNS on the proxy) | - | - |
|
|
313
|
+
| `HTTPS_PROXY` | HTTP(S) proxy URL, used when `SOCKS_PROXY` is unset | - | - |
|
|
314
|
+
| `ALL_PROXY` | Proxy URL, used when the above are unset | - | - |
|
|
315
|
+
| `HTTP_PROXY` | Proxy URL, used when the above are unset | - | - |
|
|
316
|
+
| `NO_PROXY` | Comma-separated hosts that bypass the proxy | - | - |
|
|
317
|
+
| `USE_SYSTEM_PROXY` | Also detect the macOS system PAC file or SOCKS proxy when no proxy URL is set | `false` | - |
|
|
272
318
|
| **TLS / Certificates** | | | |
|
|
273
319
|
| `NODE_EXTRA_CA_CERTS` | Path to an extra CA file to trust (mkcert/corporate CA) | - | - |
|
|
274
320
|
| `NODE_USE_SYSTEM_CA` | Trust the OS certificate store (Node 22.15+) | - | - |
|
|
@@ -466,15 +512,6 @@ Log levels:
|
|
|
466
512
|
- **Expired token cleanup** and refresh handling
|
|
467
513
|
- **Multi-instance coordination** prevents authentication conflicts
|
|
468
514
|
|
|
469
|
-
## Why Use MCP WordPress Remote?
|
|
470
|
-
|
|
471
|
-
1. **Multiple Authentication Methods** - Choose what works best for your setup
|
|
472
|
-
2. **Enhanced Security** - OAuth 2.0 with persistent token storage
|
|
473
|
-
3. **Better User Experience** - One-time setup with automatic token management
|
|
474
|
-
4. **Multi-Instance Support** - Works reliably with multiple MCP clients
|
|
475
|
-
5. **Comprehensive Logging** - Detailed logs for troubleshooting
|
|
476
|
-
6. **Easy Setup** - No global installation required with npx
|
|
477
|
-
|
|
478
515
|
## Requirements
|
|
479
516
|
|
|
480
517
|
- **Node.js 22+** (required for fetch API support)
|
package/dist/lib.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ interface WordPressResponse {
|
|
|
15
15
|
[key: string]: any;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
declare const MCP_WORDPRESS_REMOTE_VERSION = "0.
|
|
18
|
+
declare const MCP_WORDPRESS_REMOTE_VERSION = "0.5.1";
|
|
19
19
|
/**
|
|
20
20
|
* Centralized configuration for MCP WordPress Remote
|
|
21
21
|
* All default values are defined here and can be overridden via environment variables
|
|
@@ -34,7 +34,7 @@ declare const CONFIG: {
|
|
|
34
34
|
readonly OAUTH_AUTHENTICATE_ENDPOINT: string;
|
|
35
35
|
readonly OAUTH_RESOURCE_INDICATOR: boolean;
|
|
36
36
|
readonly OAUTH_SCOPES: string;
|
|
37
|
-
readonly OAUTH_TIMEOUT:
|
|
37
|
+
readonly OAUTH_TIMEOUT: number;
|
|
38
38
|
readonly LOCK_TIMEOUT: 300000;
|
|
39
39
|
readonly WP_API_TIMEOUT: number;
|
|
40
40
|
readonly WP_API_INIT_TIMEOUT: number;
|
|
@@ -74,7 +74,7 @@ declare const getConfig: () => {
|
|
|
74
74
|
/** Custom OAuth scopes (comma-separated) */
|
|
75
75
|
oauthScopes: string;
|
|
76
76
|
/** OAuth operation timeout in milliseconds */
|
|
77
|
-
oauthTimeout:
|
|
77
|
+
oauthTimeout: number;
|
|
78
78
|
/** Lock operation timeout in milliseconds */
|
|
79
79
|
lockTimeout: 300000;
|
|
80
80
|
/** WordPress request timeout in milliseconds (tool calls and non-init requests) */
|
|
@@ -155,6 +155,12 @@ declare const logger: {
|
|
|
155
155
|
config: (message: string, level?: LogLevel, ...args: any[]) => void;
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Send one request to WordPress. While the proxy is running, the request rides its live
|
|
160
|
+
* connection, and session recovery is left to the connected client.
|
|
161
|
+
*
|
|
162
|
+
* @param useJsonRpc Deprecated and ignored; requests are always sent as JSON-RPC.
|
|
163
|
+
*/
|
|
158
164
|
declare function wpRequest(requestData: any, useJsonRpc?: boolean, options?: {
|
|
159
165
|
allowSessionRecovery?: boolean;
|
|
160
166
|
}): Promise<WordPressResponse>;
|
|
@@ -235,12 +241,6 @@ declare function isConfigError(error: any): error is ConfigError;
|
|
|
235
241
|
declare function isAuthError(error: any): error is AuthError;
|
|
236
242
|
declare function isAPIError(error: any): error is APIError;
|
|
237
243
|
|
|
238
|
-
/**
|
|
239
|
-
* Fetch API utilities for MCP WordPress Remote
|
|
240
|
-
*
|
|
241
|
-
* Provides fetch polyfill setup for Node.js environments that don't have native fetch
|
|
242
|
-
* and proxy-aware fetch for routing through system proxies (PAC files, env-based SOCKS/HTTP proxies)
|
|
243
|
-
*/
|
|
244
244
|
/**
|
|
245
245
|
* Setup fetch polyfill for Node.js 18+ compatibility
|
|
246
246
|
*
|
|
@@ -252,9 +252,9 @@ declare function setupFetchPolyfill(): Promise<void>;
|
|
|
252
252
|
/**
|
|
253
253
|
* Proxy-aware fetch that routes requests through system proxies when configured
|
|
254
254
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* Falls back to direct connection if no proxy is configured or
|
|
255
|
+
* Uses SOCKS_PROXY, HTTPS_PROXY, ALL_PROXY or HTTP_PROXY when set
|
|
256
|
+
* With USE_SYSTEM_PROXY=true on macOS: Evaluates the system PAC file or SOCKS proxy
|
|
257
|
+
* Falls back to direct connection if no proxy is configured or NO_PROXY matches
|
|
258
258
|
*
|
|
259
259
|
* @param url - The URL to fetch
|
|
260
260
|
* @param init - Optional fetch init options
|
|
@@ -289,9 +289,9 @@ declare function getFetchInfo(): {
|
|
|
289
289
|
* Cross-platform proxy utilities for MCP WordPress Remote
|
|
290
290
|
*
|
|
291
291
|
* Supports:
|
|
292
|
-
* -
|
|
293
|
-
* - macOS
|
|
294
|
-
* -
|
|
292
|
+
* - All platforms: Environment variables (SOCKS_PROXY, HTTPS_PROXY, etc.), always
|
|
293
|
+
* - macOS, with USE_SYSTEM_PROXY=true: PAC file from system proxy settings
|
|
294
|
+
* - macOS, with USE_SYSTEM_PROXY=true: System SOCKS proxy ("tunnel all traffic")
|
|
295
295
|
*/
|
|
296
296
|
|
|
297
297
|
type ProxyAgent = SocksProxyAgent | HttpsProxyAgent<string>;
|
|
@@ -327,17 +327,6 @@ declare function isProxyConfigured(): boolean;
|
|
|
327
327
|
*/
|
|
328
328
|
declare function getProxyType(): 'pac' | 'env' | 'none';
|
|
329
329
|
|
|
330
|
-
/**
|
|
331
|
-
* MCP Request Types for WordPress Remote Proxy
|
|
332
|
-
*
|
|
333
|
-
* Type definitions for all MCP JSON-RPC request schemas
|
|
334
|
-
*/
|
|
335
|
-
|
|
336
|
-
interface WPRequestParams {
|
|
337
|
-
method: string;
|
|
338
|
-
[key: string]: unknown;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
330
|
/**
|
|
342
331
|
* Tool-call hooks for MCP WordPress Remote.
|
|
343
332
|
*
|
|
@@ -356,11 +345,10 @@ interface ToolCallContext {
|
|
|
356
345
|
name: string;
|
|
357
346
|
/**
|
|
358
347
|
* Dispatch an additional request over the proxy's live, authenticated
|
|
359
|
-
* session. The request is prepared
|
|
360
|
-
* (JSON-RPC envelope or simple format) before it is sent, e.g.
|
|
348
|
+
* session. The request is prepared as JSON-RPC before it is sent, e.g.
|
|
361
349
|
* `wpRequest({ method: 'tools/call', name, arguments })`.
|
|
362
350
|
*/
|
|
363
|
-
wpRequest: (params:
|
|
351
|
+
wpRequest: (params: WordPressRequestParams) => Promise<WordPressResponse>;
|
|
364
352
|
}
|
|
365
353
|
/** A hook fired after each completed `tools/call`. May be async. */
|
|
366
354
|
type ToolCallHook = (context: ToolCallContext) => void | Promise<void>;
|