mcp-prompt-optimizer 3.2.2 → 3.3.0

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/index.js +128 -4
  2. package/package.json +25 -2
package/index.js CHANGED
@@ -64,6 +64,7 @@ const ENDPOINTS = {
64
64
  SESSION: (id) => `/api/v1/context-engineer/sessions/${id}`,
65
65
  TRANSFORM: '/api/v1/context-engineer/transform',
66
66
  QUOTA: '/api/v1/context-engineer/quota',
67
+ HARNESS_BUNDLE: '/api/v1/context-engineer/harness-bundle',
67
68
  },
68
69
  };
69
70
 
@@ -146,6 +147,25 @@ class MCPPromptOptimizer {
146
147
  },
147
148
  required: ["label", "description"]
148
149
  }
150
+ },
151
+ intent_frame: {
152
+ type: "object",
153
+ description: "Question Method intent framing — steers optimization toward a specific angle, excludes off-topic territory, and defines what success looks like. Any non-null field floors routing to HYBRID tier minimum.",
154
+ properties: {
155
+ perspective: {
156
+ type: "string",
157
+ description: "The angle or thesis to optimize from (e.g. 'growth is a retention problem, not an acquisition problem'). Gives the optimizer a north-star direction."
158
+ },
159
+ out_of_scope: {
160
+ type: "array",
161
+ items: { type: "string" },
162
+ description: "Topics, approaches, or angles to explicitly exclude from optimization (e.g. ['pricing strategy', 'acquisition channels'])."
163
+ },
164
+ success_definition: {
165
+ type: "string",
166
+ description: "Narrative description of what a successful optimized output achieves (e.g. 'reader understands why churn drives flat revenue even with user growth')."
167
+ }
168
+ }
149
169
  }
150
170
  },
151
171
  required: ["prompt"]
@@ -311,7 +331,17 @@ class MCPPromptOptimizer {
311
331
  properties: {
312
332
  goal: { type: "string", description: "What the agent should accomplish" },
313
333
  context: { type: "string", description: "Additional context (optional)" },
314
- model_id: { type: "string", description: "Model to use (optional)" }
334
+ model_id: { type: "string", description: "Model to use (optional)" },
335
+ intent_frame: {
336
+ type: "object",
337
+ description: "Optional IntentFrame to sharpen SOP scope and success criteria.",
338
+ properties: {
339
+ perspective: { type: "string", description: "The agent role or viewpoint (e.g. DevOps engineer)." },
340
+ out_of_scope: { type: "string", description: "What is explicitly excluded from this workflow." },
341
+ success_definition: { type: "string", description: "Measurable criteria that define success." }
342
+ },
343
+ additionalProperties: false
344
+ }
315
345
  },
316
346
  required: ["goal"]
317
347
  }
@@ -347,6 +377,37 @@ class MCPPromptOptimizer {
347
377
  description: "Check your Context Engineer credit balance and available workflow types.",
348
378
  inputSchema: { type: "object", properties: {}, additionalProperties: false }
349
379
  },
380
+ {
381
+ name: "generate_harness_bundle",
382
+ description: (
383
+ "Generate a deployment-ready Agentic Harness ZIP bundle for a specific platform. "
384
+ + "Returns a confirmation message when the bundle is queued. "
385
+ + "Explorer+ required for non-default deploy targets."
386
+ ),
387
+ inputSchema: {
388
+ type: "object",
389
+ properties: {
390
+ goal: {
391
+ type: "string",
392
+ description: "The workflow goal the harness is built for."
393
+ },
394
+ deploy_target: {
395
+ type: "string",
396
+ enum: ["claude_code", "claude_desktop", "cursor", "copilot", "windsurf", "cline", "zed", "replit", "openai_agents", "ollama"],
397
+ description: "Target deployment platform. Default: claude_code."
398
+ },
399
+ session_id: {
400
+ type: "string",
401
+ description: "Optional: session ID from a prior generate_skill_package call to reuse SOP."
402
+ },
403
+ sop_content: {
404
+ type: "string",
405
+ description: "The SOP content to base the harness on (required if no session_id)."
406
+ }
407
+ },
408
+ required: ["goal"]
409
+ }
410
+ },
350
411
  ];
351
412
 
352
413
  // Add advanced tools if Bayesian optimization is enabled
