@vint.tri/report_gen_mcp 1.7.15 → 1.7.17

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.
@@ -0,0 +1,92 @@
1
+ # 📋 Fix for Neural Network Image Integration Issue
2
+
3
+ ## 🎯 Problem Description
4
+ The neural network was unable to properly integrate images generated by the `generate-image` tool into reports created with the `generate-report` tool. The error message was:
5
+ > "Извините, я не могу напрямую встроить сгенерированное изображение в отчет, так как функция report_generate_image не возвращает идентификатор или путь к изображению, который можно было бы использовать в report_generate_report."
6
+
7
+ This occurred because the neural network didn't understand how to properly extract and use the `fileUrl` from the `generate-image` response in the `generate-report` elements parameter.
8
+
9
+ ## 🔧 Root Cause Analysis
10
+ 1. **Missing Documentation**: The neural network instructions didn't clearly explain how to use the result from `generate-image` in `generate-report`
11
+ 2. **Format Mismatch**: The `generate-image` tool returns `fileUrl` in its response, but the neural network didn't know to extract this and wrap it in the proper `{type: "url", config: {url: ...}}` structure
12
+ 3. **Direct String Usage**: Neural network was trying to use the image path directly as a string value instead of as a properly structured object
13
+
14
+ ## ✅ Solution Implemented
15
+
16
+ ### 1. Updated Neural Network Instructions
17
+ Updated both `NEURAL_NETWORK_INSTRUCTIONS.md` and `NEURAL_NETWORK_INSTRUCTIONS_v1.7.1.md` with clear guidance:
18
+
19
+ #### New Section Added: ПРАВИЛЬНОЕ ИСПОЛЬЗОВАНИЕ РЕЗУЛЬТАТА generate-image В ОТЧЕТАХ
20
+
21
+ **Key Points:**
22
+ - Clearly explained the structure of `generate-image` response
23
+ - Showed exactly how to extract `fileUrl` from the response
24
+ - Provided complete example of integrating the result into `generate-report`
25
+ - Included both correct and incorrect examples for comparison
26
+
27
+ ### 2. Enhanced Documentation with Practical Examples
28
+
29
+ **Before (Confusing):**
30
+ ```javascript
31
+ // Neural network didn't know what to do with this response
32
+ {
33
+ "content": [...],
34
+ "filePath": "/path/to/image.jpeg",
35
+ "fileUrl": "file:///path/to/image.jpeg"
36
+ }
37
+ ```
38
+
39
+ **After (Clear Guidance):**
40
+ ```javascript
41
+ // Now neural network knows to:
42
+ // 1. Extract fileUrl from response
43
+ // 2. Wrap it in proper structure for generate-report
44
+
45
+ // Extract fileUrl: "file:///path/to/image.jpeg"
46
+ // Use in generate-report elements:
47
+ {
48
+ "dog_image": {
49
+ "type": "url",
50
+ "config": {
51
+ "url": "file:///path/to/image.jpeg", // <- fileUrl from generate-image response
52
+ "alt": "Сгенерированное изображение",
53
+ "width": 512,
54
+ "height": 512
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### 3. Complete Integration Workflow Example
61
+
62
+ Provided step-by-step example:
63
+ 1. Call `generate-image` tool
64
+ 2. Receive response with `fileUrl`
65
+ 3. Extract `fileUrl` from response
66
+ 4. Use `fileUrl` in `generate-report` elements parameter with proper structure
67
+ 5. Successfully generate report with embedded image
68
+
69
+ ## 📚 Files Updated
70
+
71
+ 1. **`NEURAL_NETWORK_INSTRUCTIONS_v1.7.1.md`** - Enhanced with detailed integration guidance
72
+ 2. **`NEURAL_NETWORK_INSTRUCTIONS.md`** - Updated with proper image integration workflow
73
+ 3. **`test_neural_network_image_integration.js`** - Created test script demonstrating correct vs incorrect workflows
74
+
75
+ ## 🎉 Expected Results
76
+
77
+ After this fix, the neural network will be able to:
78
+ 1. ✅ Properly extract `fileUrl` from `generate-image` responses
79
+ 2. ✅ Correctly structure elements for `generate-report`
80
+ 3. ✅ Successfully embed generated images in reports
81
+ 4. ✅ Avoid the "Expected object, received string" error
82
+ 5. ✅ Provide users with complete reports containing both charts and generated images
83
+
84
+ ## 💡 Key Improvements
85
+
86
+ - **Clear Documentation**: Explicit instructions on data flow between tools
87
+ - **Practical Examples**: Real-world integration scenarios
88
+ - **Error Prevention**: Clear distinction between correct and incorrect approaches
89
+ - **Backward Compatibility**: Maintains existing functionality while fixing the integration issue
90
+ - **Comprehensive Coverage**: Addresses both Chutes AI and pollinations.ai image generation workflows
91
+
92
+ This fix resolves the core issue preventing neural networks from creating rich reports that combine both data visualizations (charts) and AI-generated images.
@@ -542,6 +542,48 @@
542
542
 
543
543
  **Гибкость параметров:** Инструмент поддерживает как числовые, так и строковые значения для числовых параметров (`width`, `height`, `guidance_scale`, `num_inference_steps`, `seed`). Это обеспечивает совместимость с различными способами формирования запросов.
544
544
 
545
+ **ПРАВИЛЬНОЕ ИСПОЛЬЗОВАНИЕ РЕЗУЛЬТАТА generate-image В ОТЧЕТАХ:**
546
+
547
+ Когда вы получаете ответ от `generate-image`, он имеет следующую структуру:
548
+ ```json
549
+ {
550
+ "content": [
551
+ {
552
+ "type": "text",
553
+ "text": "✅ Image successfully generated from prompt: 'your prompt'"
554
+ }
555
+ ],
556
+ "filePath": "/полный/путь/к/generated-image-1234567890.jpeg",
557
+ "fileUrl": "file:///полный/путь/к/generated-image-1234567890.jpeg"
558
+ }
559
+ ```
560
+
561
+ Чтобы использовать это изображение в отчете с помощью `generate-report`, извлеките `fileUrl` из ответа и используйте его в элементе отчета:
562
+
563
+ ```json
564
+ {
565
+ "method": "tools/call",
566
+ "params": {
567
+ "name": "generate-report",
568
+ "arguments": {
569
+ "document": "# Отчет\n\n[[image:generated_img]]",
570
+ "elements": {
571
+ "generated_img": {
572
+ "type": "url",
573
+ "config": {
574
+ "url": "file:///полный/путь/к/generated-image-1234567890.jpeg", // <- Используйте fileUrl из предыдущего ответа
575
+ "alt": "Сгенерированное изображение",
576
+ "width": 512,
577
+ "height": 512
578
+ }
579
+ }
580
+ },
581
+ "outputFile": "report.html"
582
+ }
583
+ }
584
+ }
585
+ ```
586
+
545
587
  ### Изображения по URL
546
588
 
547
589
  ```json
