mcp-prompt-optimizer 3.0.4 → 3.1.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/README.md +41 -0
  2. package/index.js +156 -3
  3. package/package.json +17 -10
package/README.md CHANGED
@@ -232,6 +232,47 @@ Real-time optimization status and AG-UI capabilities. Requires the feature to be
232
232
 
233
233
  ---
234
234
 
235
+ ## 🤖 Context Engineer (CE) Tools
236
+
237
+ Requires a Creator or Innovator subscription. CE tools generate agentic scaffolding artifacts (SOPs, skill packages, framework code) directly in your IDE.
238
+
239
+ ### `generate_agent_sop`
240
+ Generate a structured SOP document for an AI agent from a goal description. Returns markdown SOP ready for use.
241
+ ```json
242
+ {
243
+ "goal": "What the agent should accomplish",
244
+ "context": "Additional context, constraints, or domain info (optional)",
245
+ "model_id": "Model to use (optional)"
246
+ }
247
+ ```
248
+
249
+ ### `generate_skill_package`
250
+ Generate a complete skill package (SOP + SKILL.md + reference + examples + helper.py) for a given agent goal. Takes 30–90 seconds (async with polling).
251
+ ```json
252
+ {
253
+ "goal": "What the agent should accomplish",
254
+ "format": "knowledge_doc",
255
+ "model_id": "Model to use (optional)"
256
+ }
257
+ ```
258
+ `format` is one of `knowledge_doc` (default) or `agent_spec`.
259
+
260
+ ### `transform_for_framework`
261
+ Transform a SOP into native code for your agent framework: LangChain tool, AutoGen agent, or Claude Code skill.
262
+ ```json
263
+ {
264
+ "sop_content": "The SOP markdown content",
265
+ "goal": "What the agent should accomplish",
266
+ "framework": "langchain_tool"
267
+ }
268
+ ```
269
+ `framework` is one of `langchain_tool`, `autogen_agent`, or `claude_skill`.
270
+
271
+ ### `get_ce_quota_status`
272
+ Check your Context Engineer credit balance and what workflows are available at your tier. No parameters required.
273
+
274
+ ---
275
+
235
276
  ## 🎛️ Advanced Model Configuration (Optional)
236
277
 
237
278
  Configure custom models in the WebUI and the MCP server uses them automatically.
package/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Production-grade with Bayesian optimization, AG-UI real-time features, enhanced network resilience,
6
6
  * development mode, and complete backend alignment
7
7
  *
8
- * Version: 3.0.2 - Aligned with FastAPI Backend production-v2.2.0-stable
8
+ * Version: 3.1.0 - CE tools: generate_agent_sop, generate_skill_package, transform_for_framework, get_ce_quota_status
9
9
  */
10
10
 
11
11
  const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
@@ -53,6 +53,15 @@ const ENDPOINTS = {
53
53
 
54
54
  /** AG‑UI status (GET) */
55
55
  AGUI_STATUS: '/api/status',
56
+
57
+ /** Context Engineer (CE) endpoints */
58
+ CE: {
59
+ SOP: '/api/v1/context-engineer/sop',
60
+ GENERATE_SKILL_PACKAGE: '/api/v1/context-engineer/generate-skill-package',
61
+ SESSION: (id) => `/api/v1/context-engineer/sessions/${id}`,
62
+ TRANSFORM: '/api/v1/context-engineer/transform',
63
+ QUOTA: '/api/v1/context-engineer/quota',
64
+ },
56
65
  };
57
66
 
58
67
  class MCPPromptOptimizer {
@@ -259,6 +268,50 @@ class MCPPromptOptimizer {
259
268
  required: ["prompt"]
260
269
  }
261
270
  },
