@automattic/mcp-wordpress-remote 0.2.20 → 0.2.21

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 +44 -11
  2. package/package.json +1 -1
package/dist/proxy.js CHANGED
@@ -38808,12 +38808,45 @@ function prepareRequest(wpRequestParams, mcpRequest, context) {
38808
38808
  }
38809
38809
  }
38810
38810
  function createSessionContext() {
38811
+ let resolve;
38812
+ const ready = new Promise((r2) => {
38813
+ resolve = r2;
38814
+ });
38811
38815
  return {
38812
38816
  sessionId: null,
38813
38817
  requestIdCounter: 0,
38814
- transportType: null
38818
+ transportType: null,
38819
+ _init: {
38820
+ ready,
38821
+ resolve,
38822
+ settled: false,
38823
+ failed: false
38824
+ }
38815
38825
  };
38816
38826
  }
38827
+ function resolveInit(context, failed) {
38828
+ if (context._init.settled) return;
38829
+ context._init.failed = failed;
38830
+ context._init.settled = true;
38831
+ context._init.resolve();
38832
+ }
38833
+ var INIT_TIMEOUT_MS = 3e4;
38834
+ async function waitForInit(context, timeoutMs = INIT_TIMEOUT_MS) {
38835
+ if (context._init.settled) {
38836
+ return context._init.failed ? { ready: false, reason: "failed" } : { ready: true };
38837
+ }
38838
+ let timer;
38839
+ const timeout = new Promise((resolve) => {
38840
+ timer = setTimeout(() => resolve("timeout"), timeoutMs);
38841
+ });
38842
+ const result = await Promise.race([context._init.ready.then(() => "ready"), timeout]);
38843
+ clearTimeout(timer);
38844
+ if (result === "timeout") {
38845
+ logger.error("Timed out waiting for initialization to complete", "INIT");
38846
+ return { ready: false, reason: "timeout" };
38847
+ }
38848
+ return context._init.failed ? { ready: false, reason: "failed" } : { ready: true };
38849
+ }
38817
38850
 
38818
38851
  // src/lib/transport-detection.ts
38819
38852
  async function detectTransportType(context, initParams) {
@@ -38982,6 +39015,11 @@ function convertAPIErrorToMcpError(error) {
38982
39015
  function createRequestHandler(config, context) {
38983
39016
  return async (request) => {
38984
39017
  logger.debug(`Processing ${config.name}Request`, "MCP");
39018
+ const init = await waitForInit(context);
39019
+ if (!init.ready) {
39020
+ const cause = init.reason === "timeout" ? "timed out waiting for" : "failed during";
39021
+ throw new Error(`Cannot process ${config.method}: WordPress connection ${cause} initialization`);
39022
+ }
38985
39023
  const wpParams = config.paramMapper(request);
38986
39024
  const requestData = prepareRequest(wpParams, request, context);
38987
39025
  const response = await wpRequest(requestData, context.transportType === "jsonrpc");
@@ -39168,6 +39206,7 @@ async function WordPressProxy() {
39168
39206
  try {
39169
39207
  logger.info("\u{1F504} Initializing WordPress connection with client parameters", "INIT");
39170
39208
  const { initResult } = await detectTransportType(sessionContext, request.params);
39209
+ resolveInit(sessionContext, false);
39171
39210
  const wordpressInitResponse = {
39172
39211
  protocolVersion: initResult.protocolVersion || "2025-06-18",
39173
39212
  serverInfo: initResult.serverInfo,
@@ -39183,6 +39222,7 @@ async function WordPressProxy() {
39183
39222
  "INIT",
39184
39223
  error
39185
39224
  );
39225
+ resolveInit(sessionContext, true);
39186
39226
  const clientProtocolVersion = request?.params?.protocolVersion || "2025-06-18";
39187
39227
  const fallbackResponse = {
39188
39228
  protocolVersion: clientProtocolVersion,
@@ -39191,16 +39231,9 @@ async function WordPressProxy() {
39191
39231
  version: MCP_WORDPRESS_REMOTE_VERSION
39192
39232
  },
39193
39233
  capabilities: {
39194
- tools: {
39195
- listChanged: false
39196
- },
39197
- resources: {
39198
- listChanged: false,
39199
- subscribe: false
39200
- },
39201
- prompts: {
39202
- listChanged: false
39203
- },
39234
+ tools: {},
39235
+ resources: {},
39236
+ prompts: {},
39204
39237
  logging: {},
39205
39238
  completions: {}
39206
39239
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/mcp-wordpress-remote",
3
- "version": "0.2.20",
3
+ "version": "0.2.21",
4
4
  "description": "MCP WordPress Remote proxy server",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"