@vint.tri/report_gen_mcp 1.7.1 → 1.7.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.
@@ -498,6 +498,50 @@
498
498
  }
499
499
  ```
500
500
 
501
+ ### Изображения, сгенерированные с помощью generate-image (Chutes AI)
502
+
503
+ При использовании инструмента `generate-image` для генерации изображений с помощью Chutes AI, важно правильно форматировать параметры. Все числовые параметры должны быть представлены как числа, а не как строки.
504
+
505
+ ✅ ПРАВИЛЬНО (числовые параметры как числа):
506
+ ```json
507
+ {
508
+ "method": "tools/call",
509
+ "params": {
510
+ "name": "generate-image",
511
+ "arguments": {
512
+ "prompt": "a dog made of US dollar bills",
513
+ "width": 512,
514
+ "height": 512,
515
+ "guidance_scale": 7.5,
516
+ "negative_prompt": "blurry, low quality",
517
+ "num_inference_steps": 50,
518
+ "seed": 0
519
+ }
520
+ }
521
+ }
522
+ ```
523
+
524
+ ❌ НЕПРАВИЛЬНО (числовые параметры как строки):
525
+ ```json
526
+ {
527
+ "method": "tools/call",
528
+ "params": {
529
+ "name": "generate-image",
530
+ "arguments": {
531
+ "prompt": "a dog made of US dollar bills",
532
+ "width": "512",
533
+ "height": "512",
534
+ "guidance_scale": "7.5",
535
+ "negative_prompt": "blurry, low quality",
536
+ "num_inference_steps": "50",
537
+ "seed": "0"
538
+ }
539
+ }
540
+ }
541
+ ```
542
+
543
+ **ВАЖНО:** Все числовые параметры (`width`, `height`, `guidance_scale`, `num_inference_steps`, `seed`) должны быть представлены как числа, а не как строки в кавычках. Это критически важно для корректной работы инструмента.
544
+
501
545
  ### Изображения по URL
502
546
 
503
547
  ```json