@@ -404,6 +465,7 @@ class MCPPromptOptimizer {
404
465
  case "generate_skill_package": return await this.handleGenerateSkillPackage(args);
405
466
  case "transform_for_framework": return await this.handleTransformForFramework(args);
406
467
  case "get_ce_quota_status": return await this.handleGetCEQuotaStatus();
468
+ case "generate_harness_bundle": return await this.handleGenerateHarnessBundle(args);
407
469
  default: throw new Error(`Unknown tool: ${name}`);
408
470
  }
409
471
  } catch (error) {
@@ -712,6 +774,13 @@ class MCPPromptOptimizer {
712
774
  optimizationPayload.value_hierarchy = args.value_hierarchy;
713
775
  }
714
776
 
777
+ if (args.intent_frame && typeof args.intent_frame === 'object') {
778
+ const { perspective, out_of_scope, success_definition } = args.intent_frame;
779
+ if (perspective || (out_of_scope && out_of_scope.length > 0) || success_definition) {
780
+ optimizationPayload.intent_frame = args.intent_frame;
781
+ }
782
+ }
783
+
715
784
  const result = await this.callBackendAPI(ENDPOINTS.OPTIMIZE, optimizationPayload);
716
785
 
717
786
  const enableBayesian = args.enable_bayesian !== false && this.bayesianOptimizationEnabled;
@@ -1024,6 +1093,7 @@ class MCPPromptOptimizer {
1024
1093
  const payload = { goal: args.goal };
1025
1094
  if (args.context) payload.context = args.context;
1026
1095
  if (args.model_id) payload.model_id = args.model_id;
1096
+ if (args.intent_frame) payload.intent_frame = args.intent_frame;
1027
1097
  try {
1028
1098
  const result = await this.callBackendAPI(ENDPOINTS.CE.SOP, payload);
1029
1099
  const sopContent = result.sop || result.content || result.result || JSON.stringify(result, null, 2);
@@ -1101,6 +1171,48 @@ class MCPPromptOptimizer {
1101
1171
  }
1102
1172
  }
1103
1173
 
1174
+ async handleGenerateHarnessBundle(args) {
1175
+ if (!args.sop_content && !args.session_id) {
1176
+ return { content: [{ type: "text", text: "Error: provide either sop_content or session_id." }] };
1177
+ }
1178
+ const deployTarget = args.deploy_target || "claude_code";
1179
+ const payload = {
1180
+ goal: args.goal,
1181
+ deploy_target: deployTarget,
1182
+ platform: deployTarget,
1183
+ user_goal: args.goal,
1184
+ sop_content: args.sop_content || "",
1185
+ };
1186
+
1187
+ // If session_id provided, first fetch session artifacts for sop_content
1188
+ if (args.session_id) {
1189
+ try {
1190
+ const status = await this.callBackendAPI(ENDPOINTS.CE.SESSION(args.session_id), null, "GET");
1191
+ const sop = status.artifacts?.sop_content || status.sop_content || "";
1192
+ if (sop) payload.sop_content = sop;
1193
+ } catch (sessionErr) {
1194
+ console.error(`[handleGenerateHarnessBundle] Could not fetch session ${args.session_id}:`, sessionErr.message || sessionErr);
1195
+ // Proceed with empty sop_content; backend will handle gracefully
1196
+ }
1197
+ }
1198
+
1199
+ try {
1200
+ await this.callBackendAPI(ENDPOINTS.CE.HARNESS_BUNDLE, payload);
1201
+ return {
1202
+ content: [{
1203
+ type: "text",
1204
+ text: `# Harness Bundle Requested\n\nDeploy target: **${deployTarget}**\nGoal: ${args.goal}\n\nDownload from the CE dashboard or via the /harness-bundle API endpoint.`
1205
+ }]
1206
+ };
1207
+ } catch (error) {
1208
+ const msg = error?.message || String(error);
1209
+ if (msg.includes("TIER_LIMIT_REACHED")) {
1210
+ return { content: [{ type: "text", text: `Upgrade required: Deploy target requires Explorer tier. Upgrade at /pricing.` }] };
1211
+ }
1212
+ throw error;
1213
+ }
1214
+ }
1215
+
1104
1216
  _formatSkillPackage(result) {
1105
1217
  const sections = ['# Skill Package Generated'];
1106
1218
  const artifacts = result.artifacts || result.steps || {};
@@ -1146,13 +1258,25 @@ class MCPPromptOptimizer {
1146
1258
  res.on('end', () => {
1147
1259
  try {
1148
1260
  if (res.statusCode >= 200 && res.statusCode < 300) {
1149
- const parsed = JSON.parse(responseData);
1150
- resolve(parsed);
1261
+ const contentType = res.headers['content-type'] || '';
1262
+ if (contentType.includes('application/json') || contentType === '') {
1263
+ try {
1264
+ const parsed = JSON.parse(responseData);
1265
+ resolve(parsed);
1266
+ } catch (e) {
1267
+ reject(new Error(`Invalid response format: ${e.message}`));
1268
+ }
1269
+ } else {
1270
+ // Binary or non-JSON response (e.g., application/zip) — return metadata
1271
+ resolve({ _binary: true, contentType, size: responseData.length });
1272
+ }
1151
1273
  } else {
1152
1274
  let errorMessage;
1153
1275
  try {
1154
1276
  const error = JSON.parse(responseData);
1155
- errorMessage = error.detail || error.message || `HTTP ${res.statusCode}`;
1277
+ errorMessage = (typeof error.detail === 'object' && error.detail !== null)
1278
+ ? JSON.stringify(error.detail)
1279
+ : (error.detail || error.message || `HTTP ${res.statusCode}`);
1156
1280
  } catch {
1157
1281
  errorMessage = `HTTP ${res.statusCode}: ${responseData}`;
1158
1282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-prompt-optimizer",
3
- "version": "3.2.2",
3
+ "version": "3.3.0",
4
4
  "description": "Professional cloud-based MCP server for AI-powered prompt optimization with intelligent context detection, Bayesian optimization, AG-UI real-time optimization, template auto-save, optimization insights, personal model configuration via WebUI, team collaboration, enterprise-grade features, production resilience, and startup validation. Universal compatibility with Claude Desktop, Cursor, Windsurf, and 17+ MCP clients.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -191,9 +191,32 @@
191
191
  "feature_parity": true,
192
192
  "bayesian_support": true,
193
193
  "agui_support": true,
194
- "last_sync": "2026-05-19T00:00:00Z"
194
+ "last_sync": "2026-05-23T00:00:00Z"
195
195
  },
196
196
  "release_notes": {
197
+ "v3.3.0": {
198
+ "major_features": [
199
+ "New tool: generate_harness_bundle — generate a deployment-ready Agentic Harness ZIP for 9 platforms (claude_code, claude_desktop, cursor, copilot, windsurf, cline, zed, replit, openai_agents)",
200
+ "generate_agent_sop now accepts intent_frame parameter (perspective, out_of_scope, success_definition) to sharpen SOP scope and success criteria",
201
+ "Explorer+ tier gate enforced server-side for non-default deploy targets",
202
+ "callBackendAPI now handles binary (ZIP) responses gracefully — skips JSON parse for non-JSON content types",
203
+ "Improved TIER_LIMIT_REACHED error detection with proper error detail stringification"
204
+ ],
205
+ "breaking_changes": [],
206
+ "migration_guide": "No migration required. Both new features are additive and fully optional; existing calls are unaffected."
207
+ },
208
+ "v3.2.3": {
209
+ "major_features": [
210
+ "optimize_prompt now accepts intent_frame parameter for Question Method intent framing",
211
+ "intent_frame.perspective steers optimization toward a specific angle or thesis",
212
+ "intent_frame.out_of_scope excludes topics/approaches from optimization scope",
213
+ "intent_frame.success_definition defines what a successful output achieves",
214
+ "Any non-null intent_frame field floors routing to HYBRID tier minimum for higher-quality optimization",
215
+ "Fixed value_hierarchy passthrough — was sent by client but silently dropped by backend MCP router (now fixed end-to-end)"
216
+ ],
217
+ "breaking_changes": [],
218
+ "migration_guide": "No migration required. intent_frame is fully optional; existing calls are unaffected."
219
+ },
197
220
  "v3.2.2": {
198
221
  "major_features": [
199
222
  "optimize_prompt now accepts value_hierarchy parameter for constraint-driven optimization",