mcp-prompt-optimizer 3.2.3 → 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 +102 -4
  2. package/package.json +13 -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
 
@@ -330,7 +331,17 @@ class MCPPromptOptimizer {
330
331
  properties: {
331
332
  goal: { type: "string", description: "What the agent should accomplish" },
332
333
  context: { type: "string", description: "Additional context (optional)" },
333
- 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
+ }
334
345
  },
335
346
  required: ["goal"]
336
347
  }
@@ -366,6 +377,37 @@ class MCPPromptOptimizer {
366
377
  description: "Check your Context Engineer credit balance and available workflow types.",
367
378
  inputSchema: { type: "object", properties: {}, additionalProperties: false }
368
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
+ },
369
411
  ];
370
412
 
371
413
  // Add advanced tools if Bayesian optimization is enabled
@@ -423,6 +465,7 @@ class MCPPromptOptimizer {
423
465
  case "generate_skill_package": return await this.handleGenerateSkillPackage(args);
424
466
  case "transform_for_framework": return await this.handleTransformForFramework(args);
425
467
  case "get_ce_quota_status": return await this.handleGetCEQuotaStatus();
468
+ case "generate_harness_bundle": return await this.handleGenerateHarnessBundle(args);
426
469
  default: throw new Error(`Unknown tool: ${name}`);
427
470
  }
428
471
  } catch (error) {
@@ -1050,6 +1093,7 @@ class MCPPromptOptimizer {
1050
1093
  const payload = { goal: args.goal };
1051
1094
  if (args.context) payload.context = args.context;
1052
1095
  if (args.model_id) payload.model_id = args.model_id;
1096
+ if (args.intent_frame) payload.intent_frame = args.intent_frame;
1053
1097
  try {
1054
1098
  const result = await this.callBackendAPI(ENDPOINTS.CE.SOP, payload);
1055
1099
  const sopContent = result.sop || result.content || result.result || JSON.stringify(result, null, 2);
@@ -1127,6 +1171,48 @@ class MCPPromptOptimizer {
1127
1171
  }
1128
1172
  }
1129
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
+
1130
1216
  _formatSkillPackage(result) {
1131
1217
  const sections = ['# Skill Package Generated'];
1132
1218
  const artifacts = result.artifacts || result.steps || {};
@@ -1172,13 +1258,25 @@ class MCPPromptOptimizer {
1172
1258
  res.on('end', () => {
1173
1259
  try {
1174
1260
  if (res.statusCode >= 200 && res.statusCode < 300) {
1175
- const parsed = JSON.parse(responseData);
1176
- 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
+ }
1177
1273
  } else {
1178
1274
  let errorMessage;
1179
1275
  try {
1180
1276
  const error = JSON.parse(responseData);
1181
- 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}`);
1182
1280
  } catch {
1183
1281
  errorMessage = `HTTP ${res.statusCode}: ${responseData}`;
1184
1282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-prompt-optimizer",
3
- "version": "3.2.3",
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,20 @@
191
191
  "feature_parity": true,
192
192
  "bayesian_support": true,
193
193
  "agui_support": true,
194
- "last_sync": "2026-05-22T00: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
+ },
197
208
  "v3.2.3": {
198
209
  "major_features": [
199
210
  "optimize_prompt now accepts intent_frame parameter for Question Method intent framing",