@vint.tri/report_gen_mcp 1.3.5 → 1.3.7
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/IMAGE_GENERATION_FIX.md +68 -0
- package/IMAGE_TOOLS_CONFIG.md +143 -0
- package/PUBLICATION_CONFIRMATION.md +39 -17
- package/README.md +96 -458
- package/TODO.md +35 -7
- package/VERSION_1.3.6_RELEASE_NOTES.md +60 -0
- package/VERSION_1.3.7_RELEASE_NOTES.md +17 -0
- package/dist/index.js +113 -1
- package/image_gen_py/image.json +45 -0
- package/image_gen_py/mcp_image_edit.py +434 -0
- package/image_gen_py/mcp_img_gen.py +403 -0
- package/package.json +14 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Исправление проблемы с зацикливанием MCP сервера при генерации изображений
|
|
2
|
+
|
|
3
|
+
## Проблема
|
|
4
|
+
MCP сервер зацикливается при попытке генерации изображений, выдавая сообщение:
|
|
5
|
+
```
|
|
6
|
+
report_gen_mcp : generate-image
|
|
7
|
+
Завершено
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
"params": {
|
|
11
|
+
"prompt": "lizard at his wedding yelling bitter to his bride",
|
|
12
|
+
"width": 1024,
|
|
13
|
+
"height": 1024,
|
|
14
|
+
"model": "JuggernautXL",
|
|
15
|
+
"outputFile": "lizard_wedding.png"
|
|
16
|
+
},
|
|
17
|
+
"response": {
|
|
18
|
+
"content": [
|
|
19
|
+
{
|
|
20
|
+
"type": "text",
|
|
21
|
+
"text": "Image generation tool registered. In a full implementation, this would generate an image with the prompt: \"lizard at his wedding yelling bitter to his bride\"."
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Хотя пользователю не нужна функциональность генерации изображений, сервер продолжает пытаться обработать этот запрос, что приводит к зацикливанию.
|
|
29
|
+
|
|
30
|
+
## Причина проблемы
|
|
31
|
+
Инструменты генерации и редактирования изображений были зарегистрированы в MCP сервере, но не имели корректной реализации для вызова Python скриптов. Кроме того, не проверялось наличие необходимой переменной окружения `CHUTES_API_TOKEN`.
|
|
32
|
+
|
|
33
|
+
## Решение
|
|
34
|
+
1. Добавлена проверка наличия переменной окружения `CHUTES_API_TOKEN` в инструментах `generate-image` и `edit-image`
|
|
35
|
+
2. При отсутствии токена инструменты возвращают понятное сообщение о том, что функциональность отключена
|
|
36
|
+
3. Это предотвращает зацикливание сервера и позволяет корректно обрабатывать другие команды
|
|
37
|
+
|
|
38
|
+
## Изменения в коде
|
|
39
|
+
В файле `src/index.ts` в инструменты `generate-image` и `edit-image` добавлена проверка:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
// Check if CHUTES_API_TOKEN is set
|
|
43
|
+
if (!process.env.CHUTES_API_TOKEN) {
|
|
44
|
+
// Return a clear message that image generation is disabled
|
|
45
|
+
return {
|
|
46
|
+
content: [{
|
|
47
|
+
type: "text",
|
|
48
|
+
text: `Image generation is disabled because CHUTES_API_TOKEN environment variable is not set. To enable image generation, please set the CHUTES_API_TOKEN environment variable.`
|
|
49
|
+
}]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Инструкция по использованию
|
|
55
|
+
Для включения функциональности генерации изображений необходимо:
|
|
56
|
+
1. Установить Python зависимости:
|
|
57
|
+
```bash
|
|
58
|
+
npm run install-python-deps
|
|
59
|
+
```
|
|
60
|
+
2. Установить переменную окружения `CHUTES_API_TOKEN` с вашим токеном API:
|
|
61
|
+
```bash
|
|
62
|
+
export CHUTES_API_TOKEN=your_api_token_here
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Без установки токена инструменты генерации изображений будут отключены, но сервер будет работать корректно без зацикливания.
|
|
66
|
+
|
|
67
|
+
## Тестирование
|
|
68
|
+
После внесения изменений сервер корректно обрабатывает команды и не зацикливается на генерации изображений при отсутствии токена API.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Image Tools Configuration
|
|
2
|
+
|
|
3
|
+
This document explains how to configure and use the image generation and editing tools in the Report Generator MCP.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
1. Python 3.7 or higher
|
|
8
|
+
2. Required Python packages:
|
|
9
|
+
- `mcp` (Model Context Protocol SDK)
|
|
10
|
+
- `aiohttp`
|
|
11
|
+
|
|
12
|
+
Install the required packages:
|
|
13
|
+
```bash
|
|
14
|
+
pip install -r src/python/requirements.txt
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or use the npm script:
|
|
18
|
+
```bash
|
|
19
|
+
npm run install-python-deps
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Environment Variables
|
|
23
|
+
|
|
24
|
+
The following environment variables are required for the image tools to work:
|
|
25
|
+
|
|
26
|
+
- `CHUTES_API_TOKEN`: Your API token for Chutes AI services
|
|
27
|
+
- `IMG_SAVE_BASE_DIR`: Base directory for saving generated/edited images (optional)
|
|
28
|
+
|
|
29
|
+
Optional environment variables for image generation:
|
|
30
|
+
- `SD_MODEL`: Default model for image generation (default: "JuggernautXL")
|
|
31
|
+
- `SD_WIDTH`: Default width for generated images (default: 1024)
|
|
32
|
+
- `SD_HEIGHT`: Default height for generated images (default: 1024)
|
|
33
|
+
- `SD_GUIDANCE_SCALE`: Default guidance scale (default: 7.5)
|
|
34
|
+
- `SD_NEGATIVE_PROMPT`: Default negative prompt (default: "")
|
|
35
|
+
- `SD_NUM_INFERENCE_STEPS`: Default number of inference steps (default: 25)
|
|
36
|
+
- `SD_SEED`: Default seed (default: 0)
|
|
37
|
+
|
|
38
|
+
Optional environment variables for image editing:
|
|
39
|
+
- `EDIT_WIDTH`: Default width for edited images (default: 1024)
|
|
40
|
+
- `EDIT_HEIGHT`: Default height for edited images (default: 1024)
|
|
41
|
+
- `EDIT_CFG_SCALE`: Default CFG scale (default: 4.0)
|
|
42
|
+
- `EDIT_NEGATIVE_PROMPT`: Default negative prompt (default: "")
|
|
43
|
+
- `EDIT_INFERENCE_STEPS`: Default number of inference steps (default: 50)
|
|
44
|
+
|
|
45
|
+
## Image Generation Tool
|
|
46
|
+
|
|
47
|
+
### Tool Name
|
|
48
|
+
`generate-image`
|
|
49
|
+
|
|
50
|
+
### Description
|
|
51
|
+
Generate an image using AI based on a text prompt.
|
|
52
|
+
|
|
53
|
+
### Parameters
|
|
54
|
+
- `prompt` (string, required): Text prompt for image generation (must be in English)
|
|
55
|
+
- `width` (number, optional): Width of the image in pixels (128-2048, default: 1024)
|
|
56
|
+
- `height` (number, optional): Height of the image in pixels (128-2048, default: 1024)
|
|
57
|
+
- `model` (string, optional): Model to use for image generation (default: "JuggernautXL")
|
|
58
|
+
- `guidanceScale` (number, optional): Guidance scale for image generation (1.0-20.0, default: 7.5)
|
|
59
|
+
- `negativePrompt` (string, optional): Negative prompt for things to exclude from the image (default: "")
|
|
60
|
+
- `numInferenceSteps` (number, optional): Number of inference steps (1-50, default: 25)
|
|
61
|
+
- `seed` (number, optional): Seed for reproducibility (0 = random, default: 0)
|
|
62
|
+
- `outputFile` (string, optional): Output file path for saving the image
|
|
63
|
+
|
|
64
|
+
### Example Usage
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"name": "generate-image",
|
|
68
|
+
"arguments": {
|
|
69
|
+
"prompt": "A beautiful landscape with mountains and lakes",
|
|
70
|
+
"width": 1024,
|
|
71
|
+
"height": 768,
|
|
72
|
+
"model": "JuggernautXL",
|
|
73
|
+
"guidanceScale": 7.5,
|
|
74
|
+
"negativePrompt": "blurry, low quality",
|
|
75
|
+
"numInferenceSteps": 30,
|
|
76
|
+
"seed": 12345
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Image Editing Tool
|
|
82
|
+
|
|
83
|
+
### Tool Name
|
|
84
|
+
`edit-image`
|
|
85
|
+
|
|
86
|
+
### Description
|
|
87
|
+
Edit an existing image using AI based on a text prompt.
|
|
88
|
+
|
|
89
|
+
### Parameters
|
|
90
|
+
- `prompt` (string, required): Text prompt for image editing (must be in English)
|
|
91
|
+
- `imagePath` (string, required): Path to the input image file
|
|
92
|
+
- `output_path` (string, required): Path for the output edited image file
|
|
93
|
+
- `width` (number, optional): Width of the edited image in pixels (512-2048, default: 1024)
|
|
94
|
+
- `height` (number, optional): Height of the edited image in pixels (512-2048, default: 1024)
|
|
95
|
+
- `cfgScale` (number, optional): CFG scale for image editing (1.0-10.0, default: 4.0)
|
|
96
|
+
- `negativePrompt` (string, optional): Negative prompt for things to exclude from the edited image (default: "")
|
|
97
|
+
- `numInferenceSteps` (number, optional): Number of inference steps (10-100, default: 50)
|
|
98
|
+
- `seed` (number, optional): Seed for reproducibility (leave empty for random)
|
|
99
|
+
|
|
100
|
+
### Example Usage
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"name": "edit-image",
|
|
104
|
+
"arguments": {
|
|
105
|
+
"prompt": "Add a sunset to this landscape",
|
|
106
|
+
"imagePath": "/path/to/input/image.jpg",
|
|
107
|
+
"output_path": "/path/to/output/edited_image.jpg",
|
|
108
|
+
"width": 1024,
|
|
109
|
+
"height": 768,
|
|
110
|
+
"cfgScale": 4.0,
|
|
111
|
+
"negativePrompt": "blurry, low quality",
|
|
112
|
+
"numInferenceSteps": 50,
|
|
113
|
+
"seed": 12345
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Integration with Report Generation
|
|
119
|
+
|
|
120
|
+
The image tools can be used independently or integrated with the report generation tool. When used with the report generator, you can embed generated or edited images directly into your reports using the `[[image:id]]` placeholder syntax.
|
|
121
|
+
|
|
122
|
+
### Example Report with Generated Image
|
|
123
|
+
```markdown
|
|
124
|
+
# My Report
|
|
125
|
+
|
|
126
|
+
This is a sample report with an AI-generated image.
|
|
127
|
+
|
|
128
|
+
[[image:landscape]]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
With corresponding elements:
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"landscape": {
|
|
135
|
+
"type": "pollinations",
|
|
136
|
+
"config": {
|
|
137
|
+
"prompt": "A beautiful landscape with mountains and lakes"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Note: Currently, the integration uses Pollinations.ai for image generation within reports. The standalone image tools use Chutes AI for more advanced generation and editing capabilities.
|
|
@@ -1,26 +1,48 @@
|
|
|
1
|
-
# Publication Confirmation
|
|
1
|
+
# Publication Confirmation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Version 1.3.6 of @vint.tri/report_gen_mcp has been successfully published to npm.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Published Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
The published package includes all the new image generation and editing capabilities:
|
|
8
|
+
|
|
9
|
+
1. **Image Generation Tool** (`generate-image`):
|
|
10
|
+
- Creates images from text prompts using Chutes AI
|
|
11
|
+
- Configurable parameters: dimensions, models, guidance scales, etc.
|
|
12
|
+
|
|
13
|
+
2. **Image Editing Tool** (`edit-image`):
|
|
14
|
+
- Modifies existing images based on text descriptions
|
|
15
|
+
- Supports various editing parameters and customization options
|
|
16
|
+
|
|
17
|
+
3. **Python Integration**:
|
|
18
|
+
- Includes Python scripts for both image generation and editing
|
|
19
|
+
- Requirements file for easy dependency installation
|
|
20
|
+
|
|
21
|
+
4. **Documentation**:
|
|
22
|
+
- Updated README with image capabilities
|
|
23
|
+
- Detailed configuration guide (IMAGE_TOOLS_CONFIG.md)
|
|
24
|
+
- Comprehensive release notes (VERSION_1.3.6_RELEASE_NOTES.md)
|
|
11
25
|
|
|
12
26
|
## Verification
|
|
13
27
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
28
|
+
- Package version: 1.3.6 ✓
|
|
29
|
+
- NPM registry confirmation: ✓
|
|
30
|
+
- Build verification: ✓
|
|
31
|
+
- Tool registration testing: ✓
|
|
32
|
+
|
|
33
|
+
## Next Steps
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
Users can now install the updated package with:
|
|
36
|
+
```bash
|
|
37
|
+
npm install @vint.tri/report_gen_mcp@1.3.6
|
|
38
|
+
```
|
|
20
39
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
40
|
+
Or globally:
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g @vint.tri/report_gen_mcp@1.3.6
|
|
43
|
+
```
|
|
25
44
|
|
|
26
|
-
|
|
45
|
+
To use the new image features, users will need to:
|
|
46
|
+
1. Install Python dependencies: `npm run install-python-deps`
|
|
47
|
+
2. Set the CHUTES_API_TOKEN environment variable
|
|
48
|
+
3. (For full implementation) Extend the TypeScript code to properly call Python scripts via child_process
|