Skip to content

Commit 52c9296

Browse files
authored
Merge pull request #11 from Baronco/dev
This release is **v0.2.1**. It introduces a new environment variable …
2 parents 9c9a0a8 + fde7e82 commit 52c9296

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ GenFilesMCP is a Model Context Protocol (MCP) server that generates PowerPoint,
3434

3535
## Status
3636

37-
This is the **first stable version (v0.2.0)** designed for multi-user environments. It includes enhanced security, user-specific knowledge base integration, and improved document management.
37+
This release is **v0.2.1**. It introduces a new environment variable `ENABLE_CREATE_KNOWLEDGE` that lets deployments choose whether generated or reviewed files are automatically added to users' knowledge collections. This enables coexistence between RAG-preserving deployments (do not enable knowledge creation) and deployments that want generated files saved to knowledge collections (requires enabling the Open Web UI document option `Bypass Embedding and Retrieval`). The original behavior (downloading files from chats) remains unchanged for end users.
3838

3939
## Prerequisites
4040

@@ -49,19 +49,29 @@ This is the **first stable version (v0.2.0)** designed for multi-user environmen
4949
Pull the pre-built Docker image from GitHub Container Registry:
5050

5151
```bash
52-
docker pull ghcr.io/baronco/genfilesmcp:v0.2.0
52+
docker pull ghcr.io/baronco/genfilesmcp:v0.2.1
5353
```
5454

5555
Run the container:
5656

5757
```bash
58-
docker run -d --restart unless-stopped -p YOUR_PORT:YOUR_PORT -e OWUI_URL="http://host.docker.internal:3000" -e PORT=YOUR_PORT --name gen_files_mcp gen_files_mcp ghcr.io/baronco/genfilesmcp:v0.2.0
58+
docker run -d --restart unless-stopped -p YOUR_PORT:YOUR_PORT \
59+
-e OWUI_URL="http://host.docker.internal:3000" \
60+
-e PORT=YOUR_PORT \
61+
-e ENABLE_CREATE_KNOWLEDGE=false \
62+
--name gen_files_mcp \
63+
ghcr.io/baronco/genfilesmcp:v0.2.1
5964
```
6065

6166
Alternatively, use the `:latest` tag for the most recent version:
6267

6368
```bash
64-
docker run -d --restart unless-stopped -p YOUR_PORT:YOUR_PORT -e OWUI_URL="http://host.docker.internal:3000" -e PORT=YOUR_PORT --name gen_files_mcp gen_files_mcp ghcr.io/baronco/genfilesmcp:latest
69+
docker run -d --restart unless-stopped -p YOUR_PORT:YOUR_PORT \
70+
-e OWUI_URL="http://host.docker.internal:3000" \
71+
-e PORT=YOUR_PORT \
72+
-e ENABLE_CREATE_KNOWLEDGE=false \
73+
--name gen_files_mcp \
74+
ghcr.io/baronco/genfilesmcp:latest
6575
```
6676

6777
### Option 2: Building from Source
@@ -88,6 +98,7 @@ docker run -d --restart unless-stopped \
8898
-p YOUR_PORT:YOUR_PORT \
8999
-e OWUI_URL="http://host.docker.internal:3000" \
90100
-e PORT=YOUR_PORT \
101+
-e ENABLE_CREATE_KNOWLEDGE=false \
91102
--name gen_files_mcp \
92103
genfilesmcp
93104
```
@@ -102,6 +113,7 @@ The MCP server requires the following environment variables:
102113
|----------|-------------|---------|
103114
| `OWUI_URL` | URL of your Open Web UI instance | `http://host.docker.internal:3000` |
104115
| `PORT` | Port where the MCP server will listen | `8015` |
116+
| `ENABLE_CREATE_KNOWLEDGE` | Controls whether generated or reviewed files are automatically added to users' knowledge collections. Set to `true` to enable automatic creation/updating of knowledge collections; set to `false` to disable that behavior and preserve RAG workflows (recommended default for RAG users). NOTE: If `ENABLE_CREATE_KNOWLEDGE=true`, it is mandatory to enable the Open Web UI document option `Bypass Embedding and Retrieval`. | `false` |
105117

106118
### MCP Configuration in Open Web UI
107119

@@ -202,7 +214,11 @@ This version integrates with Open Web UI's knowledge base system:
202214

203215
### MCP Server Document Upload Settings
204216

205-
To ensure that the upload of documents generated or reviewed by AI via the MCP server works for users or administrators, the `'Bypass Embedding and Retrieval'` option must be `enabled` in the Document options. Currently, I don't find an explanation of why, but to manage the knowledge of generated documents, it must be done.
217+
To support automatic creation of knowledge collections for files generated or reviewed by the MCP server, the Open Web UI document option `Bypass Embedding and Retrieval` must be enabled. This is required only when `ENABLE_CREATE_KNOWLEDGE=true`.
218+
219+
Behavior summary:
220+
- If `ENABLE_CREATE_KNOWLEDGE=false` (default recommended for RAG users): The MCP server will NOT create or update knowledge collections for generated/reviewed files. Users who rely on RAG or do not want knowledge collections created can keep this setting disabled and do NOT enable `Bypass Embedding and Retrieval`. Users will still be able to download generated/reviewed files from their chats as before.
221+
- If `ENABLE_CREATE_KNOWLEDGE=true`: The MCP server will attempt to create/update per-user knowledge collections for generated/reviewed files. In this mode, you MUST enable `Bypass Embedding and Retrieval` in the Open Web UI document options so the knowledge creation/upload flow works correctly.
206222

207223
<div style="text-align: center;">
208224

