@respira/wordpress-mcp-server 6.18.0 → 6.18.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/dist/server.d.ts CHANGED
@@ -129,6 +129,27 @@ export declare class RespiraWordPressServer {
129
129
  */
130
130
  private normalizeArgsForBackCompat;
131
131
  private handleToolCall;
132
+ /**
133
+ * v6.18.2: enforce a response-size cap on tool results.
134
+ *
135
+ * Customers were hitting silent session deaths after 3-4 tool calls in a
136
+ * row (telemetry confirmed across multiple users on 2026-05-21). Root cause
137
+ * is most likely the Claude Desktop / Cursor MCP supervisor reaping the
138
+ * subprocess when a STDIO write stalls. macOS pipe buffer is 64 KB; a
139
+ * single 600+ KB tool result (e.g. list_options dumping every wp_options
140
+ * row) fragments across many pipe writes and can starve the host's drain
141
+ * loop. Even at the SDK layer some MCP hosts apply a hard per-result cap.
142
+ *
143
+ * Strategy: serialize the result, measure the JSON byte length, and if it
144
+ * exceeds RESPIRA_MAX_TOOL_RESULT_BYTES (default 100 KiB), return a
145
+ * structured truncation envelope instead. Includes the original size,
146
+ * a per-tool pagination hint, and a small preview so the agent can
147
+ * recover without guessing.
148
+ *
149
+ * Opt-out: set RESPIRA_MAX_TOOL_RESULT_BYTES=0 to disable. Set to a
150
+ * larger value for hosts known to tolerate big payloads.
151
+ */
152
+ private capResponseSize;
132
153
  private dispatchToolCall;
133
154
  /**
134
155
  * v5.2.0 Elemental tool definitions.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH,OAAO,KAAK,EAAE,mBAAmB,EAAe,MAAM,kBAAkB,CAAC;AAyGzE,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAgC;IACnD,OAAO,CAAC,KAAK,CAA2C;IACxD,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,cAAc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,OAAO,CAAC,mBAAmB;IAwT3B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAe3C;IAEF;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;YAmCpB,cAAc;IA+D5B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,eAAe;YAuCT,gBAAgB;IAqpB9B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoRzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA6UxB,GAAG;CAyCV"}
package/dist/server.js CHANGED
@@ -116,6 +116,23 @@ const SITE_ID_PROPERTY = {
116
116
  type: 'string',
117
117
  description: 'Optional. Override the active site for this single call without changing the global current site. Use this when running multiple Cowork chats against different WordPress sites in parallel so each chat can pin its own target site per tool call.',
118
118
  };
119
+ /**
120
+ * v6.18.2: per-tool pagination hint, surfaced inside the truncation envelope
121
+ * when a tool result exceeds the response-size cap. Tells the agent the
122
+ * specific argument shape to retry with so it can recover without guessing.
123
+ */
124
+ const TOOLS_WITH_PAGINATION_HINT = {
125
+ respira_list_options: 'Pass per_page (default unlimited, recommend 25) and page args. Or use respira_get_option with a single option_name when you already know which key you need.',
126
+ wordpress_list_options: 'Pass per_page (default unlimited, recommend 25) and page args. Or use wordpress_get_option with a single option_name when you already know which key you need.',
127
+ respira_get_builder_info: 'Filter to one builder at a time via builder_name arg if available, or call respira_get_active_site first and only ask for the active builder.',
128
+ wordpress_get_builder_info: 'Filter to one builder at a time via builder_name arg if available, or call wordpress_get_active_site first and only ask for the active builder.',
129
+ respira_list_pages: 'Pass per_page (default 100, recommend 25) and page args plus a search filter to narrow results.',
130
+ respira_list_posts: 'Pass per_page (default 100, recommend 25) and page args plus a search filter to narrow results.',
131
+ respira_list_users: 'Pass per_page (default 100, recommend 25) and page args plus a search filter to narrow results.',
132
+ respira_list_media: 'Pass per_page (default 100, recommend 25) and page args plus a mime_type filter to narrow results.',
133
+ respira_extract_builder_content: 'Use respira_get_page_outline first for a row-level summary, or pass node_id to extract just the subtree you care about.',
134
+ respira_list_plugins: 'No pagination arg today. The full plugin list is usually small; consider filing a feature request if your site hits the cap here.',
135
+ };
119
136
  export class RespiraWordPressServer {
120
137
  server;
121
138
  currentSite = null;
@@ -3908,13 +3925,71 @@ Allowlist: css, scss, less, json. PHP / JS theme writes are intentionally out of
3908
3925
  }
3909
3926
  }
