mcp-image 0.8.0 → 0.8.2
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/bin/install-skills.js +7 -6
- package/dist/api/geminiClient.d.ts +4 -4
- package/dist/api/geminiClient.d.ts.map +1 -1
- package/dist/api/geminiClient.js +27 -28
- package/dist/api/geminiClient.js.map +1 -1
- package/dist/api/geminiTextClient.d.ts +3 -3
- package/dist/api/geminiTextClient.d.ts.map +1 -1
- package/dist/api/geminiTextClient.js +16 -19
- package/dist/api/geminiTextClient.js.map +1 -1
- package/dist/business/fileManager.d.ts +2 -2
- package/dist/business/fileManager.d.ts.map +1 -1
- package/dist/business/fileManager.js +15 -50
- package/dist/business/fileManager.js.map +1 -1
- package/dist/business/inputValidator.d.ts +3 -3
- package/dist/business/inputValidator.d.ts.map +1 -1
- package/dist/business/inputValidator.js +34 -40
- package/dist/business/inputValidator.js.map +1 -1
- package/dist/business/responseBuilder.d.ts +3 -3
- package/dist/business/responseBuilder.d.ts.map +1 -1
- package/dist/business/responseBuilder.js +9 -45
- package/dist/business/responseBuilder.js.map +1 -1
- package/dist/business/structuredPromptGenerator.d.ts +2 -2
- package/dist/business/structuredPromptGenerator.d.ts.map +1 -1
- package/dist/business/structuredPromptGenerator.js +14 -19
- package/dist/business/structuredPromptGenerator.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -9
- package/dist/index.js.map +1 -1
- package/dist/server/errorHandler.d.ts +2 -2
- package/dist/server/errorHandler.d.ts.map +1 -1
- package/dist/server/errorHandler.js +10 -13
- package/dist/server/errorHandler.js.map +1 -1
- package/dist/server/mcpServer.d.ts +2 -2
- package/dist/server/mcpServer.d.ts.map +1 -1
- package/dist/server/mcpServer.js +45 -72
- package/dist/server/mcpServer.js.map +1 -1
- package/dist/server-main.js +6 -8
- package/dist/server-main.js.map +1 -1
- package/dist/types/mcp.js +2 -5
- package/dist/types/mcp.js.map +1 -1
- package/dist/types/result.js +2 -6
- package/dist/types/result.js.map +1 -1
- package/dist/utils/config.d.ts +3 -3
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +12 -16
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/errors.js +9 -19
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/logger.js +2 -39
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/security.d.ts +10 -2
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js +39 -50
- package/dist/utils/security.js.map +1 -1
- package/package.json +12 -16
- package/skills/image-generation/SKILL.md +20 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../src/server/errorHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../src/server/errorHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,YAAY,GAEb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,4CAA4C;AAC5C,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAA;AAE3B;;;;GAIG;AACH,SAAS,WAAW,CAAC,KAAY;IAC/B,6BAA6B;IAC7B,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,gBAAgB,EAAE,KAAK,EAAE;QACrD,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI;QACjC,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC,CAAA;IAEF,qCAAqC;IACrC,MAAM,eAAe,GAAG;QACtB,KAAK,EAAE,wBAAwB,CAAC,KAAK,CAAC;KACvC,CAAA;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC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AAE,GAAG,KAAK,CAAC,OAAkC,CAAA;YAChF,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACzC,aAAa,CAAC,SAAS,CAAC,GAAG,YAAY,CAAA;YACzC,CAAC;QACH,CAAC;QAED,OAAO,aAMN,CAAA;IACH,CAAC;IAED,wBAAwB;IACxB,OAAO;QACL,GAAG,SAAS;QACZ,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,2BAA2B;QACrD,UAAU,EAAE,8BAA8B;KAC3C,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,WAAW;IACX,kBAAkB;CACV,CAAA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Simplified architecture with direct Gemini integration
|
|
4
4
|
*/
|
|
5
5
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
|
-
import type { MCPServerConfig } from '../types/mcp';
|
|
6
|
+
import type { MCPServerConfig } from '../types/mcp.js';
|
|
7
7
|
/**
|
|
8
8
|
* Simplified MCP server
|
|
9
9
|
*/
|
|
@@ -90,7 +90,7 @@ export declare class MCPServerImpl {
|
|
|
90
90
|
/**
|
|
91
91
|
* Tool execution
|
|
92
92
|
*/
|
|
93
|
-
callTool(name: string, args: unknown): Promise<import("../types/mcp").McpToolResponse>;
|
|
93
|
+
callTool(name: string, args: unknown): Promise<import("../types/mcp.js").McpToolResponse>;
|
|
94
94
|
/**
|
|
95
95
|
* Initialize Gemini clients lazily
|
|
96
96
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpServer.d.ts","sourceRoot":"","sources":["../../src/server/mcpServer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;
|
|
1
|
+
{"version":3,"file":"mcpServer.d.ts","sourceRoot":"","sources":["../../src/server/mcpServer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAoBlE,OAAO,KAAK,EAAuB,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAiB3E;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,yBAAyB,CAAyC;IAC1E,OAAO,CAAC,gBAAgB,CAAgC;IACxD,OAAO,CAAC,YAAY,CAA4B;gBAEpC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM;IAQjD;;OAEG;IACI,aAAa;;;;IAOpB;;OAEG;IACI,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyFnB;;OAEG;IACU,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;IAYjD;;OAEG;YACW,iBAAiB;IAkC/B;;OAEG;YACW,mBAAmB;IA0HjC;;OAEG;IACI,UAAU,IAAI,MAAM;IAmB3B;;OAEG;IACH,OAAO,CAAC,aAAa;CA0BtB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,iBAEpE"}
|
package/dist/server/mcpServer.js
CHANGED
|
@@ -1,61 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* MCP Server implementation
|
|
4
3
|
* Simplified architecture with direct Gemini integration
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.MCPServerImpl = void 0;
|
|
41
|
-
exports.createMCPServer = createMCPServer;
|
|
42
|
-
const fs = __importStar(require("node:fs/promises"));
|
|
43
|
-
const path = __importStar(require("node:path"));
|
|
44
|
-
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
45
|
-
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
46
|
-
// Business logic
|
|
47
|
-
const fileManager_1 = require("../business/fileManager");
|
|
48
|
-
const inputValidator_1 = require("../business/inputValidator");
|
|
49
|
-
const responseBuilder_1 = require("../business/responseBuilder");
|
|
50
|
-
const structuredPromptGenerator_1 = require("../business/structuredPromptGenerator");
|
|
5
|
+
import * as fs from 'node:fs/promises';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
8
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
51
9
|
// API clients
|
|
52
|
-
|
|
53
|
-
|
|
10
|
+
import { createGeminiClient } from '../api/geminiClient.js';
|
|
11
|
+
import { createGeminiTextClient } from '../api/geminiTextClient.js';
|
|
12
|
+
// Business logic
|
|
13
|
+
import { createFileManager } from '../business/fileManager.js';
|
|
14
|
+
import { validateGenerateImageParams } from '../business/inputValidator.js';
|
|
15
|
+
import { createResponseBuilder } from '../business/responseBuilder.js';
|
|
16
|
+
import { createStructuredPromptGenerator, } from '../business/structuredPromptGenerator.js';
|
|
54
17
|
// Utilities
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
18
|
+
import { getConfig } from '../utils/config.js';
|
|
19
|
+
import { Logger } from '../utils/logger.js';
|
|
20
|
+
import { SecurityManager } from '../utils/security.js';
|
|
21
|
+
import { ErrorHandler } from './errorHandler.js';
|
|
59
22
|
/**
|
|
60
23
|
* Default MCP server configuration
|
|
61
24
|
*/
|
|
@@ -67,17 +30,17 @@ const DEFAULT_CONFIG = {
|
|
|
67
30
|
/**
|
|
68
31
|
* Simplified MCP server
|
|
69
32
|
*/
|
|
70
|
-
class MCPServerImpl {
|
|
33
|
+
export class MCPServerImpl {
|
|
71
34
|
constructor(config = {}) {
|
|
72
35
|
this.server = null;
|
|
73
36
|
this.structuredPromptGenerator = null;
|
|
74
37
|
this.geminiTextClient = null;
|
|
75
38
|
this.geminiClient = null;
|
|
76
39
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
77
|
-
this.logger = new
|
|
78
|
-
this.fileManager =
|
|
79
|
-
this.responseBuilder =
|
|
80
|
-
this.securityManager = new
|
|
40
|
+
this.logger = new Logger();
|
|
41
|
+
this.fileManager = createFileManager();
|
|
42
|
+
this.responseBuilder = createResponseBuilder();
|
|
43
|
+
this.securityManager = new SecurityManager();
|
|
81
44
|
}
|
|
82
45
|
/**
|
|
83
46
|
* Get server info
|
|
@@ -181,7 +144,7 @@ class MCPServerImpl {
|
|
|
181
144
|
}
|
|
182
145
|
catch (error) {
|
|
183
146
|
this.logger.error('mcp-server', 'Tool execution failed', error);
|
|
184
|
-
return
|
|
147
|
+
return ErrorHandler.handleError(error);
|
|
185
148
|
}
|
|
186
149
|
}
|
|
187
150
|
/**
|
|
@@ -190,13 +153,13 @@ class MCPServerImpl {
|
|
|
190
153
|
async initializeClients() {
|
|
191
154
|
if (this.structuredPromptGenerator && this.geminiClient)
|
|
192
155
|
return;
|
|
193
|
-
const configResult =
|
|
156
|
+
const configResult = getConfig();
|
|
194
157
|
if (!configResult.success) {
|
|
195
158
|
throw configResult.error;
|
|
196
159
|
}
|
|
197
160
|
// Initialize Gemini Text Client for prompt generation
|
|
198
161
|
if (!this.geminiTextClient) {
|
|
199
|
-
const textClientResult =
|
|
162
|
+
const textClientResult = createGeminiTextClient(configResult.data);
|
|
200
163
|
if (!textClientResult.success) {
|
|
201
164
|
throw textClientResult.error;
|
|
202
165
|
}
|
|
@@ -204,11 +167,11 @@ class MCPServerImpl {
|
|
|
204
167
|
}
|
|
205
168
|
// Initialize Structured Prompt Generator
|
|
206
169
|
if (!this.structuredPromptGenerator) {
|
|
207
|
-
this.structuredPromptGenerator =
|
|
170
|
+
this.structuredPromptGenerator = createStructuredPromptGenerator(this.geminiTextClient);
|
|
208
171
|
}
|
|
209
172
|
// Initialize Gemini Client for image generation
|
|
210
173
|
if (!this.geminiClient) {
|
|
211
|
-
const clientResult =
|
|
174
|
+
const clientResult = createGeminiClient(configResult.data);
|
|
212
175
|
if (!clientResult.success) {
|
|
213
176
|
throw clientResult.error;
|
|
214
177
|
}
|
|
@@ -220,14 +183,14 @@ class MCPServerImpl {
|
|
|
220
183
|
* Simplified image generation handler
|
|
221
184
|
*/
|
|
222
185
|
async handleGenerateImage(params) {
|
|
223
|
-
const result = await
|
|
186
|
+
const result = await ErrorHandler.wrapWithResultType(async () => {
|
|
224
187
|
// Validate input
|
|
225
|
-
const validationResult =
|
|
188
|
+
const validationResult = validateGenerateImageParams(params);
|
|
226
189
|
if (!validationResult.success) {
|
|
227
190
|
throw validationResult.error;
|
|
228
191
|
}
|
|
229
192
|
// Get configuration
|
|
230
|
-
const configResult =
|
|
193
|
+
const configResult = getConfig();
|
|
231
194
|
if (!configResult.success) {
|
|
232
195
|
throw configResult.error;
|
|
233
196
|
}
|
|
@@ -236,7 +199,15 @@ class MCPServerImpl {
|
|
|
236
199
|
// Handle input image if provided
|
|
237
200
|
let inputImageData;
|
|
238
201
|
if (params.inputImagePath) {
|
|
239
|
-
const
|
|
202
|
+
const sanitizedInputPath = this.securityManager.sanitizeInputFilePath(params.inputImagePath);
|
|
203
|
+
if (!sanitizedInputPath.success) {
|
|
204
|
+
throw sanitizedInputPath.error;
|
|
205
|
+
}
|
|
206
|
+
const extensionCheck = this.securityManager.validateImageFile(sanitizedInputPath.data);
|
|
207
|
+
if (!extensionCheck.success) {
|
|
208
|
+
throw extensionCheck.error;
|
|
209
|
+
}
|
|
210
|
+
const imageBuffer = await fs.readFile(sanitizedInputPath.data);
|
|
240
211
|
inputImageData = imageBuffer.toString('base64');
|
|
241
212
|
}
|
|
242
213
|
// Generate structured prompt (unless skipped)
|
|
@@ -291,7 +262,10 @@ class MCPServerImpl {
|
|
|
291
262
|
throw generationResult.error;
|
|
292
263
|
}
|
|
293
264
|
// Save image file
|
|
294
|
-
const
|
|
265
|
+
const rawFileName = params.fileName || this.fileManager.generateFileName();
|
|
266
|
+
const fileName = params.fileName
|
|
267
|
+
? this.securityManager.sanitizeFilename(rawFileName)
|
|
268
|
+
: rawFileName;
|
|
295
269
|
const outputPath = path.join(configResult.data.imageOutputDir, fileName);
|
|
296
270
|
const sanitizedPath = this.securityManager.sanitizeFilePath(outputPath);
|
|
297
271
|
if (!sanitizedPath.success) {
|
|
@@ -313,7 +287,7 @@ class MCPServerImpl {
|
|
|
313
287
|
* Initialize MCP server with tool handlers
|
|
314
288
|
*/
|
|
315
289
|
initialize() {
|
|
316
|
-
this.server = new
|
|
290
|
+
this.server = new Server({
|
|
317
291
|
name: this.config.name,
|
|
318
292
|
version: this.config.version,
|
|
319
293
|
}, {
|
|
@@ -333,11 +307,11 @@ class MCPServerImpl {
|
|
|
333
307
|
throw new Error('Server not initialized');
|
|
334
308
|
}
|
|
335
309
|
// Register tool list handler
|
|
336
|
-
this.server.setRequestHandler(
|
|
310
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
337
311
|
return this.getToolsList();
|
|
338
312
|
});
|
|
339
313
|
// Register tool call handler
|
|
340
|
-
this.server.setRequestHandler(
|
|
314
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
341
315
|
const { name, arguments: args } = request.params;
|
|
342
316
|
const result = await this.callTool(name, args);
|
|
343
317
|
const response = {
|
|
@@ -350,11 +324,10 @@ class MCPServerImpl {
|
|
|
350
324
|
});
|
|
351
325
|
}
|
|
352
326
|
}
|
|
353
|
-
exports.MCPServerImpl = MCPServerImpl;
|
|
354
327
|
/**
|
|
355
328
|
* Factory function to create MCP server
|
|
356
329
|
*/
|
|
357
|
-
function createMCPServer(config = {}) {
|
|
330
|
+
export function createMCPServer(config = {}) {
|
|
358
331
|
return new MCPServerImpl(config);
|
|
359
332
|
}
|
|
360
333
|
//# sourceMappingURL=mcpServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpServer.js","sourceRoot":"","sources":["../../src/server/mcpServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcpServer.js","sourceRoot":"","sources":["../../src/server/mcpServer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,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B,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;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,SAAmC,EAAE;IACnE,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC"}
|
package/dist/server-main.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* MCP Image Generator - Server Entry Point
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const logger = new logger_1.Logger();
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
+
import { MCPServerImpl } from './server/mcpServer.js';
|
|
6
|
+
import { Logger } from './utils/logger.js';
|
|
7
|
+
const logger = new Logger();
|
|
10
8
|
/**
|
|
11
9
|
* Application startup
|
|
12
10
|
*/
|
|
@@ -17,9 +15,9 @@ async function main() {
|
|
|
17
15
|
platform: process.platform,
|
|
18
16
|
env: process.env['NODE_ENV'] || 'development',
|
|
19
17
|
});
|
|
20
|
-
const mcpServerImpl = new
|
|
18
|
+
const mcpServerImpl = new MCPServerImpl();
|
|
21
19
|
const server = mcpServerImpl.initialize();
|
|
22
|
-
const transport = new
|
|
20
|
+
const transport = new StdioServerTransport();
|
|
23
21
|
await server.connect(transport);
|
|
24
22
|
logger.info('mcp-startup', 'Image Generator MCP Server started successfully');
|
|
25
23
|
}
|
package/dist/server-main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-main.js","sourceRoot":"","sources":["../src/server-main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server-main.js","sourceRoot":"","sources":["../src/server-main.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAA;AAE3B;;GAEG;AACH,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,6CAA6C,EAAE;YACxE,WAAW,EAAE,OAAO,CAAC,OAAO;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,aAAa;SAC9C,CAAC,CAAA;QAEF,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAA;QAEzC,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,EAAE,CAAA;QAEzC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;QAE5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAE/B,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,iDAAiD,CAAC,CAAA;IAC/E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,4BAA4B,EAAE,KAAc,EAAE;YACxE,SAAS,EAAG,KAAe,EAAE,WAAW,EAAE,IAAI;YAC9C,KAAK,EAAG,KAAe,EAAE,KAAK;SAC/B,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,oBAAoB;AACpB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,4BAA4B,EAAE,KAAc,CAAC,CAAA;IACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/types/mcp.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* MCP-related type definitions
|
|
4
3
|
* Defines types related to @modelcontextprotocol/sdk and project-specific types
|
|
5
4
|
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.GEMINI_MODELS = exports.IMAGE_QUALITY_VALUES = void 0;
|
|
8
5
|
/**
|
|
9
6
|
* Supported quality preset values
|
|
10
7
|
*/
|
|
11
|
-
|
|
8
|
+
export const IMAGE_QUALITY_VALUES = [
|
|
12
9
|
'fast',
|
|
13
10
|
'balanced',
|
|
14
11
|
'quality',
|
|
@@ -16,7 +13,7 @@ exports.IMAGE_QUALITY_VALUES = [
|
|
|
16
13
|
/**
|
|
17
14
|
* Gemini image generation model identifiers
|
|
18
15
|
*/
|
|
19
|
-
|
|
16
|
+
export const GEMINI_MODELS = {
|
|
20
17
|
/** Nano Banana 2 - fast generation with Flash speed */
|
|
21
18
|
FLASH: 'gemini-3.1-flash-image-preview',
|
|
22
19
|
/** Nano Banana Pro - highest quality output */
|
package/dist/types/mcp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/types/mcp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/types/mcp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsCH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA4B;IAC3D,MAAM;IACN,UAAU;IACV,SAAS;CACD,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,uDAAuD;IACvD,KAAK,EAAE,gCAAgC;IACvC,+CAA+C;IAC/C,GAAG,EAAE,4BAA4B;CACzB,CAAA"}
|
package/dist/types/result.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Result type for operations that may fail
|
|
4
3
|
* Provides type-safe error handling with discriminated unions
|
|
5
4
|
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.Ok = Ok;
|
|
8
|
-
exports.Err = Err;
|
|
9
5
|
/**
|
|
10
6
|
* Helper function to create a successful Result
|
|
11
7
|
* @param data The data to wrap in a successful Result
|
|
12
8
|
* @returns A successful Result containing the data
|
|
13
9
|
*/
|
|
14
|
-
function Ok(data) {
|
|
10
|
+
export function Ok(data) {
|
|
15
11
|
return {
|
|
16
12
|
success: true,
|
|
17
13
|
data,
|
|
@@ -22,7 +18,7 @@ function Ok(data) {
|
|
|
22
18
|
* @param error The error to wrap in a failed Result
|
|
23
19
|
* @returns A failed Result containing the error
|
|
24
20
|
*/
|
|
25
|
-
function Err(error) {
|
|
21
|
+
export function Err(error) {
|
|
26
22
|
return {
|
|
27
23
|
success: false,
|
|
28
24
|
error,
|
package/dist/types/result.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/types/result.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/types/result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH;;;;GAIG;AACH,MAAM,UAAU,EAAE,CAAI,IAAO;IAC3B,OAAO;QACL,OAAO,EAAE,IAAI;QACb,IAAI;KACL,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAkB,KAAQ;IAC3C,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK;KACN,CAAA;AACH,CAAC"}
|
package/dist/utils/config.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Configuration management for MCP server
|
|
3
3
|
* Handles environment variables and configuration validation
|
|
4
4
|
*/
|
|
5
|
-
import type { ImageQuality } from '../types/mcp';
|
|
6
|
-
import type { Result } from '../types/result';
|
|
7
|
-
import { ConfigError } from './errors';
|
|
5
|
+
import type { ImageQuality } from '../types/mcp.js';
|
|
6
|
+
import type { Result } from '../types/result.js';
|
|
7
|
+
import { ConfigError } from './errors.js';
|
|
8
8
|
/**
|
|
9
9
|
* Configuration interface
|
|
10
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAUD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAmD1E;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAUvD"}
|
package/dist/utils/config.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Configuration management for MCP server
|
|
4
3
|
* Handles environment variables and configuration validation
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const mcp_1 = require("../types/mcp");
|
|
10
|
-
const result_1 = require("../types/result");
|
|
11
|
-
const errors_1 = require("./errors");
|
|
5
|
+
import { IMAGE_QUALITY_VALUES } from '../types/mcp.js';
|
|
6
|
+
import { Err, Ok } from '../types/result.js';
|
|
7
|
+
import { ConfigError } from './errors.js';
|
|
12
8
|
/**
|
|
13
9
|
* Default configuration values
|
|
14
10
|
*/
|
|
@@ -21,33 +17,33 @@ const DEFAULT_CONFIG = {
|
|
|
21
17
|
* @param config The configuration to validate
|
|
22
18
|
* @returns Result containing validated config or ConfigError
|
|
23
19
|
*/
|
|
24
|
-
function validateConfig(config) {
|
|
20
|
+
export function validateConfig(config) {
|
|
25
21
|
// Validate GEMINI_API_KEY
|
|
26
22
|
if (!config.geminiApiKey || config.geminiApiKey.trim().length === 0) {
|
|
27
|
-
return
|
|
23
|
+
return Err(new ConfigError('GEMINI_API_KEY is required but not provided', 'Set GEMINI_API_KEY environment variable with your Google AI API key'));
|
|
28
24
|
}
|
|
29
25
|
if (config.geminiApiKey.length < 10) {
|
|
30
|
-
return
|
|
26
|
+
return Err(new ConfigError('GEMINI_API_KEY appears to be invalid - must be at least 10 characters', 'Set the GEMINI_API_KEY environment variable to your valid Google AI API key'));
|
|
31
27
|
}
|
|
32
28
|
// Validate apiTimeout
|
|
33
29
|
if (config.apiTimeout <= 0) {
|
|
34
|
-
return
|
|
30
|
+
return Err(new ConfigError('API timeout must be a positive number', 'Set a positive timeout value in milliseconds (e.g., 30000 for 30 seconds)'));
|
|
35
31
|
}
|
|
36
32
|
// Validate imageOutputDir (basic check - non-empty string)
|
|
37
33
|
if (!config.imageOutputDir || config.imageOutputDir.trim().length === 0) {
|
|
38
|
-
return
|
|
34
|
+
return Err(new ConfigError('IMAGE_OUTPUT_DIR cannot be empty', 'Set IMAGE_OUTPUT_DIR to a valid directory path'));
|
|
39
35
|
}
|
|
40
36
|
// Validate imageQuality
|
|
41
|
-
if (!
|
|
42
|
-
return
|
|
37
|
+
if (!IMAGE_QUALITY_VALUES.includes(config.imageQuality)) {
|
|
38
|
+
return Err(new ConfigError(`Invalid IMAGE_QUALITY value: "${config.imageQuality}". Valid options: ${IMAGE_QUALITY_VALUES.join(', ')}`, `Set IMAGE_QUALITY to one of: ${IMAGE_QUALITY_VALUES.join(', ')}`));
|
|
43
39
|
}
|
|
44
|
-
return
|
|
40
|
+
return Ok(config);
|
|
45
41
|
}
|
|
46
42
|
/**
|
|
47
43
|
* Loads configuration from environment variables
|
|
48
44
|
* @returns Result containing config or ConfigError
|
|
49
45
|
*/
|
|
50
|
-
function getConfig() {
|
|
46
|
+
export function getConfig() {
|
|
51
47
|
const config = {
|
|
52
48
|
geminiApiKey: process.env['GEMINI_API_KEY'] || '',
|
|
53
49
|
imageOutputDir: process.env['IMAGE_OUTPUT_DIR'] || DEFAULT_CONFIG.imageOutputDir,
|
package/dist/utils/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAazC;;GAEG;AACH,MAAM,cAAc,GAAG;IACrB,cAAc,EAAE,UAAU;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AAM,UAAU,SAAS;IACvB,MAAM,MAAM,GAAW;QACrB,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE;QACjD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,cAAc,CAAC,cAAc;QAChF,UAAU,EAAE,cAAc,CAAC,UAAU;QACrC,qBAAqB,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,KAAK,MAAM;QACxE,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,MAAM,CAAiB;KACvE,CAAA;IAED,OAAO,cAAc,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC"}
|
package/dist/utils/errors.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Custom error classes for MCP server
|
|
4
3
|
* Provides specific error types with structured error codes and suggestions
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
exports.SecurityError = exports.ConfigError = exports.NetworkError = exports.GeminiAPIError = exports.FileOperationError = exports.InputValidationError = exports.BaseError = void 0;
|
|
8
|
-
const mcp_1 = require("../types/mcp");
|
|
5
|
+
import { GEMINI_MODELS } from '../types/mcp.js';
|
|
9
6
|
/**
|
|
10
7
|
* Base class for all application errors with structured error support
|
|
11
8
|
*/
|
|
12
|
-
class BaseError extends Error {
|
|
9
|
+
export class BaseError extends Error {
|
|
13
10
|
constructor(message, context) {
|
|
14
11
|
super(message);
|
|
15
12
|
this.name = this.constructor.name;
|
|
@@ -26,22 +23,20 @@ class BaseError extends Error {
|
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
exports.BaseError = BaseError;
|
|
30
26
|
/**
|
|
31
27
|
* Error for input validation failures
|
|
32
28
|
*/
|
|
33
|
-
class InputValidationError extends BaseError {
|
|
29
|
+
export class InputValidationError extends BaseError {
|
|
34
30
|
constructor(message, suggestion) {
|
|
35
31
|
super(message);
|
|
36
32
|
this.suggestion = suggestion;
|
|
37
33
|
this.code = 'INPUT_VALIDATION_ERROR';
|
|
38
34
|
}
|
|
39
35
|
}
|
|
40
|
-
exports.InputValidationError = InputValidationError;
|
|
41
36
|
/**
|
|
42
37
|
* Error for file operation failures with intelligent suggestion system
|
|
43
38
|
*/
|
|
44
|
-
class FileOperationError extends BaseError {
|
|
39
|
+
export class FileOperationError extends BaseError {
|
|
45
40
|
constructor() {
|
|
46
41
|
super(...arguments);
|
|
47
42
|
this.code = 'FILE_OPERATION_ERROR';
|
|
@@ -72,11 +67,10 @@ class FileOperationError extends BaseError {
|
|
|
72
67
|
return 'Check file system permissions and available disk space';
|
|
73
68
|
}
|
|
74
69
|
}
|
|
75
|
-
exports.FileOperationError = FileOperationError;
|
|
76
70
|
/**
|
|
77
71
|
* Error for Gemini API failures with intelligent suggestion system
|
|
78
72
|
*/
|
|
79
|
-
class GeminiAPIError extends BaseError {
|
|
73
|
+
export class GeminiAPIError extends BaseError {
|
|
80
74
|
constructor(message, suggestionOrContext, statusCodeOrContext) {
|
|
81
75
|
let context;
|
|
82
76
|
let statusCode;
|
|
@@ -117,7 +111,7 @@ class GeminiAPIError extends BaseError {
|
|
|
117
111
|
return 'Wait before retrying or upgrade API quota limits';
|
|
118
112
|
}
|
|
119
113
|
if (message.includes('model') || message.includes('access') || message.includes('permission')) {
|
|
120
|
-
return `Ensure you have access to the Gemini image generation models (${
|
|
114
|
+
return `Ensure you have access to the Gemini image generation models (${GEMINI_MODELS.FLASH} or ${GEMINI_MODELS.PRO})`;
|
|
121
115
|
}
|
|
122
116
|
if (message.includes('timeout') || message.includes('503') || message.includes('502')) {
|
|
123
117
|
return 'The service is temporarily unavailable. Please retry after a few moments';
|
|
@@ -128,11 +122,10 @@ class GeminiAPIError extends BaseError {
|
|
|
128
122
|
return 'Check API configuration and retry the request';
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
|
-
exports.GeminiAPIError = GeminiAPIError;
|
|
132
125
|
/**
|
|
133
126
|
* Error for network-related failures with intelligent suggestion system
|
|
134
127
|
*/
|
|
135
|
-
class NetworkError extends BaseError {
|
|
128
|
+
export class NetworkError extends BaseError {
|
|
136
129
|
constructor(message, suggestionOrContext, causeOrContext) {
|
|
137
130
|
let context;
|
|
138
131
|
let cause;
|
|
@@ -179,22 +172,20 @@ class NetworkError extends BaseError {
|
|
|
179
172
|
return 'Check network connectivity and firewall settings';
|
|
180
173
|
}
|
|
181
174
|
}
|
|
182
|
-
exports.NetworkError = NetworkError;
|
|
183
175
|
/**
|
|
184
176
|
* Error for configuration failures
|
|
185
177
|
*/
|
|
186
|
-
class ConfigError extends BaseError {
|
|
178
|
+
export class ConfigError extends BaseError {
|
|
187
179
|
constructor(message, suggestion) {
|
|
188
180
|
super(message);
|
|
189
181
|
this.suggestion = suggestion;
|
|
190
182
|
this.code = 'CONFIG_ERROR';
|
|
191
183
|
}
|
|
192
184
|
}
|
|
193
|
-
exports.ConfigError = ConfigError;
|
|
194
185
|
/**
|
|
195
186
|
* Error for security violations and attacks with intelligent suggestion system
|
|
196
187
|
*/
|
|
197
|
-
class SecurityError extends BaseError {
|
|
188
|
+
export class SecurityError extends BaseError {
|
|
198
189
|
constructor() {
|
|
199
190
|
super(...arguments);
|
|
200
191
|
this.code = 'SECURITY_ERROR';
|
|
@@ -221,5 +212,4 @@ class SecurityError extends BaseError {
|
|
|
221
212
|
return 'Ensure your request meets security requirements';
|
|
222
213
|
}
|
|
223
214
|
}
|
|
224
|
-
exports.SecurityError = SecurityError;
|
|
225
215
|
//# sourceMappingURL=errors.js.map
|