@automattic/mcp-wordpress-remote 0.2.19 → 0.2.20
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 +30 -30
- package/dist/lib.d.ts +1 -0
- package/dist/lib.js +20 -8
- package/dist/proxy.js +88 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ Add to your MCP client configuration (e.g., Claude Desktop's `claude_desktop_con
|
|
|
50
50
|
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.
|
|
51
51
|
|
|
52
52
|
#### JSON Format (Recommended):
|
|
53
|
+
|
|
53
54
|
```json
|
|
54
55
|
{
|
|
55
56
|
"mcpServers": {
|
|
@@ -66,6 +67,7 @@ You can add custom headers to all API requests using the `CUSTOM_HEADERS` enviro
|
|
|
66
67
|
```
|
|
67
68
|
|
|
68
69
|
#### Comma-Separated Format:
|
|
70
|
+
|
|
69
71
|
```json
|
|
70
72
|
{
|
|
71
73
|
"mcpServers": {
|
|
@@ -82,6 +84,7 @@ You can add custom headers to all API requests using the `CUSTOM_HEADERS` enviro
|
|
|
82
84
|
```
|
|
83
85
|
|
|
84
86
|
#### Command Line Usage:
|
|
87
|
+
|
|
85
88
|
```bash
|
|
86
89
|
CUSTOM_HEADERS='{"X-MCP-API-Key": "wc_mcp_FaQduhQcW0mfVaZgP3yaaqDuXaZ3mw7j"}' \
|
|
87
90
|
WP_API_URL="https://your-site.com" \
|
|
@@ -89,6 +92,7 @@ npx @automattic/mcp-wordpress-remote
|
|
|
89
92
|
```
|
|
90
93
|
|
|
91
94
|
Custom headers are included in:
|
|
95
|
+
|
|
92
96
|
- All WordPress API requests
|
|
93
97
|
- OAuth discovery requests
|
|
94
98
|
- OAuth token exchange requests
|
|
@@ -130,8 +134,6 @@ OAuth 2.1 provides the most secure and user-friendly experience with full MCP Au
|
|
|
130
134
|
}
|
|
131
135
|
```
|
|
132
136
|
|
|
133
|
-
|
|
134
|
-
|
|
135
137
|
**MCP Authorization Specification Features:**
|
|
136
138
|
|
|
137
139
|
- **OAuth 2.1 authorization code flow** with PKCE (RFC 7636)
|
|
@@ -240,34 +242,32 @@ For WooCommerce-specific tools and reports:
|
|
|
240
242
|
|
|
241
243
|
### Environment Variables
|
|
242
244
|
|
|
243
|
-
| Variable
|
|
244
|
-
|
|
|
245
|
-
| `WP_API_URL`
|
|
246
|
-
| `OAUTH_ENABLED`
|
|
247
|
-
| `OAUTH_CALLBACK_PORT`
|
|
248
|
-
| `OAUTH_HOST`
|
|
249
|
-
| `WP_OAUTH_CLIENT_ID`
|
|
250
|
-
| **OAuth Endpoints**
|
|
251
|
-
| `OAUTH_AUTHORIZE_ENDPOINT`
|
|
252
|
-
| `OAUTH_TOKEN_ENDPOINT`
|
|
253
|
-
| `OAUTH_AUTHENTICATE_ENDPOINT
|
|
254
|
-
| **MCP OAuth 2.1 Settings**
|
|
255
|
-
| `OAUTH_FLOW_TYPE`
|
|
256
|
-
| `OAUTH_USE_PKCE`
|
|
257
|
-
| `OAUTH_DYNAMIC_REGISTRATION`
|
|
258
|
-
| `OAUTH_RESOURCE_INDICATOR`
|
|
259
|
-
| **Configuration**
|
|
260
|
-
| `WP_MCP_CONFIG_DIR`
|
|
261
|
-
| `LOG_FILE`
|
|
262
|
-
| `LOG_LEVEL`
|
|
263
|
-
| **Legacy Authentication**
|
|
264
|
-
| `JWT_TOKEN`
|
|
265
|
-
| `WP_API_USERNAME`
|
|
266
|
-
| `WP_API_PASSWORD`
|
|
267
|
-
| `WOO_CUSTOMER_KEY`
|
|
268
|
-
| `WOO_CUSTOMER_SECRET`
|
|
269
|
-
|
|
270
|
-
|
|
245
|
+
| Variable | Description | Default | Required |
|
|
246
|
+
| ----------------------------- | ------------------------------------------------ | -------------------- | --------------------- |
|
|
247
|
+
| `WP_API_URL` | WordPress site URL | - | ✅ |
|
|
248
|
+
| `OAUTH_ENABLED` | Enable OAuth authentication | `true` | - |
|
|
249
|
+
| `OAUTH_CALLBACK_PORT` | OAuth callback port | `7665` | - |
|
|
250
|
+
| `OAUTH_HOST` | OAuth callback hostname | `127.0.0.1` | - |
|
|
251
|
+
| `WP_OAUTH_CLIENT_ID` | Custom OAuth client ID | - | - |
|
|
252
|
+
| **OAuth Endpoints** | | | |
|
|
253
|
+
| `OAUTH_AUTHORIZE_ENDPOINT` | OAuth authorization endpoint | - | ✅ (for custom OAuth) |
|
|
254
|
+
| `OAUTH_TOKEN_ENDPOINT` | OAuth token endpoint | - | ✅ (for custom OAuth) |
|
|
255
|
+
| `OAUTH_AUTHENTICATE_ENDPOINT` | OAuth authenticate endpoint | - | - |
|
|
256
|
+
| **MCP OAuth 2.1 Settings** | | | |
|
|
257
|
+
| `OAUTH_FLOW_TYPE` | OAuth flow type (authorization_code or implicit) | `authorization_code` | - |
|
|
258
|
+
| `OAUTH_USE_PKCE` | Use PKCE (required for OAuth 2.1) | `true` | - |
|
|
259
|
+
| `OAUTH_DYNAMIC_REGISTRATION` | Enable dynamic client registration | `true` | - |
|
|
260
|
+
| `OAUTH_RESOURCE_INDICATOR` | Use resource indicators (RFC 8707) | `true` | - |
|
|
261
|
+
| **Configuration** | | | |
|
|
262
|
+
| `WP_MCP_CONFIG_DIR` | Config directory override | `~/.mcp-auth` | - |
|
|
263
|
+
| `LOG_FILE` | Log file path | - | - |
|
|
264
|
+
| `LOG_LEVEL` | Log level (0-3) | `2` | - |
|
|
265
|
+
| **Legacy Authentication** | | | |
|
|
266
|
+
| `JWT_TOKEN` | JWT token for authentication | - | - |
|
|
267
|
+
| `WP_API_USERNAME` | WordPress username (legacy) | - | - |
|
|
268
|
+
| `WP_API_PASSWORD` | WordPress app password (legacy) | - | - |
|
|
269
|
+
| `WOO_CUSTOMER_KEY` | WooCommerce consumer key | - | - |
|
|
270
|
+
| `WOO_CUSTOMER_SECRET` | WooCommerce consumer secret | - | - |
|
|
271
271
|
|
|
272
272
|
### Disable OAuth
|
|
273
273
|
|
package/dist/lib.d.ts
CHANGED
|
@@ -280,6 +280,7 @@ declare function getFetchInfo(): {
|
|
|
280
280
|
*
|
|
281
281
|
* Supports:
|
|
282
282
|
* - macOS: Automatic PAC file detection from system proxy settings
|
|
283
|
+
* - macOS: System SOCKS proxy detection (AutoProxxy Tunnel All Traffic)
|
|
283
284
|
* - All platforms: Environment variables (SOCKS_PROXY, HTTPS_PROXY, etc.)
|
|
284
285
|
*/
|
|
285
286
|
|
package/dist/lib.js
CHANGED
|
@@ -35641,15 +35641,19 @@ import { SocksProxyAgent } from "socks-proxy-agent";
|
|
|
35641
35641
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
35642
35642
|
var proxyConfig = { type: "none" };
|
|
35643
35643
|
var initializationPromise = null;
|
|
35644
|
-
function
|
|
35644
|
+
function detectMacOsProxy() {
|
|
35645
35645
|
if (process.platform !== "darwin") return null;
|
|
35646
35646
|
try {
|
|
35647
35647
|
const output = execSync("scutil --proxy", { encoding: "utf-8", timeout: 3e3 });
|
|
35648
35648
|
const pacEnabled = output.match(/ProxyAutoConfigEnable\s*:\s*(\d)/)?.[1] === "1";
|
|
35649
35649
|
const pacUrl = output.match(/ProxyAutoConfigURLString\s*:\s*(\S+)/)?.[1];
|
|
35650
|
-
|
|
35651
|
-
|
|
35652
|
-
|
|
35650
|
+
const socksEnabled = output.match(/SOCKSEnable\s*:\s*(\d)/)?.[1] === "1";
|
|
35651
|
+
const socksHost = output.match(/SOCKSProxy\s*:\s*(\S+)/)?.[1];
|
|
35652
|
+
const socksPort = output.match(/SOCKSPort\s*:\s*(\d+)/)?.[1];
|
|
35653
|
+
return {
|
|
35654
|
+
pacUrl: pacEnabled && pacUrl ? pacUrl : null,
|
|
35655
|
+
socks: socksEnabled && socksHost && socksPort ? { host: socksHost, port: socksPort } : null
|
|
35656
|
+
};
|
|
35653
35657
|
} catch {
|
|
35654
35658
|
}
|
|
35655
35659
|
return null;
|
|
@@ -35715,10 +35719,10 @@ async function initializeProxy() {
|
|
|
35715
35719
|
return initializationPromise;
|
|
35716
35720
|
}
|
|
35717
35721
|
async function doInitializeProxy() {
|
|
35718
|
-
const
|
|
35719
|
-
if (pacUrl) {
|
|
35722
|
+
const macProxy = detectMacOsProxy();
|
|
35723
|
+
if (macProxy?.pacUrl) {
|
|
35720
35724
|
try {
|
|
35721
|
-
const response = await fetch(pacUrl);
|
|
35725
|
+
const response = await fetch(macProxy.pacUrl);
|
|
35722
35726
|
const pacScript = await response.text();
|
|
35723
35727
|
const { getQuickJS } = await import("@tootallnate/quickjs-emscripten");
|
|
35724
35728
|
const { createPacResolver } = await import("pac-resolver");
|
|
@@ -35728,12 +35732,20 @@ async function doInitializeProxy() {
|
|
|
35728
35732
|
type: "pac",
|
|
35729
35733
|
pacResolver: resolver
|
|
35730
35734
|
};
|
|
35731
|
-
logger.info(`PAC proxy initialized from ${sanitizeProxyUrl(pacUrl)}`, "PROXY");
|
|
35735
|
+
logger.info(`PAC proxy initialized from ${sanitizeProxyUrl(macProxy.pacUrl)}`, "PROXY");
|
|
35732
35736
|
return;
|
|
35733
35737
|
} catch (error) {
|
|
35734
35738
|
logger.error(`Failed to initialize PAC proxy: ${error}`, "PROXY");
|
|
35735
35739
|
}
|
|
35736
35740
|
}
|
|
35741
|
+
if (macProxy?.socks) {
|
|
35742
|
+
const { host, port } = macProxy.socks;
|
|
35743
|
+
const bracketedHost = host.includes(":") ? `[${host}]` : host;
|
|
35744
|
+
const socksUrl = `socks5://${bracketedHost}:${port}`;
|
|
35745
|
+
proxyConfig = { type: "env", envProxy: { url: socksUrl, type: "socks" } };
|
|
35746
|
+
logger.info(`System SOCKS proxy configured: ${sanitizeProxyUrl(socksUrl)}`, "PROXY");
|
|
35747
|
+
return;
|
|
35748
|
+
}
|
|
35737
35749
|
const envProxy = detectEnvProxy();
|
|
35738
35750
|
if (envProxy) {
|
|
35739
35751
|
proxyConfig = { type: "env", envProxy };
|
package/dist/proxy.js
CHANGED
|
@@ -36305,15 +36305,19 @@ import { SocksProxyAgent } from "socks-proxy-agent";
|
|
|
36305
36305
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
36306
36306
|
var proxyConfig = { type: "none" };
|
|
36307
36307
|
var initializationPromise = null;
|
|
36308
|
-
function
|
|
36308
|
+
function detectMacOsProxy() {
|
|
36309
36309
|
if (process.platform !== "darwin") return null;
|
|
36310
36310
|
try {
|
|
36311
36311
|
const output = execSync("scutil --proxy", { encoding: "utf-8", timeout: 3e3 });
|
|
36312
36312
|
const pacEnabled = output.match(/ProxyAutoConfigEnable\s*:\s*(\d)/)?.[1] === "1";
|
|
36313
36313
|
const pacUrl = output.match(/ProxyAutoConfigURLString\s*:\s*(\S+)/)?.[1];
|
|
36314
|
-
|
|
36315
|
-
|
|
36316
|
-
|
|
36314
|
+
const socksEnabled = output.match(/SOCKSEnable\s*:\s*(\d)/)?.[1] === "1";
|
|
36315
|
+
const socksHost = output.match(/SOCKSProxy\s*:\s*(\S+)/)?.[1];
|
|
36316
|
+
const socksPort = output.match(/SOCKSPort\s*:\s*(\d+)/)?.[1];
|
|
36317
|
+
return {
|
|
36318
|
+
pacUrl: pacEnabled && pacUrl ? pacUrl : null,
|
|
36319
|
+
socks: socksEnabled && socksHost && socksPort ? { host: socksHost, port: socksPort } : null
|
|
36320
|
+
};
|
|
36317
36321
|
} catch {
|
|
36318
36322
|
}
|
|
36319
36323
|
return null;
|
|
@@ -36379,10 +36383,10 @@ async function initializeProxy() {
|
|
|
36379
36383
|
return initializationPromise;
|
|
36380
36384
|
}
|
|
36381
36385
|
async function doInitializeProxy() {
|
|
36382
|
-
const
|
|
36383
|
-
if (pacUrl) {
|
|
36386
|
+
const macProxy = detectMacOsProxy();
|
|
36387
|
+
if (macProxy?.pacUrl) {
|
|
36384
36388
|
try {
|
|
36385
|
-
const response = await fetch(pacUrl);
|
|
36389
|
+
const response = await fetch(macProxy.pacUrl);
|
|
36386
36390
|
const pacScript = await response.text();
|
|
36387
36391
|
const { getQuickJS } = await import("@tootallnate/quickjs-emscripten");
|
|
36388
36392
|
const { createPacResolver } = await import("pac-resolver");
|
|
@@ -36392,12 +36396,20 @@ async function doInitializeProxy() {
|
|
|
36392
36396
|
type: "pac",
|
|
36393
36397
|
pacResolver: resolver
|
|
36394
36398
|
};
|
|
36395
|
-
logger.info(`PAC proxy initialized from ${sanitizeProxyUrl(pacUrl)}`, "PROXY");
|
|
36399
|
+
logger.info(`PAC proxy initialized from ${sanitizeProxyUrl(macProxy.pacUrl)}`, "PROXY");
|
|
36396
36400
|
return;
|
|
36397
36401
|
} catch (error) {
|
|
36398
36402
|
logger.error(`Failed to initialize PAC proxy: ${error}`, "PROXY");
|
|
36399
36403
|
}
|
|
36400
36404
|
}
|
|
36405
|
+
if (macProxy?.socks) {
|
|
36406
|
+
const { host, port } = macProxy.socks;
|
|
36407
|
+
const bracketedHost = host.includes(":") ? `[${host}]` : host;
|
|
36408
|
+
const socksUrl = `socks5://${bracketedHost}:${port}`;
|
|
36409
|
+
proxyConfig = { type: "env", envProxy: { url: socksUrl, type: "socks" } };
|
|
36410
|
+
logger.info(`System SOCKS proxy configured: ${sanitizeProxyUrl(socksUrl)}`, "PROXY");
|
|
36411
|
+
return;
|
|
36412
|
+
}
|
|
36401
36413
|
const envProxy = detectEnvProxy();
|
|
36402
36414
|
if (envProxy) {
|
|
36403
36415
|
proxyConfig = { type: "env", envProxy };
|
|
@@ -39166,17 +39178,29 @@ async function WordPressProxy() {
|
|
|
39166
39178
|
logger.debug("Initialize response:", "INIT", wordpressInitResponse);
|
|
39167
39179
|
return wordpressInitResponse;
|
|
39168
39180
|
} catch (error) {
|
|
39169
|
-
logger.error(
|
|
39181
|
+
logger.error(
|
|
39182
|
+
"\u274C Failed to initialize WordPress connection with client parameters",
|
|
39183
|
+
"INIT",
|
|
39184
|
+
error
|
|
39185
|
+
);
|
|
39186
|
+
const clientProtocolVersion = request?.params?.protocolVersion || "2025-06-18";
|
|
39170
39187
|
const fallbackResponse = {
|
|
39171
|
-
protocolVersion:
|
|
39188
|
+
protocolVersion: clientProtocolVersion,
|
|
39172
39189
|
serverInfo: {
|
|
39173
39190
|
name: "WordPress MCP Remote Proxy",
|
|
39174
39191
|
version: MCP_WORDPRESS_REMOTE_VERSION
|
|
39175
39192
|
},
|
|
39176
39193
|
capabilities: {
|
|
39177
|
-
tools: {
|
|
39178
|
-
|
|
39179
|
-
|
|
39194
|
+
tools: {
|
|
39195
|
+
listChanged: false
|
|
39196
|
+
},
|
|
39197
|
+
resources: {
|
|
39198
|
+
listChanged: false,
|
|
39199
|
+
subscribe: false
|
|
39200
|
+
},
|
|
39201
|
+
prompts: {
|
|
39202
|
+
listChanged: false
|
|
39203
|
+
},
|
|
39180
39204
|
logging: {},
|
|
39181
39205
|
completions: {}
|
|
39182
39206
|
},
|
|
@@ -39186,24 +39210,62 @@ async function WordPressProxy() {
|
|
|
39186
39210
|
return fallbackResponse;
|
|
39187
39211
|
}
|
|
39188
39212
|
});
|
|
39189
|
-
server.setRequestHandler(
|
|
39190
|
-
|
|
39191
|
-
|
|
39192
|
-
|
|
39193
|
-
server.setRequestHandler(
|
|
39194
|
-
|
|
39195
|
-
|
|
39196
|
-
|
|
39197
|
-
server.setRequestHandler(
|
|
39198
|
-
|
|
39199
|
-
|
|
39200
|
-
|
|
39213
|
+
server.setRequestHandler(
|
|
39214
|
+
ListToolsRequestSchema,
|
|
39215
|
+
createWrappedHandler(HANDLER_CONFIGS.listTools, sessionContext)
|
|
39216
|
+
);
|
|
39217
|
+
server.setRequestHandler(
|
|
39218
|
+
CallToolRequestSchema,
|
|
39219
|
+
createWrappedHandler(HANDLER_CONFIGS.callTool, sessionContext)
|
|
39220
|
+
);
|
|
39221
|
+
server.setRequestHandler(
|
|
39222
|
+
ListResourcesRequestSchema,
|
|
39223
|
+
createWrappedHandler(HANDLER_CONFIGS.listResources, sessionContext)
|
|
39224
|
+
);
|
|
39225
|
+
server.setRequestHandler(
|
|
39226
|
+
ListResourceTemplatesRequestSchema,
|
|
39227
|
+
createWrappedHandler(HANDLER_CONFIGS.listResourceTemplates, sessionContext)
|
|
39228
|
+
);
|
|
39229
|
+
server.setRequestHandler(
|
|
39230
|
+
ReadResourceRequestSchema,
|
|
39231
|
+
createWrappedHandler(HANDLER_CONFIGS.readResource, sessionContext)
|
|
39232
|
+
);
|
|
39233
|
+
server.setRequestHandler(
|
|
39234
|
+
SubscribeRequestSchema,
|
|
39235
|
+
createWrappedHandler(HANDLER_CONFIGS.subscribe, sessionContext)
|
|
39236
|
+
);
|
|
39237
|
+
server.setRequestHandler(
|
|
39238
|
+
UnsubscribeRequestSchema,
|
|
39239
|
+
createWrappedHandler(HANDLER_CONFIGS.unsubscribe, sessionContext)
|
|
39240
|
+
);
|
|
39241
|
+
server.setRequestHandler(
|
|
39242
|
+
ListPromptsRequestSchema,
|
|
39243
|
+
createWrappedHandler(HANDLER_CONFIGS.listPrompts, sessionContext)
|
|
39244
|
+
);
|
|
39245
|
+
server.setRequestHandler(
|
|
39246
|
+
GetPromptRequestSchema,
|
|
39247
|
+
createWrappedHandler(HANDLER_CONFIGS.getPrompt, sessionContext)
|
|
39248
|
+
);
|
|
39249
|
+
server.setRequestHandler(
|
|
39250
|
+
SetLevelRequestSchema,
|
|
39251
|
+
createWrappedHandler(HANDLER_CONFIGS.setLevel, sessionContext)
|
|
39252
|
+
);
|
|
39253
|
+
server.setRequestHandler(
|
|
39254
|
+
CompleteRequestSchema,
|
|
39255
|
+
createWrappedHandler(HANDLER_CONFIGS.complete, sessionContext)
|
|
39256
|
+
);
|
|
39257
|
+
server.setRequestHandler(
|
|
39258
|
+
ListRootsRequestSchema,
|
|
39259
|
+
createWrappedHandler(HANDLER_CONFIGS.listRoots, sessionContext)
|
|
39260
|
+
);
|
|
39201
39261
|
const transport = new StdioServerTransport();
|
|
39202
39262
|
transport.onmessage = (message) => {
|
|
39203
39263
|
const msg = message;
|
|
39204
39264
|
const method = typeof msg?.method === "string" ? msg.method : "unknown";
|
|
39205
39265
|
const id = msg?.id ?? "none";
|
|
39206
|
-
const hasParams = Boolean(
|
|
39266
|
+
const hasParams = Boolean(
|
|
39267
|
+
msg?.params && typeof msg.params === "object" && Object.keys(msg.params).length
|
|
39268
|
+
);
|
|
39207
39269
|
logger.info("\u{1F4E5} Raw client message received", "TRANSPORT", {
|
|
39208
39270
|
method,
|
|
39209
39271
|
id,
|