mcp-prompt-optimizer 3.2.3 → 3.4.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 (3) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/index.js +244 -4
  3. package/package.json +13 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.4.0] - 2026-05-26
9
+
10
+ ### Added
11
+ - `explore_sop_approaches` tool: generates 3 parallel SOP variants (process-oriented, decision-tree, role-based) for comparison. Optionally accepts `blend_description` to blend variants directly into a single SOP. Innovator tier required.
12
+
8
13
  ## [3.1.3] - 2026-04-13
9
14
 
10
15
  ### Changed
package/index.js CHANGED
@@ -64,9 +64,18 @@ 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',
68
+ SOP_EXPLORE: '/api/v1/context-engineer/sop-explore',
69
+ SOP_BLEND: '/api/v1/context-engineer/sop-blend',
67
70
  },
68
71
  };
69
72
 
73
+ const DEPLOY_TARGET_ENUM = [
74
+ "claude_code", "claude_desktop", "cursor", "copilot",
75
+ "windsurf", "cline", "zed", "replit", "openai_agents", "ollama",
76
+ "amazon_q", "aider", "continue_dev", "crewai"
77
+ ];
78
+
70
79
  class MCPPromptOptimizer {
71
80
  constructor() {
72
81
  this.server = new Server(
@@ -330,7 +339,17 @@ class MCPPromptOptimizer {
330
339
  properties: {
331
340
  goal: { type: "string", description: "What the agent should accomplish" },
332
341
  context: { type: "string", description: "Additional context (optional)" },
333
- model_id: { type: "string", description: "Model to use (optional)" }
342
+ model_id: { type: "string", description: "Model to use (optional)" },
343
+ intent_frame: {
344
+ type: "object",
345
+ description: "Optional IntentFrame to sharpen SOP scope and success criteria.",
346
+ properties: {
347
+ perspective: { type: "string", description: "The agent role or viewpoint (e.g. DevOps engineer)." },
348
+ out_of_scope: { type: "string", description: "What is explicitly excluded from this workflow." },
349
+ success_definition: { type: "string", description: "Measurable criteria that define success." }
350
+ },
351
+ additionalProperties: false
352
+ }
334
353
  },
335
354
  required: ["goal"]
336
355
  }
@@ -366,6 +385,86 @@ class MCPPromptOptimizer {
366
385
  description: "Check your Context Engineer credit balance and available workflow types.",
367
386
  inputSchema: { type: "object", properties: {}, additionalProperties: false }
368
387
  },
388
+ {
389
+ name: "generate_harness_bundle",
390
+ description: (
391
+ "Generate a deployment-ready Agentic Harness ZIP bundle for a specific platform. "
392
+ + "Returns a confirmation message when the bundle is queued. "
393
+ + "Explorer+ required for non-default deploy targets."
394
+ ),
395
+ inputSchema: {
396
+ type: "object",
397
+ properties: {
398
+ goal: {
399
+ type: "string",
400
+ description: "The workflow goal the harness is built for."
401
+ },
402
+ deploy_target: {
403
+ oneOf: [
404
+ {
405
+ type: "string",
406
+ enum: DEPLOY_TARGET_ENUM,
407
+ description: "Single deploy target."
408
+ },
409
+ {
410
+ type: "array",
411
+ minItems: 1,
412
+ items: {
413
+ type: "string",
414
+ enum: DEPLOY_TARGET_ENUM
415
+ },
416
+ description: "Multiple deploy targets simultaneously (Creator+ required)."
417
+ }
418
+ ],
419
+ description: (
420
+ "Target deployment platform(s). Single string (Explorer+) or array (Creator+). "
421
+ + "amazon_q, aider, continue_dev, crewai require Creator+. "
422
+ + "Default: claude_code."
423
+ )
424
+ },
425
+ session_id: {
426
+ type: "string",
427
+ description: "Optional: session ID from a prior generate_skill_package call to reuse SOP."
428
+ },
429
+ sop_content: {
430
+ type: "string",
431
+ description: "The SOP content to base the harness on (required if no session_id)."
432
+ }
433
+ },
434
+ required: ["goal"]
435
+ }
436
+ },
437
+ {
438
+ name: "explore_sop_approaches",
439
+ description: (
440
+ "Generate 3 parallel SOP variants (process-oriented, decision-tree, role-based) for comparison before committing. " +
441
+ "Returns exploration_html (self-contained comparison grid), variants array, and a recommended variant. " +
442
+ "Innovator tier required. " +
443
+ "Optionally provide blend_description to skip comparison and receive a single blended SOP instead."
444
+ ),
445
+ inputSchema: {
446
+ type: "object",
447
+ properties: {
448
+ goal: {
449
+ type: "string",
450
+ description: "The workflow goal to generate SOP variants for"
451
+ },
452
+ context: {
453
+ type: "string",
454
+ description: "Optional background context or documentation excerpt"
455
+ },
456
+ blend_description: {
457
+ type: "string",
458
+ description: "Optional: if provided, skips variant comparison and blends all 3 into one SOP using this description"
459
+ },
460
+ perspective: { type: "string", description: "Agent role or viewpoint (IntentFrame)" },
461
+ out_of_scope: { type: "string", description: "What is explicitly excluded (IntentFrame)" },
462
+ success_definition: { type: "string", description: "Measurable success criteria (IntentFrame)" },
463
+ },
464
+ required: ["goal"],
465
+ additionalProperties: false
466
+ }
467
+ },
369
468
  ];
370
469
 
371
470
  // Add advanced tools if Bayesian optimization is enabled
@@ -423,6 +522,8 @@ class MCPPromptOptimizer {
423
522
  case "generate_skill_package": return await this.handleGenerateSkillPackage(args);
424
523
  case "transform_for_framework": return await this.handleTransformForFramework(args);
425
524
  case "get_ce_quota_status": return await this.handleGetCEQuotaStatus();
525
+ case "generate_harness_bundle": return await this.handleGenerateHarnessBundle(args);
526
+ case "explore_sop_approaches": return await this.handleExploreSopApproaches(args);
426
527
  default: throw new Error(`Unknown tool: ${name}`);
427
528
  }
428
529
  } catch (error) {
@@ -1050,6 +1151,7 @@ class MCPPromptOptimizer {
1050
1151
  const payload = { goal: args.goal };
1051
1152
  if (args.context) payload.context = args.context;
1052
1153
  if (args.model_id) payload.model_id = args.model_id;
1154
+ if (args.intent_frame) payload.intent_frame = args.intent_frame;
1053
1155
  try {
1054
1156
  const result = await this.callBackendAPI(ENDPOINTS.CE.SOP, payload);
1055
1157
  const sopContent = result.sop || result.content || result.result || JSON.stringify(result, null, 2);
@@ -1127,6 +1229,132 @@ class MCPPromptOptimizer {
1127
1229
  }
1128
1230
  }
1129
1231
 
1232
+ async handleGenerateHarnessBundle(args) {
1233
+ if (!args.sop_content && !args.session_id) {
1234
+ return { content: [{ type: "text", text: "Error: provide either sop_content or session_id." }] };
1235
+ }
1236
+ // Normalize deploy_target: string → [string], array → array, undefined → ["claude_code"]
1237
+ let deployTargets;
1238
+ if (!args.deploy_target) {
1239
+ deployTargets = ["claude_code"];
1240
+ } else if (Array.isArray(args.deploy_target)) {
1241
+ deployTargets = args.deploy_target;
1242
+ } else {
1243
+ deployTargets = [args.deploy_target];
1244
+ }
1245
+ // Guard: empty array falls back to default
1246
+ if (deployTargets.length === 0) {
1247
+ deployTargets = ["claude_code"];
1248
+ }
1249
+
1250
+ const payload = {
1251
+ goal: args.goal,
1252
+ deploy_target: deployTargets.length === 1 ? deployTargets[0] : deployTargets,
1253
+ platform: deployTargets[0],
1254
+ user_goal: args.goal,
1255
+ sop_content: args.sop_content || "",
1256
+ };
1257
+
1258
+ // If session_id provided, first fetch session artifacts for sop_content
1259
+ if (args.session_id) {
1260
+ try {
1261
+ const status = await this.callBackendAPI(ENDPOINTS.CE.SESSION(args.session_id), null, "GET");
1262
+ const sop = status.artifacts?.sop_content || status.sop_content || "";
1263
+ if (sop) payload.sop_content = sop;
1264
+ } catch (sessionErr) {
1265
+ console.error(`[handleGenerateHarnessBundle] Could not fetch session ${args.session_id}:`, sessionErr.message || sessionErr);
1266
+ // Proceed with empty sop_content; backend will handle gracefully
1267
+ }
1268
+ }
1269
+
1270
+ try {
1271
+ await this.callBackendAPI(ENDPOINTS.CE.HARNESS_BUNDLE, payload);
1272
+ return {
1273
+ content: [{
1274
+ type: "text",
1275
+ text: `# Harness Bundle Requested\n\nDeploy target: **${deployTargets.join(", ")}**\nGoal: ${args.goal}\n\nDownload from the CE dashboard or via the /harness-bundle API endpoint.`
1276
+ }]
1277
+ };
1278
+ } catch (error) {
1279
+ const msg = error?.message || String(error);
1280
+ if (msg.includes("TIER_LIMIT_REACHED")) {
1281
+ const CREATOR_ONLY = ["amazon_q", "aider", "continue_dev", "crewai"];
1282
+ const needsCreator =
1283
+ msg.includes("creator") ||
1284
+ deployTargets.length > 1 ||
1285
+ CREATOR_ONLY.some(t => deployTargets.includes(t));
1286
+ const tierNeeded = needsCreator ? "Creator" : "Explorer";
1287
+ return { content: [{ type: "text",
1288
+ text: `Upgrade required: this deploy target requires ${tierNeeded} tier or higher. Upgrade at /pricing.`
1289
+ }] };
1290
+ }
1291
+ throw error;
1292
+ }
1293
+ }
1294
+
1295
+ async handleExploreSopApproaches(args) {
1296
+ if (!args.goal) {
1297
+ return { content: [{ type: "text", text: "Error: goal is required." }] };
1298
+ }
1299
+
1300
+ // If blend_description provided, explore then blend in one call chain
1301
+ if (args.blend_description) {
1302
+ try {
1303
+ const explorePayload = {
1304
+ goal: args.goal,
1305
+ context: args.context || undefined,
1306
+ perspective: args.perspective || undefined,
1307
+ out_of_scope: args.out_of_scope || undefined,
1308
+ success_definition: args.success_definition || undefined,
1309
+ };
1310
+ const exploreResult = await this.callBackendAPI(ENDPOINTS.CE.SOP_EXPLORE, explorePayload);
1311
+ const blendPayload = {
1312
+ variants: exploreResult.variants,
1313
+ blend_description: args.blend_description,
1314
+ goal: args.goal,
1315
+ };
1316
+ const blendResult = await this.callBackendAPI(ENDPOINTS.CE.SOP_BLEND, blendPayload);
1317
+ return {
1318
+ content: [{
1319
+ type: "text",
1320
+ text: `# Blended SOP\n\n${blendResult.sop_content}`
1321
+ }]
1322
+ };
1323
+ } catch (error) {
1324
+ throw new Error(`Failed to blend SOP approaches: ${error.message}`);
1325
+ }
1326
+ }
1327
+
1328
+ // Standard exploration: return 3 variant summaries
1329
+ try {
1330
+ const payload = {
1331
+ goal: args.goal,
1332
+ context: args.context || undefined,
1333
+ perspective: args.perspective || undefined,
1334
+ out_of_scope: args.out_of_scope || undefined,
1335
+ success_definition: args.success_definition || undefined,
1336
+ };
1337
+ const result = await this.callBackendAPI(ENDPOINTS.CE.SOP_EXPLORE, payload);
1338
+
1339
+ const variantSummaries = result.variants.map(v => {
1340
+ const rec = v.id === result.recommended ? " *(Recommended)*" : "";
1341
+ return `## Variant ${v.id} — ${v.approach.replace('_', '-')}${rec}\n\n${v.content.slice(0, 600)}${v.content.length > 600 ? '\n\n...(truncated)' : ''}`;
1342
+ }).join('\n\n---\n\n');
1343
+
1344
+ return {
1345
+ content: [{
1346
+ type: "text",
1347
+ text: `# SOP Exploration Results\n\n**Goal:** ${args.goal}\n**Recommended:** Variant ${result.recommended}\n\n---\n\n${variantSummaries}\n\n---\n\n*To select a variant, call generate_skill_package with the full content of your chosen variant as sop_content. To blend variants, re-call explore_sop_approaches with blend_description.*`
1348
+ }]
1349
+ };
1350
+ } catch (error) {
1351
+ if (error.message && error.message.includes('403')) {
1352
+ return { content: [{ type: "text", text: "Error: SOP exploration requires Innovator tier. Upgrade at /pricing." }] };
1353
+ }
1354
+ throw new Error(`Failed to explore SOP approaches: ${error.message}`);
1355
+ }
1356
+ }
1357
+
1130
1358
  _formatSkillPackage(result) {
1131
1359
  const sections = ['# Skill Package Generated'];
1132
1360
  const artifacts = result.artifacts || result.steps || {};
@@ -1172,13 +1400,25 @@ class MCPPromptOptimizer {
1172
1400
  res.on('end', () => {
1173
1401
  try {
1174
1402
  if (res.statusCode >= 200 && res.statusCode < 300) {
1175
- const parsed = JSON.parse(responseData);
1176
- resolve(parsed);
1403
+ const contentType = res.headers['content-type'] || '';
1404
+ if (contentType.includes('application/json') || contentType === '') {
1405
+ try {
1406
+ const parsed = JSON.parse(responseData);
1407
+ resolve(parsed);
1408
+ } catch (e) {
1409
+ reject(new Error(`Invalid response format: ${e.message}`));
1410
+ }
1411
+ } else {
1412
+ // Binary or non-JSON response (e.g., application/zip) — return metadata
1413
+ resolve({ _binary: true, contentType, size: responseData.length });
1414
+ }
1177
1415
  } else {
1178
1416
  let errorMessage;
1179
1417
  try {
1180
1418
  const error = JSON.parse(responseData);
1181
- errorMessage = error.detail || error.message || `HTTP ${res.statusCode}`;
1419
+ errorMessage = (typeof error.detail === 'object' && error.detail !== null)
1420
+ ? JSON.stringify(error.detail)
1421
+ : (error.detail || error.message || `HTTP ${res.statusCode}`);
1182
1422
  } catch {
1183
1423
  errorMessage = `HTTP ${res.statusCode}: ${responseData}`;
1184
1424
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-prompt-optimizer",
3
- "version": "3.2.3",
3
+ "version": "3.4.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",