@vint.tri/report_gen_mcp 1.7.7 → 1.7.9

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/dist/index.js CHANGED
@@ -103,7 +103,7 @@ if (process.argv.length === 2) {
103
103
  // No command specified, run in stdio mode using MCP SDK
104
104
  const mcpServer = new McpServer({
105
105
  name: "report_gen_mcp",
106
- version: "1.7.7"
106
+ version: "1.7.9"
107
107
  }, {
108
108
  // Disable health check to prevent automatic calls
109
109
  capabilities: {
@@ -1 +1 @@
1
- {"version":3,"file":"imageGenerationServer.d.ts","sourceRoot":"","sources":["../../src/mcp/imageGenerationServer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,UAAU,uBAAuB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,cAAM,cAAc;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAA0B;;IAiBjD,OAAO,CAAC,aAAa;IAIf,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAuE9G;AA+ND,iBAAe,IAAI,kBASlB;AAOD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"imageGenerationServer.d.ts","sourceRoot":"","sources":["../../src/mcp/imageGenerationServer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,UAAU,uBAAuB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,cAAM,cAAc;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAA0B;;IAiBjD,OAAO,CAAC,aAAa;IAIf,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAuE9G;AA6SD,iBAAe,IAAI,kBASlB;AAOD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC"}
@@ -7,7 +7,6 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
7
7
  import axios from 'axios';
8
8
  import fs from 'fs-extra';
9
9
  import path from 'path';
10
- import os from 'os';
11
10
  import { fileURLToPath } from 'url';
12
11
  import { z } from 'zod';
13
12
  // Получаем __dirname в ES модуле
@@ -147,9 +146,9 @@ app.registerTool("generate_image", {
147
146
  if (imageDataUri.startsWith("data:image/jpeg;base64,")) {
148
147
  base64Data = imageDataUri.substring("data:image/jpeg;base64,".length);
149
148
  }
150
- // Сохраняем изображение в домашнюю папку пользователя
151
- const homeDir = os.homedir();
152
- const imagesDir = path.join(homeDir, 'generated_images');
149
+ // Сохраняем изображение в указанную рабочую папку
150
+ const reportsDir = process.env.REPORTS_DIR || process.cwd(); // Use REPORTS_DIR or current working directory
151
+ const imagesDir = path.join(reportsDir, 'generated_images');
153
152
  await fs.ensureDir(imagesDir);
154
153
  // Создаем уникальное имя файла
155
154
  const timestamp = Date.now();
@@ -284,6 +283,78 @@ app.registerTool("generate_image_to_file", {
284
283
  };
285
284
  }
286
285
  });
286
+ app.registerTool("show_image", {
287
+ description: "Показывает изображение по пути (локальному или URL). Возвращает base64 код изображения.",
288
+ inputSchema: {
289
+ path: z.string().describe("Путь к изображению (локальный файл или URL)")
290
+ },
291
+ }, async (args) => {
292
+ try {
293
+ const imagePath = args.path;
294
+ if (!imagePath) {
295
+ throw new Error("Параметр 'path' обязателен");
296
+ }
297
+ let imageDataBuffer;
298
+ let mimeType = "image/jpeg"; // Default to JPEG, will try to infer or set based on URL
299
+ if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) {
300
+ // Fetch from URL
301
+ const response = await axios.get(imagePath, {
302
+ responseType: 'arraybuffer',
303
+ timeout: 30000
304
+ });
305
+ if (response.status !== 200) {
306
+ throw new Error(`Ошибка при загрузке изображения с URL ${imagePath}: ${response.statusText}`);
307
+ }
308
+ imageDataBuffer = response.data;
309
+ mimeType = response.headers['content-type'] || mimeType; // Get MIME type from headers
310
+ }
311
+ else {
312
+ // Read from local file
313
+ const fullPath = path.resolve(imagePath);
314
+ imageDataBuffer = await fs.readFile(fullPath);
315
+ // Try to infer mime type from file extension
316
+ const ext = path.extname(fullPath).toLowerCase();
317
+ if (ext === '.png')
318
+ mimeType = 'image/png';
319
+ else if (ext === '.gif')
320
+ mimeType = 'image/gif';
321
+ else if (ext === '.webp')
322
+ mimeType = 'image/webp';
323
+ else
324
+ mimeType = 'image/jpeg'; // Default
325
+ }
326
+ if (!imageDataBuffer || imageDataBuffer.length === 0) {
327
+ throw new Error("Пустые или некорректные данные изображения");
328
+ }
329
+ const base64Data = imageDataBuffer.toString('base64');
330
+ return {
331
+ content: [
332
+ {
333
+ type: "text",
334
+ text: `✅ Изображение успешно загружено с пути: '${imagePath}'
335
+
336
+ Код изображения (base64):
337
+ ${base64Data}`
338
+ },
339
+ {
340
+ type: "image",
341
+ data: base64Data,
342
+ mimeType: mimeType
343
+ }
344
+ ]
345
+ };
346
+ }
347
+ catch (error) {
348
+ return {
349
+ content: [
350
+ {
351
+ type: "text",
352
+ text: `❌ Ошибка при показе изображения: ${error.message}`
353
+ }
354
+ ]
355
+ };
356
+ }
357
+ });
287
358
  async function main() {
288
359
  try {
289
360
  const transport = new StdioServerTransport();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vint.tri/report_gen_mcp",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "CLI tool for generating HTML reports with embedded charts and images",
5
5
  "main": "dist/index.js",
6
6
  "bin": {