@automattic/mcp-wordpress-remote 0.2.2 → 0.2.4

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.
Files changed (2) hide show
  1. package/dist/proxy.js +21 -7
  2. package/package.json +1 -1
package/dist/proxy.js CHANGED
@@ -23,7 +23,9 @@ var CONFIG = {
23
23
  OAUTH_HOST: process.env.OAUTH_HOST || "127.0.0.1",
24
24
  WP_OAUTH_CLIENT_ID: process.env.WP_OAUTH_CLIENT_ID || "",
25
25
  // No default - site-specific
26
- // MCP OAuth 2.1 specific settings
26
+ // OAuth flow type settings
27
+ // 'authorization_code' (recommended): MCP-compliant OAuth 2.1 with PKCE
28
+ // 'implicit' (legacy): Supported for WordPress.com and legacy implementations
27
29
  OAUTH_FLOW_TYPE: process.env.OAUTH_FLOW_TYPE || "authorization_code",
28
30
  OAUTH_USE_PKCE: process.env.OAUTH_USE_PKCE !== "false",
29
31
  // PKCE required for OAuth 2.1
@@ -101,9 +103,7 @@ function validateConfig() {
101
103
  errors.push("OAUTH_CALLBACK_PORT must be a valid port number (1-65535)");
102
104
  }
103
105
  if (CONFIG.OAUTH_FLOW_TYPE === "implicit") {
104
- errors.push(
105
- "OAUTH_FLOW_TYPE=implicit is deprecated. MCP Authorization specification 2025-06-18 requires OAuth 2.1 with authorization_code flow"
106
- );
106
+ console.warn("\u26A0\uFE0F Using deprecated implicit OAuth flow. Consider migrating to authorization_code flow for better security.");
107
107
  }
108
108
  if (CONFIG.OAUTH_FLOW_TYPE === "authorization_code" && !CONFIG.OAUTH_USE_PKCE) {
109
109
  errors.push(
@@ -1266,10 +1266,18 @@ var WP_PERSISTENT_CONFIG = {
1266
1266
  var PersistentWPOAuthClientProvider = class {
1267
1267
  constructor(options) {
1268
1268
  this.authPromise = null;
1269
+ const isWpCom = isWordPressComSite(options.serverUrl || "");
1270
+ const recommendedConfig = getRecommendedOAuthConfig(options.serverUrl || "");
1269
1271
  this.options = {
1270
1272
  ...WP_PERSISTENT_CONFIG,
1271
1273
  ...options
1272
1274
  };
1275
+ if (isWpCom && recommendedConfig.authorizationEndpoint) {
1276
+ this.options.authorizeEndpoint = recommendedConfig.authorizationEndpoint;
1277
+ logger.debug("Using WordPress.com OAuth endpoint", "OAUTH", {
1278
+ endpoint: recommendedConfig.authorizationEndpoint
1279
+ });
1280
+ }
1273
1281
  this.serverUrlHash = generateServerUrlHash(this.options.serverUrl);
1274
1282
  this.events = new EventEmitter2();
1275
1283
  this.events.setMaxListeners(10);
@@ -1278,7 +1286,9 @@ var PersistentWPOAuthClientProvider = class {
1278
1286
  serverUrl: this.options.serverUrl,
1279
1287
  serverHash: this.serverUrlHash,
1280
1288
  clientId: this.options.clientId || "auto-generated",
1281
- callbackPort: this.options.callbackPort
1289
+ callbackPort: this.options.callbackPort,
1290
+ authorizeEndpoint: this.options.authorizeEndpoint,
1291
+ isWordPressCom: isWpCom
1282
1292
  });
1283
1293
  }
1284
1294
  /**
@@ -1462,7 +1472,6 @@ var PersistentWPOAuthClientProvider = class {
1462
1472
  * Build the WordPress authorization URL
1463
1473
  */
1464
1474
  buildAuthorizationUrl(callbackUrl, state) {
1465
- const baseUrl = this.options.serverUrl.replace(/\/+$/, "");
1466
1475
  const authEndpoint = this.options.authorizeEndpoint || WP_PERSISTENT_CONFIG.authorizeEndpoint;
1467
1476
  const params = new URLSearchParams({
1468
1477
  response_type: "token",
@@ -1474,7 +1483,12 @@ var PersistentWPOAuthClientProvider = class {
1474
1483
  if (this.options.clientId) {
1475
1484
  params.set("client_id", this.options.clientId);
1476
1485
  }
1477
- return `${baseUrl}${authEndpoint}?${params.toString()}`;
1486
+ if (authEndpoint.startsWith("http://") || authEndpoint.startsWith("https://")) {
1487
+ return `${authEndpoint}?${params.toString()}`;
1488
+ } else {
1489
+ const baseUrl = this.options.serverUrl.replace(/\/+$/, "");
1490
+ return `${baseUrl}${authEndpoint}?${params.toString()}`;
1491
+ }
1478
1492
  }
1479
1493
  /**
1480
1494
  * Generate a secure state parameter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/mcp-wordpress-remote",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "MCP WordPress Remote proxy server",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"