3910
3927
  if (deprecated && result && typeof result === 'object' && !Array.isArray(result)) {
3911
- return {
3928
+ result = {
3912
3929
  ...result,
3913
3930
  _deprecation_notice: `Tool name "${name}" is deprecated. Use "respira_${name.slice('wordpress_'.length)}" instead. ` +
3914
3931
  'wordpress_* names will be removed in v6.0.',
3915
3932
  };
3916
3933
  }
3917
- return result;
3934
+ return this.capResponseSize(canonical, result);
3935
+ }
3936
+ /**
3937
+ * v6.18.2: enforce a response-size cap on tool results.
3938
+ *
3939
+ * Customers were hitting silent session deaths after 3-4 tool calls in a
3940
+ * row (telemetry confirmed across multiple users on 2026-05-21). Root cause
3941
+ * is most likely the Claude Desktop / Cursor MCP supervisor reaping the
3942
+ * subprocess when a STDIO write stalls. macOS pipe buffer is 64 KB; a
3943
+ * single 600+ KB tool result (e.g. list_options dumping every wp_options
3944
+ * row) fragments across many pipe writes and can starve the host's drain
3945
+ * loop. Even at the SDK layer some MCP hosts apply a hard per-result cap.
3946
+ *
3947
+ * Strategy: serialize the result, measure the JSON byte length, and if it
3948
+ * exceeds RESPIRA_MAX_TOOL_RESULT_BYTES (default 100 KiB), return a
3949
+ * structured truncation envelope instead. Includes the original size,
3950
+ * a per-tool pagination hint, and a small preview so the agent can
3951
+ * recover without guessing.
3952
+ *
3953
+ * Opt-out: set RESPIRA_MAX_TOOL_RESULT_BYTES=0 to disable. Set to a
3954
+ * larger value for hosts known to tolerate big payloads.
3955
+ */
3956
+ capResponseSize(toolName, result) {
3957
+ const envOverride = parseInt(process.env.RESPIRA_MAX_TOOL_RESULT_BYTES || '', 10);
3958
+ const cap = Number.isFinite(envOverride) && envOverride >= 0
3959
+ ? envOverride
3960
+ : 100 * 1024;
3961
+ if (cap === 0 || result == null)
3962
+ return result;
3963
+ let serialized;
3964
+ try {
3965
+ serialized = JSON.stringify(result);
3966
+ }
3967
+ catch {
3968
+ return result;
3969
+ }
3970
+ if (serialized.length <= cap)
3971
+ return result;
3972
+ // Build a truncated envelope. Preserve the top-level shape best-effort
3973
+ // so callers reading `result.site` etc. still get something useful.
3974
+ const preview = serialized.slice(0, Math.min(2000, cap / 2));
3975
+ const paginationHint = TOOLS_WITH_PAGINATION_HINT[toolName] ||
3976
+ 'Try re-calling this tool with pagination args (per_page, page, search filter) to limit the result size.';
3977
+ const envelope = {
3978
+ _truncated: true,
3979
+ _original_size_bytes: serialized.length,
3980
+ _cap_bytes: cap,
3981
+ _tool_name: toolName,
3982
+ _preview_json: preview,
3983
+ _hint: paginationHint,
3984
+ _why: 'Response exceeded the MCP server response-size cap. ' +
3985
+ 'Most MCP hosts (Claude Desktop, Cursor) silently kill the subprocess ' +
3986
+ 'when a STDIO write stalls; this cap prevents that. ' +
3987
+ 'Set RESPIRA_MAX_TOOL_RESULT_BYTES env var to change the cap.',
3988
+ };
3989
+ if (result && typeof result === 'object' && !Array.isArray(result) && result.site) {
3990
+ envelope.site = result.site;
3991
+ }
3992
+ return envelope;
3918
3993
  }
3919
3994
  async dispatchToolCall(name, args) {
3920
3995
  // v6.12.0: per-call site resolution. Agnostic tools work without a