mcp-image 0.1.0 → 0.2.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 (178) hide show
  1. package/README.md +41 -17
  2. package/dist/api/geminiClient.d.ts +2 -12
  3. package/dist/api/geminiClient.d.ts.map +1 -1
  4. package/dist/api/geminiClient.js +28 -56
  5. package/dist/api/geminiClient.js.map +1 -1
  6. package/dist/api/geminiTextClient.d.ts +42 -0
  7. package/dist/api/geminiTextClient.d.ts.map +1 -0
  8. package/dist/api/geminiTextClient.js +198 -0
  9. package/dist/api/geminiTextClient.js.map +1 -0
  10. package/dist/business/__tests__/mocks/mcpSamplingClient.mock.d.ts +84 -0
  11. package/dist/business/__tests__/mocks/mcpSamplingClient.mock.d.ts.map +1 -0
  12. package/dist/business/__tests__/mocks/mcpSamplingClient.mock.js +100 -0
  13. package/dist/business/__tests__/mocks/mcpSamplingClient.mock.js.map +1 -0
  14. package/dist/business/bestPracticesEngine.d.ts +149 -0
  15. package/dist/business/bestPracticesEngine.d.ts.map +1 -0
  16. package/dist/business/bestPracticesEngine.js +781 -0
  17. package/dist/business/bestPracticesEngine.js.map +1 -0
  18. package/dist/business/complexityAssessment.d.ts +132 -0
  19. package/dist/business/complexityAssessment.d.ts.map +1 -0
  20. package/dist/business/complexityAssessment.js +488 -0
  21. package/dist/business/complexityAssessment.js.map +1 -0
  22. package/dist/business/fallbackStrategies.d.ts +177 -0
  23. package/dist/business/fallbackStrategies.d.ts.map +1 -0
  24. package/dist/business/fallbackStrategies.js +368 -0
  25. package/dist/business/fallbackStrategies.js.map +1 -0
  26. package/dist/business/imageGenerator.d.ts.map +1 -1
  27. package/dist/business/imageGenerator.js +26 -5
  28. package/dist/business/imageGenerator.js.map +1 -1
  29. package/dist/business/multiImage/aspectRatioController.d.ts +77 -0
  30. package/dist/business/multiImage/aspectRatioController.d.ts.map +1 -0
  31. package/dist/business/multiImage/aspectRatioController.js +580 -0
  32. package/dist/business/multiImage/aspectRatioController.js.map +1 -0
  33. package/dist/business/multiImage/multiImageCoordinator.d.ts +142 -0
  34. package/dist/business/multiImage/multiImageCoordinator.d.ts.map +1 -0
  35. package/dist/business/multiImage/multiImageCoordinator.js +801 -0
  36. package/dist/business/multiImage/multiImageCoordinator.js.map +1 -0
  37. package/dist/business/pomlTemplateEngine.d.ts +206 -0
  38. package/dist/business/pomlTemplateEngine.d.ts.map +1 -0
  39. package/dist/business/pomlTemplateEngine.js +737 -0
  40. package/dist/business/pomlTemplateEngine.js.map +1 -0
  41. package/dist/business/promptOrchestrator.d.ts +173 -0
  42. package/dist/business/promptOrchestrator.d.ts.map +1 -0
  43. package/dist/business/promptOrchestrator.js +490 -0
  44. package/dist/business/promptOrchestrator.js.map +1 -0
  45. package/dist/business/responseBuilder.d.ts +2 -2
  46. package/dist/business/responseBuilder.d.ts.map +1 -1
  47. package/dist/business/responseBuilder.js +6 -1
  48. package/dist/business/responseBuilder.js.map +1 -1
  49. package/dist/business/structuredPromptGenerator.d.ts +54 -0
  50. package/dist/business/structuredPromptGenerator.d.ts.map +1 -0
  51. package/dist/business/structuredPromptGenerator.js +208 -0
  52. package/dist/business/structuredPromptGenerator.js.map +1 -0
  53. package/dist/business/templateNormalizer.d.ts +81 -0
  54. package/dist/business/templateNormalizer.d.ts.map +1 -0
  55. package/dist/business/templateNormalizer.js +659 -0
  56. package/dist/business/templateNormalizer.js.map +1 -0
  57. package/dist/documentation/apiContractValidation.d.ts +62 -0
  58. package/dist/documentation/apiContractValidation.d.ts.map +1 -0
  59. package/dist/documentation/apiContractValidation.js +305 -0
  60. package/dist/documentation/apiContractValidation.js.map +1 -0
  61. package/dist/infrastructure/concurrency/concurrencyManager.d.ts +101 -0
  62. package/dist/infrastructure/concurrency/concurrencyManager.d.ts.map +1 -0
  63. package/dist/infrastructure/concurrency/concurrencyManager.js +345 -0
  64. package/dist/infrastructure/concurrency/concurrencyManager.js.map +1 -0
  65. package/dist/infrastructure/config/secureConfigManager.d.ts +319 -0
  66. package/dist/infrastructure/config/secureConfigManager.d.ts.map +1 -0
  67. package/dist/infrastructure/config/secureConfigManager.js +600 -0
  68. package/dist/infrastructure/config/secureConfigManager.js.map +1 -0
  69. package/dist/infrastructure/errorHandling/orchestrationErrorHandler.d.ts +229 -0
  70. package/dist/infrastructure/errorHandling/orchestrationErrorHandler.d.ts.map +1 -0
  71. package/dist/infrastructure/errorHandling/orchestrationErrorHandler.js +61 -0
  72. package/dist/infrastructure/errorHandling/orchestrationErrorHandler.js.map +1 -0
  73. package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.d.ts +133 -0
  74. package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.d.ts.map +1 -0
  75. package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.js +569 -0
  76. package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.js.map +1 -0
  77. package/dist/infrastructure/mcp/MCPSamplingClient.d.ts +19 -0
  78. package/dist/infrastructure/mcp/MCPSamplingClient.d.ts.map +1 -0
  79. package/dist/infrastructure/mcp/MCPSamplingClient.js +31 -0
  80. package/dist/infrastructure/mcp/MCPSamplingClient.js.map +1 -0
  81. package/dist/infrastructure/mcp/RealMCPSamplingClient.d.ts +59 -0
  82. package/dist/infrastructure/mcp/RealMCPSamplingClient.d.ts.map +1 -0
  83. package/dist/infrastructure/mcp/RealMCPSamplingClient.js +271 -0
  84. package/dist/infrastructure/mcp/RealMCPSamplingClient.js.map +1 -0
  85. package/dist/infrastructure/metadata/generationMetadata.d.ts +72 -0
  86. package/dist/infrastructure/metadata/generationMetadata.d.ts.map +1 -0
  87. package/dist/infrastructure/metadata/generationMetadata.js +228 -0
  88. package/dist/infrastructure/metadata/generationMetadata.js.map +1 -0
  89. package/dist/infrastructure/monitoring/OrchestrationMetrics.d.ts +106 -0
  90. package/dist/infrastructure/monitoring/OrchestrationMetrics.d.ts.map +1 -0
  91. package/dist/infrastructure/monitoring/OrchestrationMetrics.js +456 -0
  92. package/dist/infrastructure/monitoring/OrchestrationMetrics.js.map +1 -0
  93. package/dist/infrastructure/monitoring/alertingSystem.d.ts +135 -0
  94. package/dist/infrastructure/monitoring/alertingSystem.d.ts.map +1 -0
  95. package/dist/infrastructure/monitoring/alertingSystem.js +549 -0
  96. package/dist/infrastructure/monitoring/alertingSystem.js.map +1 -0
  97. package/dist/infrastructure/optimization/performanceOptimizer.d.ts +89 -0
  98. package/dist/infrastructure/optimization/performanceOptimizer.d.ts.map +1 -0
  99. package/dist/infrastructure/optimization/performanceOptimizer.js +375 -0
  100. package/dist/infrastructure/optimization/performanceOptimizer.js.map +1 -0
  101. package/dist/infrastructure/security/AdvancedContentFilter.d.ts +99 -0
  102. package/dist/infrastructure/security/AdvancedContentFilter.d.ts.map +1 -0
  103. package/dist/infrastructure/security/AdvancedContentFilter.js +363 -0
  104. package/dist/infrastructure/security/AdvancedContentFilter.js.map +1 -0
  105. package/dist/infrastructure/security/MCPSecurityValidator.d.ts +62 -0
  106. package/dist/infrastructure/security/MCPSecurityValidator.d.ts.map +1 -0
  107. package/dist/infrastructure/security/MCPSecurityValidator.js +129 -0
  108. package/dist/infrastructure/security/MCPSecurityValidator.js.map +1 -0
  109. package/dist/infrastructure/security/OrchestrationSecurityMiddleware.d.ts +304 -0
  110. package/dist/infrastructure/security/OrchestrationSecurityMiddleware.d.ts.map +1 -0
  111. package/dist/infrastructure/security/OrchestrationSecurityMiddleware.js +61 -0
  112. package/dist/infrastructure/security/OrchestrationSecurityMiddleware.js.map +1 -0
  113. package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.d.ts +62 -0
  114. package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.d.ts.map +1 -0
  115. package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.js +591 -0
  116. package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.js.map +1 -0
  117. package/dist/infrastructure/security/SecureMCPClient.d.ts +154 -0
  118. package/dist/infrastructure/security/SecureMCPClient.d.ts.map +1 -0
  119. package/dist/infrastructure/security/SecureMCPClient.js +292 -0
  120. package/dist/infrastructure/security/SecureMCPClient.js.map +1 -0
  121. package/dist/infrastructure/security/SecurityIncidentManager.d.ts +142 -0
  122. package/dist/infrastructure/security/SecurityIncidentManager.d.ts.map +1 -0
  123. package/dist/infrastructure/security/SecurityIncidentManager.js +260 -0
  124. package/dist/infrastructure/security/SecurityIncidentManager.js.map +1 -0
  125. package/dist/infrastructure/security/apiKeyManager.d.ts +297 -0
  126. package/dist/infrastructure/security/apiKeyManager.d.ts.map +1 -0
  127. package/dist/infrastructure/security/apiKeyManager.js +254 -0
  128. package/dist/infrastructure/security/apiKeyManager.js.map +1 -0
  129. package/dist/infrastructure/security/dataSanitizer.d.ts +157 -0
  130. package/dist/infrastructure/security/dataSanitizer.d.ts.map +1 -0
  131. package/dist/infrastructure/security/dataSanitizer.js +525 -0
  132. package/dist/infrastructure/security/dataSanitizer.js.map +1 -0
  133. package/dist/infrastructure/validation/inputValidator.d.ts +54 -0
  134. package/dist/infrastructure/validation/inputValidator.d.ts.map +1 -0
  135. package/dist/infrastructure/validation/inputValidator.js +362 -0
  136. package/dist/infrastructure/validation/inputValidator.js.map +1 -0
  137. package/dist/integration/parameterOptimizer.d.ts +69 -0
  138. package/dist/integration/parameterOptimizer.d.ts.map +1 -0
  139. package/dist/integration/parameterOptimizer.js +317 -0
  140. package/dist/integration/parameterOptimizer.js.map +1 -0
  141. package/dist/integration/twoStageProcessor.d.ts +66 -0
  142. package/dist/integration/twoStageProcessor.d.ts.map +1 -0
  143. package/dist/integration/twoStageProcessor.js +348 -0
  144. package/dist/integration/twoStageProcessor.js.map +1 -0
  145. package/dist/server/handlers/structuredPromptHandler.d.ts +65 -0
  146. package/dist/server/handlers/structuredPromptHandler.d.ts.map +1 -0
  147. package/dist/server/handlers/structuredPromptHandler.js +314 -0
  148. package/dist/server/handlers/structuredPromptHandler.js.map +1 -0
  149. package/dist/server/mcpServer.d.ts +16 -35
  150. package/dist/server/mcpServer.d.ts.map +1 -1
  151. package/dist/server/mcpServer.js +111 -150
  152. package/dist/server/mcpServer.js.map +1 -1
  153. package/dist/server/mcpServerWithOrchestration.d.ts +98 -0
  154. package/dist/server/mcpServerWithOrchestration.d.ts.map +1 -0
  155. package/dist/server/mcpServerWithOrchestration.js +284 -0
  156. package/dist/server/mcpServerWithOrchestration.js.map +1 -0
  157. package/dist/types/mcpOrchestrationTypes.d.ts +135 -0
  158. package/dist/types/mcpOrchestrationTypes.d.ts.map +1 -0
  159. package/dist/types/mcpOrchestrationTypes.js +28 -0
  160. package/dist/types/mcpOrchestrationTypes.js.map +1 -0
  161. package/dist/types/multiImageTypes.d.ts +328 -0
  162. package/dist/types/multiImageTypes.d.ts.map +1 -0
  163. package/dist/types/multiImageTypes.js +27 -0
  164. package/dist/types/multiImageTypes.js.map +1 -0
  165. package/dist/types/performanceTypes.d.ts +300 -0
  166. package/dist/types/performanceTypes.d.ts.map +1 -0
  167. package/dist/types/performanceTypes.js +50 -0
  168. package/dist/types/performanceTypes.js.map +1 -0
  169. package/dist/types/twoStageTypes.d.ts +123 -0
  170. package/dist/types/twoStageTypes.d.ts.map +1 -0
  171. package/dist/types/twoStageTypes.js +7 -0
  172. package/dist/types/twoStageTypes.js.map +1 -0
  173. package/dist/utils/config.d.ts +1 -0
  174. package/dist/utils/config.d.ts.map +1 -1
  175. package/dist/utils/config.js +1 -0
  176. package/dist/utils/config.js.map +1 -1
  177. package/package.json +11 -4
  178. package/vitest.config.mjs +0 -47
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
3
  * MCP Server implementation
