@automattic/mcp-wordpress-remote 0.5.0 → 0.5.2
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 +36 -9
- package/dist/lib.d.ts +7 -7
- package/dist/lib.js +47 -18
- package/dist/proxy.js +393 -209
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
|
@@ -279,6 +308,13 @@ For WooCommerce-specific tools and reports:
|
|
|
279
308
|
| `WP_API_TIMEOUT_MS` | Request timeout for tool calls (ms) | `120000` | - |
|
|
280
309
|
| `WP_API_INIT_TIMEOUT_MS` | Initialize timeout (ms), after OAuth login | `25000` | - |
|
|
281
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` | - |
|
|
282
318
|
| **TLS / Certificates** | | | |
|
|
283
319
|
| `NODE_EXTRA_CA_CERTS` | Path to an extra CA file to trust (mkcert/corporate CA) | - | - |
|
|
284
320
|
| `NODE_USE_SYSTEM_CA` | Trust the OS certificate store (Node 22.15+) | - | - |
|
|
@@ -476,15 +512,6 @@ Log levels:
|
|
|
476
512
|
- **Expired token cleanup** and refresh handling
|
|
477
513
|
- **Multi-instance coordination** prevents authentication conflicts
|
|
478
514
|
|
|
479
|
-
## Why Use MCP WordPress Remote?
|
|
480
|
-
|
|
481
|
-
1. **Multiple Authentication Methods** - Choose what works best for your setup
|
|
482
|
-
2. **Enhanced Security** - OAuth 2.0 with persistent token storage
|
|
483
|
-
3. **Better User Experience** - One-time setup with automatic token management
|
|
484
|
-
4. **Multi-Instance Support** - Works reliably with multiple MCP clients
|
|
485
|
-
5. **Comprehensive Logging** - Detailed logs for troubleshooting
|
|
486
|
-
6. **Easy Setup** - No global installation required with npx
|
|
487
|
-
|
|
488
515
|
## Requirements
|
|
489
516
|
|
|
490
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.5.
|
|
18
|
+
declare const MCP_WORDPRESS_REMOTE_VERSION = "0.5.2";
|
|
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
|
|
@@ -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>;
|
package/dist/lib.js
CHANGED
|
@@ -73824,10 +73824,9 @@ var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
|
73824
73824
|
var CursorSchema = string2();
|
|
73825
73825
|
var TaskCreationParamsSchema = looseObject({
|
|
73826
73826
|
/**
|
|
73827
|
-
*
|
|
73828
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
73827
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
73829
73828
|
*/
|
|
73830
|
-
ttl:
|
|
73829
|
+
ttl: number2().optional(),
|
|
73831
73830
|
/**
|
|
73832
73831
|
* Time in milliseconds to wait between task status requests.
|
|
73833
73832
|
*/
|
|
@@ -74122,7 +74121,11 @@ var ClientCapabilitiesSchema = object({
|
|
|
74122
74121
|
/**
|
|
74123
74122
|
* Present if the client supports task creation.
|
|
74124
74123
|
*/
|
|
74125
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
74124
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
74125
|
+
/**
|
|
74126
|
+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
74127
|
+
*/
|
|
74128
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
74126
74129
|
});
|
|
74127
74130
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
74128
74131
|
/**
|
|
@@ -74183,7 +74186,11 @@ var ServerCapabilitiesSchema = object({
|
|
|
74183
74186
|
/**
|
|
74184
74187
|
* Present if the server supports task creation.
|
|
74185
74188
|
*/
|
|
74186
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
74189
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
74190
|
+
/**
|
|
74191
|
+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
74192
|
+
*/
|
|
74193
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
74187
74194
|
});
|
|
74188
74195
|
var InitializeResultSchema = ResultSchema.extend({
|
|
74189
74196
|
/**
|
|
@@ -74375,6 +74382,12 @@ var ResourceSchema = object({
|
|
|
74375
74382
|
* The MIME type of this resource, if known.
|
|
74376
74383
|
*/
|
|
74377
74384
|
mimeType: optional(string2()),
|
|
74385
|
+
/**
|
|
74386
|
+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
74387
|
+
*
|
|
74388
|
+
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
74389
|
+
*/
|
|
74390
|
+
size: optional(number2()),
|
|
74378
74391
|
/**
|
|
74379
74392
|
* Optional annotations for the client.
|
|
74380
74393
|
*/
|
|
@@ -75393,7 +75406,12 @@ var OAuthTokensSchema = object({
|
|
|
75393
75406
|
token_type: string2(),
|
|
75394
75407
|
expires_in: coerce_exports.number().optional(),
|
|
75395
75408
|
scope: string2().optional(),
|
|
75396
|
-
refresh_token: string2().optional()
|
|
75409
|
+
refresh_token: string2().optional(),
|
|
75410
|
+
/**
|
|
75411
|
+
* Not part of the wire format: the authorization server this value was obtained from, added by
|
|
75412
|
+
* the client's `auth()` before it is stored and compared when it is read back.
|
|
75413
|
+
*/
|
|
75414
|
+
issuer: string2().optional().catch(void 0)
|
|
75397
75415
|
}).strip();
|
|
75398
75416
|
var OAuthErrorResponseSchema = object({
|
|
75399
75417
|
error: string2(),
|
|
@@ -75423,7 +75441,12 @@ var OAuthClientInformationSchema = object({
|
|
|
75423
75441
|
client_id: string2(),
|
|
75424
75442
|
client_secret: string2().optional(),
|
|
75425
75443
|
client_id_issued_at: number2().optional(),
|
|
75426
|
-
client_secret_expires_at: number2().optional()
|
|
75444
|
+
client_secret_expires_at: number2().optional(),
|
|
75445
|
+
/**
|
|
75446
|
+
* Not part of the wire format: the authorization server this value was obtained from, added by
|
|
75447
|
+
* the client's `auth()` before it is stored and compared when it is read back.
|
|
75448
|
+
*/
|
|
75449
|
+
issuer: string2().optional().catch(void 0)
|
|
75427
75450
|
}).strip();
|
|
75428
75451
|
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
75429
75452
|
var OAuthClientRegistrationErrorSchema = object({
|
|
@@ -75530,6 +75553,10 @@ var OAUTH_ERRORS = {
|
|
|
75530
75553
|
[InvalidTargetError.errorCode]: InvalidTargetError
|
|
75531
75554
|
};
|
|
75532
75555
|
|
|
75556
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js
|
|
75557
|
+
var TokenResponseSchema = OAuthTokensSchema.omit({ issuer: true });
|
|
75558
|
+
var RegistrationResponseSchema = OAuthClientInformationFullSchema.omit({ issuer: true });
|
|
75559
|
+
|
|
75533
75560
|
// src/lib/utils.ts
|
|
75534
75561
|
import * as fs2 from "node:fs";
|
|
75535
75562
|
import * as path3 from "node:path";
|
|
@@ -75774,7 +75801,7 @@ async function selectCallbackPort(serverUrl, specifiedPort, _unused) {
|
|
|
75774
75801
|
}
|
|
75775
75802
|
|
|
75776
75803
|
// src/lib/config.ts
|
|
75777
|
-
var MCP_WORDPRESS_REMOTE_VERSION = "0.5.
|
|
75804
|
+
var MCP_WORDPRESS_REMOTE_VERSION = "0.5.2";
|
|
75778
75805
|
function parsePositiveIntEnv(value, defaultValue) {
|
|
75779
75806
|
if (!value) {
|
|
75780
75807
|
return defaultValue;
|
|
@@ -75844,7 +75871,7 @@ var CONFIG = {
|
|
|
75844
75871
|
NODE_ENV: process.env.NODE_ENV || "development",
|
|
75845
75872
|
// Proxy Configuration
|
|
75846
75873
|
USE_SYSTEM_PROXY: process.env.USE_SYSTEM_PROXY === "true"
|
|
75847
|
-
// Enable system proxy detection (PAC
|
|
75874
|
+
// Enable macOS system proxy detection (PAC file, system SOCKS)
|
|
75848
75875
|
};
|
|
75849
75876
|
var getConfig = () => ({
|
|
75850
75877
|
/** WordPress site API endpoint */
|
|
@@ -76192,6 +76219,11 @@ async function doInitializeProxy(detectMacOs) {
|
|
|
76192
76219
|
logger.info(`Proxy configured from environment: ${sanitizeProxyUrl(envProxy.url)}`, "PROXY");
|
|
76193
76220
|
return;
|
|
76194
76221
|
}
|
|
76222
|
+
if (!getConfig().useSystemProxy) {
|
|
76223
|
+
logger.debug("No proxy configured (system proxy detection disabled)", "PROXY");
|
|
76224
|
+
proxyConfig = { type: "none" };
|
|
76225
|
+
return;
|
|
76226
|
+
}
|
|
76195
76227
|
const macProxy = detectMacOs();
|
|
76196
76228
|
if (macProxy?.pacUrl) {
|
|
76197
76229
|
try {
|
|
@@ -76301,11 +76333,7 @@ async function setupFetchPolyfill() {
|
|
|
76301
76333
|
} else {
|
|
76302
76334
|
logger.info("Using native fetch API", "SYSTEM");
|
|
76303
76335
|
}
|
|
76304
|
-
|
|
76305
|
-
await initializeProxy();
|
|
76306
|
-
} else {
|
|
76307
|
-
logger.debug("System proxy support disabled (USE_SYSTEM_PROXY=false)", "PROXY");
|
|
76308
|
-
}
|
|
76336
|
+
await initializeProxy();
|
|
76309
76337
|
}
|
|
76310
76338
|
async function proxyFetch(url2, init) {
|
|
76311
76339
|
const headers = new Headers(init?.headers);
|
|
@@ -76313,9 +76341,6 @@ async function proxyFetch(url2, init) {
|
|
|
76313
76341
|
headers.set("User-Agent", clientProduct ? `${clientProduct} ${PROXY_PRODUCT}` : PROXY_PRODUCT);
|
|
76314
76342
|
}
|
|
76315
76343
|
init = { ...init, headers };
|
|
76316
|
-
if (!getConfig().useSystemProxy) {
|
|
76317
|
-
return fetch(url2, init);
|
|
76318
|
-
}
|
|
76319
76344
|
const agent = await getAgentForUrl(url2);
|
|
76320
76345
|
if (agent) {
|
|
76321
76346
|
const nodeFetch = (await Promise.resolve().then(() => (init_src(), src_exports))).default;
|
|
@@ -77405,7 +77430,11 @@ var OAuthCallbackServer = class {
|
|
|
77405
77430
|
async start() {
|
|
77406
77431
|
return new Promise((resolve, reject) => {
|
|
77407
77432
|
try {
|
|
77408
|
-
this.server = this.app.listen(this.options.port, this.options.host, () => {
|
|
77433
|
+
this.server = this.app.listen(this.options.port, this.options.host, (error51) => {
|
|
77434
|
+
if (error51) {
|
|
77435
|
+
reject(error51);
|
|
77436
|
+
return;
|
|
77437
|
+
}
|
|
77409
77438
|
logger.oauth(
|
|
77410
77439
|
`OAuth callback server listening on http://${this.options.host}:${this.options.port}`
|
|
77411
77440
|
);
|