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.
- package/README.md +41 -17
- package/dist/api/geminiClient.d.ts +2 -12
- package/dist/api/geminiClient.d.ts.map +1 -1
- package/dist/api/geminiClient.js +28 -56
- package/dist/api/geminiClient.js.map +1 -1
- package/dist/api/geminiTextClient.d.ts +42 -0
- package/dist/api/geminiTextClient.d.ts.map +1 -0
- package/dist/api/geminiTextClient.js +198 -0
- package/dist/api/geminiTextClient.js.map +1 -0
- package/dist/business/__tests__/mocks/mcpSamplingClient.mock.d.ts +84 -0
- package/dist/business/__tests__/mocks/mcpSamplingClient.mock.d.ts.map +1 -0
- package/dist/business/__tests__/mocks/mcpSamplingClient.mock.js +100 -0
- package/dist/business/__tests__/mocks/mcpSamplingClient.mock.js.map +1 -0
- package/dist/business/bestPracticesEngine.d.ts +149 -0
- package/dist/business/bestPracticesEngine.d.ts.map +1 -0
- package/dist/business/bestPracticesEngine.js +781 -0
- package/dist/business/bestPracticesEngine.js.map +1 -0
- package/dist/business/complexityAssessment.d.ts +132 -0
- package/dist/business/complexityAssessment.d.ts.map +1 -0
- package/dist/business/complexityAssessment.js +488 -0
- package/dist/business/complexityAssessment.js.map +1 -0
- package/dist/business/fallbackStrategies.d.ts +177 -0
- package/dist/business/fallbackStrategies.d.ts.map +1 -0
- package/dist/business/fallbackStrategies.js +368 -0
- package/dist/business/fallbackStrategies.js.map +1 -0
- package/dist/business/imageGenerator.d.ts.map +1 -1
- package/dist/business/imageGenerator.js +26 -5
- package/dist/business/imageGenerator.js.map +1 -1
- package/dist/business/multiImage/aspectRatioController.d.ts +77 -0
- package/dist/business/multiImage/aspectRatioController.d.ts.map +1 -0
- package/dist/business/multiImage/aspectRatioController.js +580 -0
- package/dist/business/multiImage/aspectRatioController.js.map +1 -0
- package/dist/business/multiImage/multiImageCoordinator.d.ts +142 -0
- package/dist/business/multiImage/multiImageCoordinator.d.ts.map +1 -0
- package/dist/business/multiImage/multiImageCoordinator.js +801 -0
- package/dist/business/multiImage/multiImageCoordinator.js.map +1 -0
- package/dist/business/pomlTemplateEngine.d.ts +206 -0
- package/dist/business/pomlTemplateEngine.d.ts.map +1 -0
- package/dist/business/pomlTemplateEngine.js +737 -0
- package/dist/business/pomlTemplateEngine.js.map +1 -0
- package/dist/business/promptOrchestrator.d.ts +173 -0
- package/dist/business/promptOrchestrator.d.ts.map +1 -0
- package/dist/business/promptOrchestrator.js +490 -0
- package/dist/business/promptOrchestrator.js.map +1 -0
- package/dist/business/responseBuilder.d.ts +2 -2
- package/dist/business/responseBuilder.d.ts.map +1 -1
- package/dist/business/responseBuilder.js +6 -1
- package/dist/business/responseBuilder.js.map +1 -1
- package/dist/business/structuredPromptGenerator.d.ts +54 -0
- package/dist/business/structuredPromptGenerator.d.ts.map +1 -0
- package/dist/business/structuredPromptGenerator.js +208 -0
- package/dist/business/structuredPromptGenerator.js.map +1 -0
- package/dist/business/templateNormalizer.d.ts +81 -0
- package/dist/business/templateNormalizer.d.ts.map +1 -0
- package/dist/business/templateNormalizer.js +659 -0
- package/dist/business/templateNormalizer.js.map +1 -0
- package/dist/documentation/apiContractValidation.d.ts +62 -0
- package/dist/documentation/apiContractValidation.d.ts.map +1 -0
- package/dist/documentation/apiContractValidation.js +305 -0
- package/dist/documentation/apiContractValidation.js.map +1 -0
- package/dist/infrastructure/concurrency/concurrencyManager.d.ts +101 -0
- package/dist/infrastructure/concurrency/concurrencyManager.d.ts.map +1 -0
- package/dist/infrastructure/concurrency/concurrencyManager.js +345 -0
- package/dist/infrastructure/concurrency/concurrencyManager.js.map +1 -0
- package/dist/infrastructure/config/secureConfigManager.d.ts +319 -0
- package/dist/infrastructure/config/secureConfigManager.d.ts.map +1 -0
- package/dist/infrastructure/config/secureConfigManager.js +600 -0
- package/dist/infrastructure/config/secureConfigManager.js.map +1 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandler.d.ts +229 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandler.d.ts.map +1 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandler.js +61 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandler.js.map +1 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.d.ts +133 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.d.ts.map +1 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.js +569 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.js.map +1 -0
- package/dist/infrastructure/mcp/MCPSamplingClient.d.ts +19 -0
- package/dist/infrastructure/mcp/MCPSamplingClient.d.ts.map +1 -0
- package/dist/infrastructure/mcp/MCPSamplingClient.js +31 -0
- package/dist/infrastructure/mcp/MCPSamplingClient.js.map +1 -0
- package/dist/infrastructure/mcp/RealMCPSamplingClient.d.ts +59 -0
- package/dist/infrastructure/mcp/RealMCPSamplingClient.d.ts.map +1 -0
- package/dist/infrastructure/mcp/RealMCPSamplingClient.js +271 -0
- package/dist/infrastructure/mcp/RealMCPSamplingClient.js.map +1 -0
- package/dist/infrastructure/metadata/generationMetadata.d.ts +72 -0
- package/dist/infrastructure/metadata/generationMetadata.d.ts.map +1 -0
- package/dist/infrastructure/metadata/generationMetadata.js +228 -0
- package/dist/infrastructure/metadata/generationMetadata.js.map +1 -0
- package/dist/infrastructure/monitoring/OrchestrationMetrics.d.ts +106 -0
- package/dist/infrastructure/monitoring/OrchestrationMetrics.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/OrchestrationMetrics.js +456 -0
- package/dist/infrastructure/monitoring/OrchestrationMetrics.js.map +1 -0
- package/dist/infrastructure/monitoring/alertingSystem.d.ts +135 -0
- package/dist/infrastructure/monitoring/alertingSystem.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/alertingSystem.js +549 -0
- package/dist/infrastructure/monitoring/alertingSystem.js.map +1 -0
- package/dist/infrastructure/optimization/performanceOptimizer.d.ts +89 -0
- package/dist/infrastructure/optimization/performanceOptimizer.d.ts.map +1 -0
- package/dist/infrastructure/optimization/performanceOptimizer.js +375 -0
- package/dist/infrastructure/optimization/performanceOptimizer.js.map +1 -0
- package/dist/infrastructure/security/AdvancedContentFilter.d.ts +99 -0
- package/dist/infrastructure/security/AdvancedContentFilter.d.ts.map +1 -0
- package/dist/infrastructure/security/AdvancedContentFilter.js +363 -0
- package/dist/infrastructure/security/AdvancedContentFilter.js.map +1 -0
- package/dist/infrastructure/security/MCPSecurityValidator.d.ts +62 -0
- package/dist/infrastructure/security/MCPSecurityValidator.d.ts.map +1 -0
- package/dist/infrastructure/security/MCPSecurityValidator.js +129 -0
- package/dist/infrastructure/security/MCPSecurityValidator.js.map +1 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddleware.d.ts +304 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddleware.d.ts.map +1 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddleware.js +61 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddleware.js.map +1 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.d.ts +62 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.d.ts.map +1 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.js +591 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.js.map +1 -0
- package/dist/infrastructure/security/SecureMCPClient.d.ts +154 -0
- package/dist/infrastructure/security/SecureMCPClient.d.ts.map +1 -0
- package/dist/infrastructure/security/SecureMCPClient.js +292 -0
- package/dist/infrastructure/security/SecureMCPClient.js.map +1 -0
- package/dist/infrastructure/security/SecurityIncidentManager.d.ts +142 -0
- package/dist/infrastructure/security/SecurityIncidentManager.d.ts.map +1 -0
- package/dist/infrastructure/security/SecurityIncidentManager.js +260 -0
- package/dist/infrastructure/security/SecurityIncidentManager.js.map +1 -0
- package/dist/infrastructure/security/apiKeyManager.d.ts +297 -0
- package/dist/infrastructure/security/apiKeyManager.d.ts.map +1 -0
- package/dist/infrastructure/security/apiKeyManager.js +254 -0
- package/dist/infrastructure/security/apiKeyManager.js.map +1 -0
- package/dist/infrastructure/security/dataSanitizer.d.ts +157 -0
- package/dist/infrastructure/security/dataSanitizer.d.ts.map +1 -0
- package/dist/infrastructure/security/dataSanitizer.js +525 -0
- package/dist/infrastructure/security/dataSanitizer.js.map +1 -0
- package/dist/infrastructure/validation/inputValidator.d.ts +54 -0
- package/dist/infrastructure/validation/inputValidator.d.ts.map +1 -0
- package/dist/infrastructure/validation/inputValidator.js +362 -0
- package/dist/infrastructure/validation/inputValidator.js.map +1 -0
- package/dist/integration/parameterOptimizer.d.ts +69 -0
- package/dist/integration/parameterOptimizer.d.ts.map +1 -0
- package/dist/integration/parameterOptimizer.js +317 -0
- package/dist/integration/parameterOptimizer.js.map +1 -0
- package/dist/integration/twoStageProcessor.d.ts +66 -0
- package/dist/integration/twoStageProcessor.d.ts.map +1 -0
- package/dist/integration/twoStageProcessor.js +348 -0
- package/dist/integration/twoStageProcessor.js.map +1 -0
- package/dist/server/handlers/structuredPromptHandler.d.ts +65 -0
- package/dist/server/handlers/structuredPromptHandler.d.ts.map +1 -0
- package/dist/server/handlers/structuredPromptHandler.js +314 -0
- package/dist/server/handlers/structuredPromptHandler.js.map +1 -0
- package/dist/server/mcpServer.d.ts +16 -35
- package/dist/server/mcpServer.d.ts.map +1 -1
- package/dist/server/mcpServer.js +111 -150
- package/dist/server/mcpServer.js.map +1 -1
- package/dist/server/mcpServerWithOrchestration.d.ts +98 -0
- package/dist/server/mcpServerWithOrchestration.d.ts.map +1 -0
- package/dist/server/mcpServerWithOrchestration.js +284 -0
- package/dist/server/mcpServerWithOrchestration.js.map +1 -0
- package/dist/types/mcpOrchestrationTypes.d.ts +135 -0
- package/dist/types/mcpOrchestrationTypes.d.ts.map +1 -0
- package/dist/types/mcpOrchestrationTypes.js +28 -0
- package/dist/types/mcpOrchestrationTypes.js.map +1 -0
- package/dist/types/multiImageTypes.d.ts +328 -0
- package/dist/types/multiImageTypes.d.ts.map +1 -0
- package/dist/types/multiImageTypes.js +27 -0
- package/dist/types/multiImageTypes.js.map +1 -0
- package/dist/types/performanceTypes.d.ts +300 -0
- package/dist/types/performanceTypes.d.ts.map +1 -0
- package/dist/types/performanceTypes.js +50 -0
- package/dist/types/performanceTypes.js.map +1 -0
- package/dist/types/twoStageTypes.d.ts +123 -0
- package/dist/types/twoStageTypes.d.ts.map +1 -0
- package/dist/types/twoStageTypes.js +7 -0
- package/dist/types/twoStageTypes.js.map +1 -0
- package/dist/utils/config.d.ts +1 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +1 -0
- package/dist/utils/config.js.map +1 -1
- package/package.json +11 -4
- package/vitest.config.mjs +0 -47
package/dist/server/mcpServer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* MCP Server implementation
|
|
4
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
69
|
-
* Simple implementation focusing on testability
|
|
68
|
+
* Simplified MCP server
|
|
70
69
|
*/
|
|
71
70
|
class MCPServerImpl {
|
|
72
|
-
constructor(config = {}
|
|
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 =
|
|
76
|
-
this.fileManager =
|
|
77
|
-
this.responseBuilder =
|
|
78
|
-
this.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
|
-
*
|
|
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
|
|
135
|
+
* Tool execution
|
|
171
136
|
*/
|
|
172
|
-
async callTool(name, args
|
|
137
|
+
async callTool(name, args) {
|
|
173
138
|
try {
|
|
174
139
|
if (name === 'generate_image') {
|
|
175
|
-
return await this.handleGenerateImage(args
|
|
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
|
-
*
|
|
150
|
+
* Initialize Gemini clients lazily
|
|
189
151
|
*/
|
|
190
|
-
async
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
211
|
-
|
|
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
|
-
//
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
|
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
|
-
|
|
284
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
309
|
+
* Factory function to create MCP server
|
|
348
310
|
*/
|
|
349
|
-
function createMCPServer(config = {}
|
|
350
|
-
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"mcpServer.js","sourceRoot":"","sources":["../../src/server/mcpServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoVH,0CAEC;AApVD,qDAAsC;AACtC,gDAAiC;AACjC,wEAAkE;AAClE,iEAK2C;AAK3C,iBAAiB;AACjB,yDAA6E;AAC7E,+DAAwE;AACxE,iEAAyF;AACzF,qFAI8C;AAE9C,cAAc;AACd,sDAA2E;AAC3E,8DAAuF;AAEvF,YAAY;AACZ,4CAA2C;AAC3C,4CAAwC;AACxC,gDAAmD;AACnD,iDAA6C;AAE7C;;GAEG;AACH,MAAM,cAAc,GAAoB;IACtC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,OAAO;IAChB,gBAAgB,EAAE,UAAU;CAC7B,CAAA;AAED;;GAEG;AACH,MAAa,aAAa;IAWxB,YAAY,SAAmC,EAAE;QATzC,WAAM,GAAkB,IAAI,CAAA;QAK5B,8BAAyB,GAAqC,IAAI,CAAA;QAClE,qBAAgB,GAA4B,IAAI,CAAA;QAChD,iBAAY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AAiB,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,CAAC,EA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