@@ -111,7 +111,25 @@
111
111
 
112
112
  ### Изображения, сгенерированные с помощью generate-image (Chutes AI)
113
113
 
114
- Когда вы получаете результат от `generate-image`, вы получаете `filePath` и `fileUrl`. Чтобы использовать такое изображение в отчете:
114
+ Когда вы получаете результат от `generate-image`, вы получаете `filePath` и `fileUrl`. Чтобы использовать такое изображение в отчете, вам нужно правильно преобразовать ответ:
115
+
116
+ **ПРАВИЛЬНЫЙ ФОРМАТ ИСПОЛЬЗОВАНИЯ РЕЗУЛЬТАТА generate-image:**
117
+
118
+ Когда вы получаете ответ от `generate-image`, он имеет следующую структуру:
119
+ ```json
120
+ {
121
+ "content": [
122
+ {
123
+ "type": "text",
124
+ "text": "✅ Image successfully generated from prompt: 'your prompt'"
125
+ }
126
+ ],
127
+ "filePath": "/полный/путь/к/generated-image-1234567890.jpeg",
128
+ "fileUrl": "file:///полный/путь/к/generated-image-1234567890.jpeg"
129
+ }
130
+ ```
131
+
132
+ Чтобы использовать это изображение в отчете, извлеките `fileUrl` из ответа и используйте его в элементе отчета:
115
133
 