271
+ {
272
+ name: "generate_agent_sop",
273
+ description: "Generate a structured SOP document for an AI agent from a goal description.",
274
+ inputSchema: {
275
+ type: "object",
276
+ properties: {
277
+ goal: { type: "string", description: "What the agent should accomplish" },
278
+ context: { type: "string", description: "Additional context (optional)" },
279
+ model_id: { type: "string", description: "Model to use (optional)" }
280
+ },
281
+ required: ["goal"]
282
+ }
283
+ },
284
+ {
285
+ name: "generate_skill_package",
286
+ description: "Generate a complete skill package (SOP + SKILL.md + examples + helper.py) for an AI agent. Takes 30-120 seconds (async).",
287
+ inputSchema: {
288
+ type: "object",
289
+ properties: {
290
+ goal: { type: "string", description: "What the agent should accomplish" },
291
+ format: { type: "string", enum: ["knowledge_doc", "agent_spec"], description: "Output format" },
292
+ model_id: { type: "string", description: "Model to use (optional)" }
293
+ },
294
+ required: ["goal"]
295
+ }
296
+ },
297
+ {
298
+ name: "transform_for_framework",
299
+ description: "Transform a SOP into native code for LangChain, AutoGen, or Claude Code.",
300
+ inputSchema: {
301
+ type: "object",
302
+ properties: {
303
+ sop_content: { type: "string", description: "SOP content to transform" },
304
+ goal: { type: "string", description: "What the agent should accomplish" },
305
+ framework: { type: "string", enum: ["langchain_tool", "autogen_agent", "claude_skill"], description: "Target framework" }
306
+ },
307
+ required: ["sop_content", "goal", "framework"]
308
+ }
309
+ },
310
+ {
311
+ name: "get_ce_quota_status",
312
+ description: "Check your Context Engineer credit balance and available workflow types.",
313
+ inputSchema: { type: "object", properties: {}, additionalProperties: false }
314
+ },
262
315
  ];
263
316
 
264
317
  // Add advanced tools if Bayesian optimization is enabled
@@ -311,6 +364,10 @@ class MCPPromptOptimizer {
311
364
  case "update_template": return await this.handleUpdateTemplate(args);
312
365
  case "get_optimization_insights": return await this.handleGetOptimizationInsights(args);
313
366
  case "get_real_time_status": return await this.handleGetRealTimeStatus();
367
+ case "generate_agent_sop": return await this.handleGenerateAgentSop(args);
368
+ case "generate_skill_package": return await this.handleGenerateSkillPackage(args);
369
+ case "transform_for_framework": return await this.handleTransformForFramework(args);
370
+ case "get_ce_quota_status": return await this.handleGetCEQuotaStatus();
314
371
  default: throw new Error(`Unknown tool: ${name}`);
315
372
  }