server.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
from utils.load_md_templates import load_md_templates
2121
from utils.upload_file import upload_file
2222
from utils.download_file import download_file
23-
from utils.knowledge import create_knowledge, add_file_to_knowledge
23+
from utils.knowledge import create_knowledge
2424

2525
# Parameters
2626
URL = getenv('OWUI_URL',)
2727
PORT = int(getenv('PORT'))
2828
POWERPOINT_TEMPLATE, EXCEL_TEMPLATE, WORD_TEMPLATE,MARKDOWN_TEMPLATE, MCP_INSTRUCTIONS = load_md_templates()
29+
# Enable or disable automatic creation of knowledge collections after upload
30+
# Defaults to true to preserve existing behavior. Set to 'false' to disable.
31+
ENABLE_CREATE_KNOWLEDGE = getenv('ENABLE_CREATE_KNOWLEDGE', 'true').lower() == 'true'
2932

3033
# Pydantic model for review comments
3134
class ReviewComment(BaseModel):
@@ -94,7 +97,7 @@ async def generate_powerpoint(
9497
)
9598

9699
# If upload is successful, add to knowledge base
97-
if "file_path_download" in response:
100+
if "file_path_download" in response and ENABLE_CREATE_KNOWLEDGE:
98101
# create knowledge base if not exists
99102
create_knowledge_status = create_knowledge(
100103
url=URL,
@@ -106,8 +109,10 @@ async def generate_powerpoint(
106109
logger.info("Knowledge base updated successfully.")
107110
else:
108111
logger.error(f"Error creating or updating knowledge base")
112+
elif "error" in response:
113+
logger.error(f"Error uploading the file.")
109114
else:
110-
logger.error(f"Error uploading file to knowledge base")
115+
logger.info("Skipping knowledge creation because ENABLE_CREATE_KNOWLEDGE is false")
111116

112117
return response
113118

@@ -176,7 +181,7 @@ async def generate_excel(
176181
)
177182

178183
# If upload is successful, add to knowledge base
179-
if "file_path_download" in response:
184+
if "file_path_download" in response and ENABLE_CREATE_KNOWLEDGE:
180185
# create knowledge base if not exists
181186
create_knowledge_status = create_knowledge(
182187
url=URL,
@@ -188,8 +193,10 @@ async def generate_excel(
188193
logger.info("Knowledge base updated successfully.")
189194
else:
190195
logger.error(f"Error creating or updating knowledge base")
196+
elif "error" in response:
197+
logger.error(f"Error uploading the file.")
191198
else:
192-
logger.error(f"Error uploading file to knowledge base")
199+
logger.info("Skipping knowledge creation because ENABLE_CREATE_KNOWLEDGE is false")
193200

194201
return response
195202

@@ -258,7 +265,7 @@ async def generate_word(
258265
)
259266

260267
# If upload is successful, add to knowledge base
261-
if "file_path_download" in response:
268+
if "file_path_download" in response and ENABLE_CREATE_KNOWLEDGE:
262269
# create knowledge base if not exists
263270
create_knowledge_status = create_knowledge(
264271
url=URL,
@@ -270,8 +277,10 @@ async def generate_word(
270277
logger.info("Knowledge base updated successfully.")
271278
else:
272279
logger.error(f"Error creating or updating knowledge base")
280+
elif "error" in response:
281+
logger.error(f"Error uploading the file.")
273282
else:
274-
logger.error(f"Error uploading file to knowledge base")
283+
logger.info("Skipping knowledge creation because ENABLE_CREATE_KNOWLEDGE is false")
275284

276285
return response
277286

@@ -340,7 +349,7 @@ async def generate_markdown(
340349
)
341350

342351
# If upload is successful, add to knowledge base
343-
if "file_path_download" in response:
352+
if "file_path_download" in response and ENABLE_CREATE_KNOWLEDGE:
344353
# create knowledge base if not exists
345354
create_knowledge_status = create_knowledge(
346355
url=URL,
@@ -352,8 +361,10 @@ async def generate_markdown(
352361
logger.info("Knowledge base updated successfully.")
353362
else:
354363
logger.error(f"Error creating or updating knowledge base")
364+
elif "error" in response:
365+
logger.error(f"Error uploading the file.")
355366
else:
356-
logger.error(f"Error uploading file to knowledge base")
367+
logger.info("Skipping knowledge creation because ENABLE_CREATE_KNOWLEDGE is false")
357368

358369
return response
359370

@@ -544,7 +555,7 @@ async def review_docx(
544555
)
545556

546557
# If upload is successful, add to knowledge base
547-
if "file_path_download" in response:
558+
if "file_path_download" in response and ENABLE_CREATE_KNOWLEDGE:
548559
# create knowledge base if not exists
549560
create_knowledge_status = create_knowledge(
550561
url=URL,
@@ -557,8 +568,10 @@ async def review_docx(
557568
logger.info("Knowledge base updated successfully.")
558569
else:
559570
logger.error(f"Error creating or updating knowledge base")
571+
elif "error" in response:
572+
logger.error(f"Error uploading the file.")
560573
else:
561-
logger.error(f"Error uploading file to knowledge base")
574+
logger.info("Skipping knowledge creation because ENABLE_CREATE_KNOWLEDGE is false")
562575

563576
return response
564577

utils/upload_file.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def upload_file(url: str, token: str, file_data: BytesIO, filename:str, file_typ
4444
if response.status_code != 200:
4545
return dumps({"error":{"message": f'Error uploading file: {response.status_code}, {response.text}'}}), response
4646
elif response.status_code == 200:
47-
return dumps(
48-
{
47+
return dumps({
4948
"file_path_download": f"[Download {filename}.{file_type}](/api/v1/files/{response.json()['id']}/content)"
5049
},
5150
indent=4,

0 commit comments

Comments
 (0)