@@ -0,0 +1,108 @@
1
+ # Fix for Image Generation String Parameters Issue
2
+
3
+ ## Problem Description
4
+
5
+ The neural network was sending numeric parameters as strings to the `generate-image` tool, causing validation errors:
6
+
7
+ ```
8
+ Error calling tool generate-image: Error: Error invoking remote method 'mcp:call-tool': McpError: MCP error -32602: Invalid arguments for tool generate-image: [
9
+ {
10
+ "code": "invalid_type",
11
+ "expected": "number",
12
+ "received": "string",
13
+ "path": ["width"],
14
+ "message": "Expected number, received string"
15
+ },
16
+ // Similar errors for height, guidance_scale, num_inference_steps, seed
17
+ ]
18
+ ```
19
+
20
+ ## Root Cause
21
+
22
+ The Zod schema validation in the MCP server expected actual numbers for numeric parameters, but the neural network was sending them as JSON strings.
23
+
24
+ ## Solution Implemented
25
+
26
+ ### 1. Updated Image Generation Server
27
+
28
+ Modified `src/mcp/imageGenerationServer.ts` to automatically convert string parameters to numbers:
29
+
30
+ ```typescript
31
+ // Преобразуем строковые значения в числа, если необходимо
32
+ const generationParams: Partial<ImageGenerationSettings> = {};
33
+ if (args.width !== undefined) {
34
+ generationParams.width = typeof args.width === 'string' ? parseFloat(args.width) : args.width;
35
+ }
36
+ if (args.height !== undefined) {
37
+ generationParams.height = typeof args.height === 'string' ? parseFloat(args.height) : args.height;
38
+ }
39
+ if (args.guidance_scale !== undefined) {
40
+ generationParams.guidance_scale = typeof args.guidance_scale === 'string' ? parseFloat(args.guidance_scale) : args.guidance_scale;
41
+ }
42
+ if (args.negative_prompt !== undefined) generationParams.negative_prompt = args.negative_prompt;
43
+ if (args.num_inference_steps !== undefined) {
44
+ generationParams.num_inference_steps = typeof args.num_inference_steps === 'string' ? parseInt(args.num_inference_steps) : args.num_inference_steps;
45
+ }
46
+ if (args.seed !== undefined) {
47
+ generationParams.seed = typeof args.seed === 'string' ? parseInt(args.seed) : args.seed;
48
+ }
49
+ ```
50
+
51
+ This change was applied to both `generate_image` and `generate_image_to_file` tools in the server.
52
+
53
+ ### 2. Updated Neural Network Instructions
54
+
55
+ Added clear guidelines in `FIXED_NEURAL_NETWORK_INSTRUCTIONS_v1.6.5.md` about proper parameter formatting:
56
+
57
+ #### Correct Format (Numbers as Numbers):
58
+ ```json
59
+ {
60
+ "method": "tools/call",
61
+ "params": {
62
+ "name": "generate-image",
63
+ "arguments": {
64
+ "prompt": "a dog made of US dollar bills",
65
+ "width": 512,
66
+ "height": 512,
67
+ "guidance_scale": 7.5,
68
+ "negative_prompt": "blurry, low quality",
69
+ "num_inference_steps": 50,
70
+ "seed": 0
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ #### Incorrect Format (Numbers as Strings):
77
+ ```json
78
+ {
79
+ "method": "tools/call",
80
+ "params": {
81
+ "name": "generate-image",
82
+ "arguments": {
83
+ "prompt": "a dog made of US dollar bills",
84
+ "width": "512",
85
+ "height": "512",
86
+ "guidance_scale": "7.5",
87
+ "negative_prompt": "blurry, low quality",
88
+ "num_inference_steps": "50",
89
+ "seed": "0"
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ ## Testing
96
+
97
+ Created `test-image-generation-string-params.js` to verify the fix works correctly with both string and mixed parameter types.
98
+
99
+ ## Backward Compatibility
100
+
101
+ The fix maintains backward compatibility by:
102
+ 1. Still accepting numeric parameters as numbers
103
+ 2. Converting string parameters to numbers when needed
104
+ 3. Not changing the external API interface
105
+
106
+ ## Impact
107
+
108
+ This fix resolves the issue where neural networks sending string-formatted numeric parameters would receive validation errors, allowing seamless image generation with the Chutes AI service.
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.1"
106
+ version: "1.7.2"
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;AAyMD,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;AA+ND,iBAAe,IAAI,kBASlB;AAOD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC"}
@@ -121,19 +121,25 @@ app.registerTool("generate_image", {
121
121
  throw new Error("Параметр 'prompt' обязателен");
122
122
  }
123
123
  // Дополнительные параметры (необязательные)
124
+ // Преобразуем строковые значения в числа, если необходимо
124
125
  const generationParams = {};
125
- if (args.width !== undefined)
126
- generationParams.width = args.width;
127
- if (args.height !== undefined)
128
- generationParams.height = args.height;
129
- if (args.guidance_scale !== undefined)
130
- generationParams.guidance_scale = args.guidance_scale;
126
+ if (args.width !== undefined) {
127
+ generationParams.width = typeof args.width === 'string' ? parseFloat(args.width) : args.width;
128
+ }
129
+ if (args.height !== undefined) {
130
+ generationParams.height = typeof args.height === 'string' ? parseFloat(args.height) : args.height;
131
+ }
132
+ if (args.guidance_scale !== undefined) {
133
+ generationParams.guidance_scale = typeof args.guidance_scale === 'string' ? parseFloat(args.guidance_scale) : args.guidance_scale;
134
+ }
131
135
  if (args.negative_prompt !== undefined)
132
136
  generationParams.negative_prompt = args.negative_prompt;
133
- if (args.num_inference_steps !== undefined)
134
- generationParams.num_inference_steps = args.num_inference_steps;
135
- if (args.seed !== undefined)
136
- generationParams.seed = args.seed;
137
+ if (args.num_inference_steps !== undefined) {
138
+ generationParams.num_inference_steps = typeof args.num_inference_steps === 'string' ? parseInt(args.num_inference_steps) : args.num_inference_steps;
139
+ }
140
+ if (args.seed !== undefined) {
141
+ generationParams.seed = typeof args.seed === 'string' ? parseInt(args.seed) : args.seed;
142
+ }
137
143
  // Генерируем изображение
138
144
  const imageDataUri = await imageGen.generateImage(prompt, generationParams);
139
145
  // Извлекаем только base64 данные без префикса
@@ -216,19 +222,25 @@ app.registerTool("generate_image_to_file", {
216
222
  throw new Error("Параметр 'filename' обязателен");
217
223
  }
218
224
  // Дополнительные параметры (необязательные)
225
+ // Преобразуем строковые значения в числа, если необходимо
219
226
  const generationParams = {};
220
- if (args.width !== undefined)
221
- generationParams.width = args.width;
222
- if (args.height !== undefined)
223
- generationParams.height = args.height;
224
- if (args.guidance_scale !== undefined)
225
- generationParams.guidance_scale = args.guidance_scale;
227
+ if (args.width !== undefined) {
228
+ generationParams.width = typeof args.width === 'string' ? parseFloat(args.width) : args.width;
229
+ }
230
+ if (args.height !== undefined) {
231
+ generationParams.height = typeof args.height === 'string' ? parseFloat(args.height) : args.height;
232
+ }
233
+ if (args.guidance_scale !== undefined) {
234
+ generationParams.guidance_scale = typeof args.guidance_scale === 'string' ? parseFloat(args.guidance_scale) : args.guidance_scale;
235
+ }
226
236
  if (args.negative_prompt !== undefined)
227
237
  generationParams.negative_prompt = args.negative_prompt;
228
- if (args.num_inference_steps !== undefined)
229
- generationParams.num_inference_steps = args.num_inference_steps;
230
- if (args.seed !== undefined)
231
- generationParams.seed = args.seed;
238
+ if (args.num_inference_steps !== undefined) {
239
+ generationParams.num_inference_steps = typeof args.num_inference_steps === 'string' ? parseInt(args.num_inference_steps) : args.num_inference_steps;
240
+ }
241
+ if (args.seed !== undefined) {
242
+ generationParams.seed = typeof args.seed === 'string' ? parseInt(args.seed) : args.seed;
243
+ }
232
244
  // Генерируем изображение
233
245
  const imageDataUri = await imageGen.generateImage(prompt, generationParams);
234
246
  // Извлекаем только base64 данные без префикса
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vint.tri/report_gen_mcp",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "CLI tool for generating HTML reports with embedded charts and images",
5
5
  "main": "dist/index.js",
6
6
  "bin": {