4
- * Basic structure of MCP server using @modelcontextprotocol/sdk
4
+ * Simplified architecture with direct Gemini integration
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
@@ -39,22 +39,22 @@ var __importStar = (this && this.__importStar) || (function () {
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.MCPServerImpl = void 0;
41
41
  exports.createMCPServer = createMCPServer;
42
- // External libraries
42
+ const fs = __importStar(require("node:fs/promises"));
43
43
  const path = __importStar(require("node:path"));
44
44
  const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
45
45
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
46
46
  // Business logic
47
47
  const fileManager_1 = require("../business/fileManager");
48
- const imageGenerator_1 = require("../business/imageGenerator");
49
48
  const inputValidator_1 = require("../business/inputValidator");
50
49
  const responseBuilder_1 = require("../business/responseBuilder");
50
+ const structuredPromptGenerator_1 = require("../business/structuredPromptGenerator");
51
51
  // API clients
52
52
  const geminiClient_1 = require("../api/geminiClient");
53
+ const geminiTextClient_1 = require("../api/geminiTextClient");
53
54
  // Utilities
54
55
  const config_1 = require("../utils/config");
55
56
  const logger_1 = require("../utils/logger");
56
57
  const security_1 = require("../utils/security");
57
- // Same module
58
58
  const errorHandler_1 = require("./errorHandler");
59
59
  /**
60
60
  * Default MCP server configuration
@@ -65,57 +65,22 @@ const DEFAULT_CONFIG = {
65
65
  defaultOutputDir: './output',
66
66
  };
67
67
  /**
68
- * Basic MCP server structure
69
- * Simple implementation focusing on testability
68
+ * Simplified MCP server
70
69
  */
71
70
  class MCPServerImpl {
72
- constructor(config = {}, dependencies = {}) {
71
+ constructor(config = {}) {
73
72
  this.server = null;
73
+ this.structuredPromptGenerator = null;
74
+ this.geminiTextClient = null;
75
+ this.geminiClient = null;
74
76
  this.config = { ...DEFAULT_CONFIG, ...config };
75
- this.logger = dependencies.logger || new logger_1.Logger();
76
- this.fileManager = dependencies.fileManager || (0, fileManager_1.createFileManager)();
77
- this.responseBuilder = dependencies.responseBuilder || (0, responseBuilder_1.createResponseBuilder)();
78
- this.securityManager = dependencies.securityManager || new security_1.SecurityManager();
79
- this.createImageGeneratorFn = dependencies.createImageGenerator || imageGenerator_1.createImageGenerator;
77
+ this.logger = new logger_1.Logger();
78
+ this.fileManager = (0, fileManager_1.createFileManager)();
79
+ this.responseBuilder = (0, responseBuilder_1.createResponseBuilder)();
80
+ this.securityManager = new security_1.SecurityManager();
80
81
  }
81
82
  /**
82
- * Send progress notification to client
83
- */
84
- async sendProgress(progressToken, progress, total, message) {
85
- if (!this.server || !progressToken)
86
- return;
87
- try {
88
- await this.server.notification({
89
- method: 'notifications/progress',
90
- params: {
91
- progressToken,
92
- progress,
93
- ...(total !== undefined && { total }),
94
- ...(message && { message }),
95
- },
96
- });
97
- this.logger.debug('mcp-progress', 'Progress notification sent', {
98
- progressToken,
99
- progress,
100
- total,
101
- message,
102
- });
103
- }
104
- catch (error) {
105
- this.logger.warn('mcp-progress', 'Failed to send progress notification', {
106
- progressToken,
107
- error: error.message,
108
- });
109
- }
110
- }
111
- /**
112
- * Get server instance (for testing)
113
- */
114
- getServerInstance() {
115
- return this.server;
116
- }
117
- /**
118
- * Get server information
83
+ * Get server info
119
84
  */
120
85
  getServerInfo() {
121
86
  return {
@@ -137,7 +102,7 @@ class MCPServerImpl {
137
102
  properties: {
138
103
  prompt: {
139
104
  type: 'string',
140
- description: 'The prompt for image generation',
105
+ description: 'The prompt for image generation (English recommended for optimal structured prompt enhancement)',
141
106
  },
142
107
  fileName: {
143
108
  type: 'string',
@@ -167,137 +132,136 @@ class MCPServerImpl {
167
132
  };
168
133
  }
169
134
  /**
170
- * Tool execution with unified error handling
135
+ * Tool execution
171
136
  */
172
- async callTool(name, args, progressToken) {
137
+ async callTool(name, args) {
173
138
  try {
174
139
  if (name === 'generate_image') {
175
- return await this.handleGenerateImage(args, progressToken);
140
+ return await this.handleGenerateImage(args);
176
141
  }
177
142
  throw new Error(`Unknown tool: ${name}`);
178
143
  }
179
144
  catch (error) {
180
- this.logger.error('mcp-server', 'Tool execution failed', error, {
181
- toolName: name,
182
- args,
183
- });
145
+ this.logger.error('mcp-server', 'Tool execution failed', error);
184
146
  return errorHandler_1.ErrorHandler.handleError(error);
185
147
  }
186
148
  }
187
149
  /**
188
- * Image generation tool handler with proper error handling
150
+ * Initialize Gemini clients lazily
189
151
  */
190
- async handleGenerateImage(params, progressToken) {
191
- // Use ErrorHandler.wrapWithResultType for safe execution
192
- const result = await errorHandler_1.ErrorHandler.wrapWithResultType(async () => {
193
- // Send initial progress notification
194
- if (progressToken) {
195
- await this.sendProgress(progressToken, 0, 100, 'Starting image generation...');
152
+ async initializeClients() {
153
+ if (this.structuredPromptGenerator && this.geminiClient)
154
+ return;
155
+ const configResult = (0, config_1.getConfig)();
156
+ if (!configResult.success) {
157
+ throw configResult.error;
158
+ }
159
+ // Initialize Gemini Text Client for prompt generation
160
+ if (!this.geminiTextClient) {
161
+ const textClientResult = (0, geminiTextClient_1.createGeminiTextClient)(configResult.data);
162
+ if (!textClientResult.success) {
163
+ throw textClientResult.error;
196
164
  }
197
- // Step 1: Validate input parameters
165
+ this.geminiTextClient = textClientResult.data;
166
+ }
167
+ // Initialize Structured Prompt Generator
168
+ if (!this.structuredPromptGenerator) {
169
+ this.structuredPromptGenerator = (0, structuredPromptGenerator_1.createStructuredPromptGenerator)(this.geminiTextClient);
170
+ }
171
+ // Initialize Gemini Client for image generation
172
+ if (!this.geminiClient) {
173
+ const clientResult = (0, geminiClient_1.createGeminiClient)(configResult.data);
174
+ if (!clientResult.success) {
175
+ throw clientResult.error;
176
+ }
177
+ this.geminiClient = clientResult.data;
178
+ }
179
+ this.logger.info('mcp-server', 'Gemini clients initialized');
180
+ }
181
+ /**
182
+ * Simplified image generation handler
183
+ */
184
+ async handleGenerateImage(params) {
185
+ const result = await errorHandler_1.ErrorHandler.wrapWithResultType(async () => {
186
+ // Validate input
198
187
  const validationResult = (0, inputValidator_1.validateGenerateImageParams)(params);
199
188
  if (!validationResult.success) {
200
189
  throw validationResult.error;
201
190
  }
202
- if (progressToken) {
203
- await this.sendProgress(progressToken, 20, 100, 'Input parameters validated');
204
- }
205
- // Step 2: Load configuration
191
+ // Get configuration
206
192
  const configResult = (0, config_1.getConfig)();
207
193
  if (!configResult.success) {
208
194
  throw configResult.error;
209
195
  }
210
- if (progressToken) {
211
- await this.sendProgress(progressToken, 30, 100, 'Configuration loaded');
212
- }
213
- // Step 3: Initialize components
214
- const geminiClientResult = (0, geminiClient_1.createGeminiClient)(configResult.data);
215
- if (!geminiClientResult.success) {
216
- throw geminiClientResult.error;
217
- }
218
- if (progressToken) {
219
- await this.sendProgress(progressToken, 50, 100, 'Client initialized');
220
- }
221
- const imageGenerator = this.createImageGeneratorFn(geminiClientResult.data);
222
- const fileManager = this.fileManager;
223
- const responseBuilder = this.responseBuilder;
224
- if (progressToken) {
225
- await this.sendProgress(progressToken, 60, 100, 'Generating image...');
226
- }
227
- // Step 4: Handle input image if provided
196
+ // Initialize clients
197
+ await this.initializeClients();
198
+ // Handle input image if provided
228
199
  let inputImageData;
229
- let inputImageMimeType;
230
200
  if (params.inputImagePath) {
231
- const fs = await Promise.resolve().then(() => __importStar(require('node:fs/promises')));
232
- const path = await Promise.resolve().then(() => __importStar(require('node:path')));
233
- // Read the image file
234
201
  const imageBuffer = await fs.readFile(params.inputImagePath);
235
202
  inputImageData = imageBuffer.toString('base64');
236
- // Determine MIME type from extension
237
- const ext = path.extname(params.inputImagePath).toLowerCase();
238
- const mimeTypes = {
239
- '.jpg': 'image/jpeg',
240
- '.jpeg': 'image/jpeg',
241
- '.png': 'image/png',
242
- '.webp': 'image/webp',
243
- '.gif': 'image/gif',
244
- '.bmp': 'image/bmp',
245
- };
246
- inputImageMimeType = mimeTypes[ext] || 'image/jpeg';
247
203
  }
248
- // Step 5: Generate image with all parameters
249
- const generationResult = await imageGenerator.generateImage({
250
- prompt: params.prompt,
251
- ...(inputImageData !== undefined && { inputImage: inputImageData }),
252
- ...(inputImageMimeType !== undefined && { inputImageMimeType: inputImageMimeType }),
253
- ...(params.blendImages !== undefined && { blendImages: params.blendImages }),
254
- ...(params.maintainCharacterConsistency !== undefined && {
255
- maintainCharacterConsistency: params.maintainCharacterConsistency,
256
- }),
257
- ...(params.useWorldKnowledge !== undefined && {
258
- useWorldKnowledge: params.useWorldKnowledge,
259
- }),
204
+ // Generate structured prompt using Gemini 2.0 Flash (unless skipped)
205
+ let structuredPrompt = params.prompt;
206
+ if (!configResult.data.skipPromptEnhancement && this.structuredPromptGenerator) {
207
+ const features = {};
208
+ if (params.maintainCharacterConsistency !== undefined) {
209
+ features.maintainCharacterConsistency = params.maintainCharacterConsistency;
210
+ }
211
+ if (params.blendImages !== undefined) {
212
+ features.blendImages = params.blendImages;
213
+ }
214
+ if (params.useWorldKnowledge !== undefined) {
215
+ features.useWorldKnowledge = params.useWorldKnowledge;
216
+ }
217
+ const promptResult = await this.structuredPromptGenerator.generateStructuredPrompt(params.prompt, features, inputImageData // Pass image data for context-aware prompt generation
218
+ );
219
+ if (promptResult.success) {
220
+ structuredPrompt = promptResult.data.structuredPrompt;
221
+ this.logger.info('mcp-server', 'Structured prompt generated', {
222
+ originalLength: params.prompt.length,
223
+ structuredLength: structuredPrompt.length,
224
+ selectedPractices: promptResult.data.selectedPractices,
225
+ });
226
+ }
227
+ else {
228
+ this.logger.warn('mcp-server', 'Using original prompt', {
229
+ error: promptResult.error.message,
230
+ });
231
+ }
232
+ }
233
+ else if (configResult.data.skipPromptEnhancement) {
234
+ this.logger.info('mcp-server', 'Prompt enhancement skipped (SKIP_PROMPT_ENHANCEMENT=true)');
235
+ }
236
+ // Generate image using Gemini 2.5 Flash Image Preview
237
+ if (!this.geminiClient) {
238
+ throw new Error('Gemini client not initialized');
239
+ }
240
+ const generationResult = await this.geminiClient.generateImage({
241
+ prompt: structuredPrompt,
242
+ ...(inputImageData && { inputImage: inputImageData }),
260
243
  });
261
244
  if (!generationResult.success) {
262
245
  throw generationResult.error;
263
246
  }
264
- if (progressToken) {
265
- await this.sendProgress(progressToken, 90, 100, 'Image generated, building response...');
266
- }
267
- // Step 6: Save image file to IMAGE_OUTPUT_DIR with specified or auto-generated name
268
- // Determine file path: use provided fileName or generate one, always in IMAGE_OUTPUT_DIR
269
- const finalFileName = params.fileName || fileManager.generateFileName();
270
- const rawOutputPath = path.join(configResult.data.imageOutputDir, finalFileName);
271
- // Security check: Sanitize output path
272
- const securityManager = this.securityManager;
273
- const pathSanitizationResult = securityManager.sanitizeFilePath(rawOutputPath);
274
- if (!pathSanitizationResult.success) {
275
- throw pathSanitizationResult.error;
247
+ // Save image file
248
+ const fileName = params.fileName || this.fileManager.generateFileName();
249
+ const outputPath = path.join(configResult.data.imageOutputDir, fileName);
250
+ const sanitizedPath = this.securityManager.sanitizeFilePath(outputPath);
251
+ if (!sanitizedPath.success) {
252
+ throw sanitizedPath.error;
276
253
  }
277
- const outputPath = pathSanitizationResult.data;
278
- // Always save to file (no more base64 responses)
279
- const saveResult = await fileManager.saveImage(generationResult.data.imageData, outputPath);
254
+ const saveResult = await this.fileManager.saveImage(generationResult.data.imageData, sanitizedPath.data);
280
255
  if (!saveResult.success) {
281
256
  throw saveResult.error;
282
257
  }
283
- const savedFilePath = saveResult.data;
284
- if (progressToken) {
285
- await this.sendProgress(progressToken, 95, 100, 'Image saved to file');
286
- }
287
- // Step 6: Build structured response
288
- const response = responseBuilder.buildSuccessResponse(generationResult.data, savedFilePath);
289
- if (progressToken) {
290
- await this.sendProgress(progressToken, 100, 100, 'Image generation completed');
291
- }
292
- return response;
258
+ // Build response
259
+ return this.responseBuilder.buildSuccessResponse(generationResult.data, saveResult.data);
293
260
  }, 'image-generation');
294
- // Handle the result
295
261
  if (result.ok) {
296
262
  return result.value;
297
263
  }
298
- // Build error response using ResponseBuilder
299
- const responseBuilder = this.responseBuilder;
300
- return responseBuilder.buildErrorResponse(result.error);
264
+ return this.responseBuilder.buildErrorResponse(result.error);
301
265
  }
302
266
  /**
303
267
  * Initialize MCP server with tool handlers
@@ -329,9 +293,7 @@ class MCPServerImpl {
329
293
  // Register tool call handler
330
294
  this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
331
295
  const { name, arguments: args } = request.params;
332
- const progressToken = request.params._meta?.progressToken;
333
- const result = await this.callTool(name, args, progressToken);
334
- // Extract content array from McpToolResponse and preserve structuredContent
296
+ const result = await this.callTool(name, args);
335
297
  const response = {
336
298
  content: result.content,
337
299
  };
@@ -344,10 +306,9 @@ class MCPServerImpl {
344
306
  }
345
307
  exports.MCPServerImpl = MCPServerImpl;
346
308
  /**
347
- * Factory function (for backward compatibility)
309
+ * Factory function to create MCP server
348
310
  */
349
- function createMCPServer(config = {}, dependencies = {}) {
350
- const mcpServer = new MCPServerImpl(config, dependencies);
351
- return mcpServer;
311
+ function createMCPServer(config = {}) {
312
+ return new MCPServerImpl(config);
352
313
  }
353
314
  //# sourceMappingURL=mcpServer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcpServer.js","sourceRoot":"","sources":["../../src/server/mcpServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwYH,0CAMC;AA5YD,qBAAqB;AACrB,gDAAiC;AACjC,wEAAkE;AAClE,iEAK2C;AAK3C,iBAAiB;AACjB,yDAA6E;AAC7E,+DAAsF;AACtF,+DAAwE;AACxE,iEAAyF;AAEzF,cAAc;AACd,sDAA2E;AAE3E,YAAY;AACZ,4CAA2C;AAC3C,4CAAwC;AACxC,gDAAmD;AAEnD,cAAc;AACd,iDAA6C;AAE7C;;GAEG;AACH,MAAM,cAAc,GAAoB;IACtC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,OAAO;IAChB,gBAAgB,EAAE,UAAU;CAC7B,CAAA;AAaD;;;GAGG;AACH,MAAa,aAAa;IASxB,YAAY,SAAmC,EAAE,EAAE,eAAsC,EAAE;QAPnF,WAAM,GAAkB,IAAI,CAAA;QAQlC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAA;QAC9C,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,IAAI,IAAI,eAAM,EAAE,CAAA;QACjD,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,WAAW,IAAI,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,CAAC,aAAa,EAAE,CAAA;QAEpB,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED;;OAEG;IACK,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAC3C,CAAC;QAED,6BAA6B;QAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,iCAAsB,EAAE,KAAK,IAA8B,EAAE;YACzF,OAAO,IAAI,CAAC,YAAY,EAAE,CAAA;QAC5B,CAAC,CAAC,CAAA;QAEF,6BAA6B;QAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAC3B,gCAAqB,EACrB,KAAK,EAAE,OAAO,EAA2B,EAAE;YACzC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;YAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAC9C,MAAM,QAAQ,GAAmB;gBAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAA;YACD,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;gBAC7B,QAAQ,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAA6C,CAAA;YACnF,CAAC;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC,CACF,CAAA;IACH,CAAC;CACF;AAhSD,sCAgSC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,SAAmC,EAAE;IACnE,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * MCP Server with Orchestration Support
3
+ * Extends basic MCP server with structured prompt generation capabilities
4
+ * Maintains 100% backward compatibility with existing functionality
5
+ */
6
+ import { type MCPServerDependencies, MCPServerImpl } from './mcpServer';
7
+ import type { MCPServerConfig, McpToolResponse } from '../types/mcp';
8
+ import type { MCPOrchestrationConfig, OrchestrationStatus } from '../types/mcpOrchestrationTypes';
9
+ import type { StructuredPromptOrchestrator } from '../business/promptOrchestrator';
10
+ import { StructuredPromptHandler } from './handlers/structuredPromptHandler';
11
+ import { type GeminiTextClient } from '../api/geminiTextClient';
12
+ import { type BestPracticesEngine } from '../business/bestPracticesEngine';
13
+ import { type POMLTemplateEngine } from '../business/pomlTemplateEngine';
14
+ /**
15
+ * Dependencies for orchestration-enabled MCP server
16
+ */
17
+ export interface MCPServerWithOrchestrationDependencies extends MCPServerDependencies {
18
+ geminiTextClient?: GeminiTextClient;
19
+ bestPracticesEngine?: BestPracticesEngine;
20
+ pomlTemplateEngine?: POMLTemplateEngine;
21
+ structuredPromptOrchestrator?: StructuredPromptOrchestrator;
22
+ structuredPromptHandler?: StructuredPromptHandler;
23
+ }
24
+ /**
25
+ * MCP Server with orchestration capabilities
26
+ * Extends basic MCP server while maintaining backward compatibility
27
+ */
28
+ export declare class MCPServerWithOrchestration extends MCPServerImpl {
29
+ private orchestrationConfig;
30
+ private structuredPromptHandler;
31
+ private geminiTextClient;
32
+ private orchestrator;
33
+ constructor(config?: Partial<MCPServerConfig>, orchestrationConfig?: Partial<MCPOrchestrationConfig>, dependencies?: MCPServerWithOrchestrationDependencies);
34
+ /**
35
+ * Enable structured prompt generation with orchestration components
36
+ */
37
+ enableStructuredPromptGeneration(config?: Partial<MCPOrchestrationConfig>): Promise<void>;
38
+ /**
39
+ * Get current orchestration status
40
+ */
41
+ getOrchestrationStatus(): OrchestrationStatus;
42
+ /**
43
+ * Update orchestration configuration
44
+ */
45
+ updateOrchestrationConfig(newConfig: Partial<MCPOrchestrationConfig>): void;
46
+ /**
47
+ * Override getToolsList to include orchestration parameters
48
+ */
49
+ getToolsList(): {
50
+ tools: {
51
+ name: string;
52
+ description: string;
53
+ inputSchema: {
54
+ type: "object";
55
+ properties: {
56
+ prompt: {
57
+ type: "string";
58
+ description: string;
59
+ };
60
+ fileName: {
61
+ type: "string";
62
+ description: string;
63
+ };
64
+ inputImagePath: {
65
+ type: "string";
66
+ description: string;
67
+ };
68
+ blendImages: {
69
+ type: "boolean";
70
+ description: string;
71
+ };
72
+ maintainCharacterConsistency: {
73
+ type: "boolean";
74
+ description: string;
75
+ };
76
+ useWorldKnowledge: {
77
+ type: "boolean";
78
+ description: string;
79
+ };
80
+ };
81
+ required: string[];
82
+ };
83
+ }[];
84
+ };
85
+ /**
86
+ * Override callTool to handle orchestration
87
+ */
88
+ callTool(name: string, args: unknown, progressToken?: string | number): Promise<McpToolResponse>;
89
+ /**
90
+ * Handle generate_image with optional orchestration
91
+ */
92
+ private handleGenerateImageWithOrchestration;
93
+ /**
94
+ * Initialize orchestration components
95
+ */
96
+ private initializeOrchestrationComponents;
97
+ }
98
+ //# sourceMappingURL=mcpServerWithOrchestration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpServerWithOrchestration.d.ts","sourceRoot":"","sources":["../../src/server/mcpServerWithOrchestration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,KAAK,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGvE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAEV,sBAAsB,EAEtB,mBAAmB,EACpB,MAAM,gCAAgC,CAAA;AAIvC,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAG5E,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,yBAAyB,CAAA;AACvF,OAAO,EAAE,KAAK,mBAAmB,EAA2B,MAAM,iCAAiC,CAAA;AAEnG,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,gCAAgC,CAAA;AAOhG;;GAEG;AACH,MAAM,WAAW,sCAAuC,SAAQ,qBAAqB;IACnF,gBAAgB,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