316
373
  } catch (error) {
@@ -899,7 +956,7 @@ class MCPPromptOptimizer {
899
956
  const { template_id, ...updateData } = args;
900
957
  // Filter out undefined values so we only send fields that are being updated
901
958
  Object.keys(updateData).forEach(key => updateData[key] === undefined && delete updateData[key]);
902
-
959
+
903
960
  const result = await this.callBackendAPI(ENDPOINTS.TEMPLATE.UPDATE(template_id), updateData, 'PATCH'); // PATCH is better for partial updates
904
961
  let output = `# ✅ Template Updated Successfully!\n\n`;
905
962
  output += `**ID:** \`${result.id}\`\n`;
@@ -911,7 +968,103 @@ class MCPPromptOptimizer {
911
968
  }
912
969
  }
913
970
 
914
- async _buildUrl(path) {
971
+ async handleGenerateAgentSop(args) {
972
+ if (!args.goal) throw new Error('goal is required');
973
+ const payload = { goal: args.goal };
974
+ if (args.context) payload.context = args.context;
975
+ if (args.model_id) payload.model_id = args.model_id;
976
+ try {
977
+ const result = await this.callBackendAPI(ENDPOINTS.CE.SOP, payload);
978
+ const sopContent = result.sop || result.content || result.result || JSON.stringify(result, null, 2);
979
+ return { content: [{ type: "text", text: `# Agent SOP Generated\n\n${sopContent}\n\n---\n*Generated by MCP Prompt Optimizer CE*` }] };
980
+ } catch (error) {
981
+ throw new Error(`Failed to generate SOP: ${error.message}`);
982
+ }
983
+ }
984
+
985
+ async handleGenerateSkillPackage(args) {
986
+ if (!args.goal) throw new Error('goal is required');
987
+ const payload = { goal: args.goal, format: args.format || 'knowledge_doc' };
988
+ if (args.model_id) payload.model_id = args.model_id;
989
+ let workflowError = null;
990
+ try {
991
+ const startResult = await this.callBackendAPI(ENDPOINTS.CE.GENERATE_SKILL_PACKAGE, payload);
992
+ const sessionId = startResult.session_id;
993
+ if (!sessionId) {
994
+ return { content: [{ type: "text", text: this._formatSkillPackage(startResult) }] };
995
+ }
996
+ for (let i = 0; i < 24; i++) {
997
+ await new Promise(resolve => setTimeout(resolve, 5000));
998
+ const status = await this.callBackendAPI(ENDPOINTS.CE.SESSION(sessionId), null, 'GET');
999
+ const state = status.workflow_state || status.current_state;
1000
+ if (state === 'complete') return { content: [{ type: "text", text: this._formatSkillPackage(status) }] };
1001
+ if (state === 'failed') {
1002
+ workflowError = new Error(`Generation failed: ${status.error || 'Unknown error'}`);
1003
+ throw workflowError;
1004
+ }
1005
+ }
1006
+ workflowError = new Error(`Timed out after 120s. Session ID: ${sessionId}`);
1007
+ throw workflowError;
1008
+ } catch (error) {
1009
+ if (error === workflowError) throw error;
1010
+ throw new Error(`Failed to generate skill package: ${error.message}`);
1011
+ }
1012
+ }
1013
+
1014
+ async handleTransformForFramework(args) {
1015
+ if (!args.sop_content) throw new Error('sop_content is required');
1016
+ if (!args.goal) throw new Error('goal is required');
1017
+ if (!args.framework) throw new Error('framework is required');
1018
+ const valid = ['langchain_tool', 'autogen_agent', 'claude_skill'];
1019
+ if (!valid.includes(args.framework)) throw new Error(`framework must be one of: ${valid.join(', ')}`);
1020
+ try {
1021
+ const result = await this.callBackendAPI(ENDPOINTS.CE.TRANSFORM, {
1022
+ sop_content: args.sop_content, goal: args.goal, framework: args.framework
1023
+ });
1024
+ const code = result.code || result.content || result.result || JSON.stringify(result, null, 2);
1025
+ return { content: [{ type: "text", text: `# ${args.framework} Implementation\n\n\`\`\`python\n${code}\n\`\`\`\n\n---\n*Transformed by MCP Prompt Optimizer CE*` }] };
1026
+ } catch (error) {
1027
+ throw new Error(`Failed to transform: ${error.message}`);
1028
+ }
1029
+ }
1030
+
1031
+ async handleGetCEQuotaStatus() {
1032
+ try {
1033
+ const result = await this.callBackendAPI(ENDPOINTS.CE.QUOTA, null, 'GET');
1034
+ const lines = ['## CE Credit Balance', ''];
1035
+ if (result.is_unlimited) {
1036
+ lines.push(`Credits: **Unlimited** (${result.credits_used || 0} used this period)`);
1037
+ } else {
1038
+ lines.push(`Credits: **${result.credits_remaining ?? 'N/A'}** of ${result.credits_limit} remaining (${result.credits_used || 0} used)`);
1039
+ }
1040
+ lines.push('', '## Available Workflows');
1041
+ if (result.workflow_availability) {
1042
+ for (const [type, info] of Object.entries(result.workflow_availability)) {
1043
+ lines.push(`- ${info.available ? '✓' : '✗'} ${type}: ${info.cost_credits} credit(s)`);
1044
+ }
1045
+ }
1046
+ if (result.message) lines.push('', result.message);
1047
+ return { content: [{ type: "text", text: lines.join('\n') }] };
1048
+ } catch (error) {
1049
+ throw new Error(`Failed to get CE quota: ${error.message}`);
1050
+ }
1051
+ }
1052
+
1053
+ _formatSkillPackage(result) {
1054
+ const sections = ['# Skill Package Generated'];
1055
+ const artifacts = result.artifacts || result.steps || {};
1056
+ if (typeof artifacts === 'object' && Object.keys(artifacts).length > 0) {
1057
+ for (const [key, value] of Object.entries(artifacts)) {
1058
+ if (value && typeof value === 'string') sections.push(`\n## ${key}\n\n${value}`);
1059
+ }
1060
+ } else {
1061
+ sections.push('\n```json\n' + JSON.stringify(result, null, 2) + '\n```');
1062
+ }
1063
+ sections.push('\n---\n*Generated by MCP Prompt Optimizer CE*');
1064
+ return sections.join('\n');
1065
+ }
1066
+
1067
+ _buildUrl(path) {
915
1068
  return `${this.backendUrl}${path}`;
916
1069
  }
917
1070
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-prompt-optimizer",
3
- "version": "3.0.4",
3
+ "version": "3.1.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": {
@@ -99,13 +99,13 @@
99
99
  "parameter-tuning",
100
100
  "optimization-strategies"
101
101
  ],
102
- "author": "Prompt Optimizer Team <support@promptoptimizer.help>",
102
+ "author": "Prompt Optimizer Team <support@promptoptimizer.xyz>",
103
103
  "license": "SEE LICENSE IN LICENSE",
104
104
  "repository": {
105
105
  "type": "git",
106
106
  "url": "git+https://github.com/prompt-optimizer/mcp-prompt-optimizer.git"
107
107
  },
108
- "homepage": "https://promptoptimizer-blog.vercel.app",
108
+ "homepage": "https://promptoptimizer.xyz",
109
109
  "bugs": {
110
110
  "url": "https://github.com/prompt-optimizer/mcp-prompt-optimizer/issues"
111
111
  },
@@ -157,7 +157,7 @@
157
157
  {
158
158
  "name": "OPTIMIZER_API_KEY",
159
159
  "format": "sk-opt-*, sk-team-*, sk-dev-*, or sk-local-*",
160
- "description": "Cloud API key from promptoptimizer-blog.vercel.app/pricing or development key for testing",
160
+ "description": "Cloud API key from promptoptimizer.xyz/pricing or development key for testing",
161
161
  "required": true
162
162
  }
163
163
  ],
@@ -224,10 +224,17 @@
224
224
  "feature_parity": true,
225
225
  "bayesian_support": true,
226
226
  "agui_support": true,
227
- "last_sync": "2026-03-09T00:00:00Z"
227
+ "last_sync": "2026-03-13T00:00:00Z"
228
228
  },
229
229
  "release_notes": {
230
- "v1.5.0": {
230
+ "v3.0.5": {
231
+ "major_features": [
232
+ "Updated homepage and support links to promptoptimizer.xyz"
233
+ ],
234
+ "breaking_changes": [],
235
+ "migration_guide": "No migration required. Drop-in replacement for v3.0.4."
236
+ },
237
+ "v3.0.4": {
231
238
  "major_features": [
232
239
  "Bayesian optimization with parameter tuning",
233
240
  "AG-UI real-time optimization capabilities",
@@ -240,9 +247,9 @@
240
247
  }
241
248
  },
242
249
  "support": {
243
- "email": "support@promptoptimizer.help",
244
- "documentation": "https://promptoptimizer-blog.vercel.app/docs",
245
- "dashboard": "https://promptoptimizer-blog.vercel.app/dashboard",
246
- "pricing": "https://promptoptimizer-blog.vercel.app/pricing"
250
+ "email": "support@promptoptimizer.xyz",
251
+ "documentation": "https://promptoptimizer.xyz/docs",
252
+ "dashboard": "https://promptoptimizer.xyz/dashboard",
253
+ "pricing": "https://promptoptimizer.xyz/pricing"
247
254
  }
248
255
  }