116
134
  ```json
117
135
  {
@@ -127,6 +145,48 @@
127
145
 
128
146
  **ВАЖНО:** Используйте `fileUrl` из ответа `generate-image` в поле `url`.
129
147
 
148
+ **ПОЛНЫЙ ПРИМЕР ИНТЕГРАЦИИ:**
149
+
150
+ 1. Сначала сгенерируйте изображение:
151
+ ```json
152
+ {
153
+ "method": "tools/call",
154
+ "params": {
155
+ "name": "generate-image",
156
+ "arguments": {
157
+ "prompt": "a beautiful landscape",
158
+ "width": 512,
159
+ "height": 512
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ 2. Затем используйте результат в generate-report:
166
+ ```json
167
+ {
168
+ "method": "tools/call",
169
+ "params": {
170
+ "name": "generate-report",
171
+ "arguments": {
172
+ "document": "# Отчет\n\n[[image:generated_img]]",
173
+ "elements": {
174
+ "generated_img": {
175
+ "type": "url",
176
+ "config": {
177
+ "url": "file:///полный/путь/к/generated-image-1234567890.jpeg", // <- Используйте fileUrl из предыдущего ответа
178
+ "alt": "Сгенерированное изображение",
179
+ "width": 512,
180
+ "height": 512
181
+ }
182
+ }
183
+ },
184
+ "outputFile": "report.html"
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
130
190
  ### Изображения по URL
131
191
 
132
192
  ```json
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.15"
106
+ version: "1.7.17"
107
107
  }, {
108
108
  // Disable health check to prevent automatic calls
109
109
  capabilities: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vint.tri/report_gen_mcp",
3
- "version": "1.7.15",
3
+ "version": "1.7.17",
4
4
  "description": "CLI tool for generating HTML reports with embedded charts and images",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Test script to verify the neural network image integration fix
5
+ * This script demonstrates the correct workflow for using generate-image result in generate-report
6
+ */
7
+
8
+ import fs from 'fs-extra';
9
+ import path from 'path';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ // Get the directory of this script
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+
16
+ // Mock the response from generate-image tool
17
+ const mockGenerateImageResponse = {
18
+ content: [
19
+ {
20
+ type: "text",
21
+ text: "✅ Image successfully generated from prompt: 'a beautiful dog made of US dollar bills'"
22
+ }
23
+ ],
24
+ filePath: "/tmp/generated-image-1234567890.jpeg",
25
+ fileUrl: "file:///tmp/generated-image-1234567890.jpeg"
26
+ };
27
+
28
+ // Mock the response from generate-report tool
29
+ const mockGenerateReportResponse = {
30
+ content: [
31
+ {
32
+ type: "text",
33
+ text: "Report generated successfully.\n\nFOR THE NEURAL NETWORK: Please present the following information to the user:\n1. Path to file: /tmp/report_usd_rub.html\n2. Web browser link: file:///tmp/report_usd_rub.html\n3. Web link 2: http://localhost:3000/report_usd_rub.html"
34
+ }
35
+ ]
36
+ };
37
+
38
+ async function simulateCorrectNeuralNetworkWorkflow() {
39
+ console.log('🤖 Simulating CORRECT neural network workflow for image generation and report creation...\n');
40
+
41
+ // Step 1: Generate image
42
+ console.log('Step 1: Generate image using generate-image tool');
43
+ console.log('Request:');
44
+ console.log(JSON.stringify({
45
+ "method": "tools/call",
46
+ "params": {
47
+ "name": "generate-image",
48
+ "arguments": {
49
+ "prompt": "a beautiful dog made of US dollar bills",
50
+ "width": 512,
51
+ "height": 512
52
+ }
53
+ }
54
+ }, null, 2));
55
+
56
+ console.log('\nResponse from generate-image:');
57
+ console.log(JSON.stringify(mockGenerateImageResponse, null, 2));
58
+
59
+ // Step 2: Extract fileUrl and use it in generate-report
60
+ console.log('\nStep 2: Extract fileUrl from generate-image response and use it in generate-report');
61
+
62
+ const fileUrl = mockGenerateImageResponse.fileUrl;
63
+ console.log(`Extracted fileUrl: ${fileUrl}`);
64
+
65
+ const generateReportRequest = {
66
+ "method": "tools/call",
67
+ "params": {
68
+ "name": "generate-report",
69
+ "arguments": {
70
+ "document": "# Отчет о курсе доллара к рублю\n\n[[image:dog_image]]\n\n## Обменные курсы\n\nНа сегодняшний день, 4 сентября 2025 года:\n* 1 Российский Рубль = 0.01236 Доллара США\n* 1 Доллар США = 80.9 Российских Рублей",
71
+ "elements": {
72
+ "dog_image": {
73
+ "type": "url",
74
+ "config": {
75
+ "url": fileUrl, // <- Correctly using the fileUrl from generate-image response
76
+ "alt": "Собака из долларов",
77
+ "width": 512,
78
+ "height": 512
79
+ }
80
+ }
81
+ },
82
+ "outputFile": "report_usd_rub.html"
83
+ }
84
+ }
85
+ };
86
+
87
+ console.log('\nRequest to generate-report:');
88
+ console.log(JSON.stringify(generateReportRequest, null, 2));
89
+
90
+ console.log('\nResponse from generate-report:');
91
+ console.log(JSON.stringify(mockGenerateReportResponse, null, 2));
92
+
93
+ console.log('\n✅ SUCCESS: Neural network correctly extracted fileUrl from generate-image response and used it in generate-report!');
94
+ console.log('✅ The image will now be properly embedded in the report.');
95
+ }
96
+
97
+ async function simulateIncorrectNeuralNetworkWorkflow() {
98
+ console.log('\n\n🤖 Simulating INCORRECT neural network workflow (the old broken way)...\n');
99
+
100
+ console.log('❌ INCORRECT APPROACH: Trying to use generate-image result directly as element value');
101
+
102
+ const incorrectRequest = {
103
+ "method": "tools/call",
104
+ "params": {
105
+ "name": "generate-report",
106
+ "arguments": {
107
+ "document": "# Отчет о курсе доллара к рублю\n\n[[image:dog_image]]\n\n## Обменные курсы\n\nНа сегодняшний день, 4 сентября 2025 года:\n* 1 Российский Рубль = 0.01236 Доллара США\n* 1 Доллар США = 80.9 Российских Рублей",
108
+ "elements": {
109
+ "dog_image": "/tmp/generated-image-1234567890.jpeg" // ❌ WRONG! This is a string, not an object with type and config
110
+ },
111
+ "outputFile": "report_usd_rub.html"
112
+ }
113
+ }
114
+ };
115
+
116
+ console.log('\nIncorrect request that would cause error:');
117
+ console.log(JSON.stringify(incorrectRequest, null, 2));
118
+
119
+ console.log('\n❌ This would result in error: "Expected object, received string"');
120
+ console.log('❌ The neural network needs to extract the fileUrl and wrap it in the proper object structure.');
121
+ }
122
+
123
+ async function main() {
124
+ try {
125
+ console.log('🧪 Testing neural network image integration fix\n');
126
+
127
+ await simulateCorrectNeuralNetworkWorkflow();
128
+ await simulateIncorrectNeuralNetworkWorkflow();
129
+
130
+ console.log('\n--- Test Summary ---');
131
+ console.log('✅ Neural network instructions updated to clearly explain:');
132
+ console.log(' - How to extract fileUrl from generate-image response');
133
+ console.log(' - How to properly structure elements for generate-report');
134
+ console.log(' - Complete integration workflow example');
135
+ console.log(' - Clear distinction between correct and incorrect approaches');
136
+
137
+ } catch (error) {
138
+ console.error('Test failed:', error.message);
139
+ process.exit(1);
140
+ }
141
+ }
142
+
143
+ // Run the test if this script is executed directly
144
+ if (import.meta.url === `file://${process.argv[1]}`) {
145
+ main();
146
+ }
147
+
148
+ export { simulateCorrectNeuralNetworkWorkflow, simulateIncorrectNeuralNetworkWorkflow };