Tools in Openwebui have access to some reserved variable names, for example to the attached files in a chat. For MCP this so far doesn't work. This PR introduces reserved variable names (to be more precise: files) to also work with MCP.
A MCP server that accepts files: dict get access to the file information
Example mcp tool:
@mcp.tool
def process_files(__files__: dict):
"""
give information on the attached file
"""
print(str(__files__))
return str(__files__)
This allows an mcp server, with minimal parsing of the dict to know the id and local url on the file server, making it easy to access files via api or on the local file structure to be processed within an mcp tool.
Added
reserved files word to also be considered for mcp tool calls.
Screenshots or Videos
This is the result of the above mcp tool
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/19241
**Author:** [@tobiasbaur](https://github.com/tobiasbaur)
**Created:** 11/17/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `dev`
---
### 📝 Commits (1)
- [`f89e549`](https://github.com/open-webui/open-webui/commit/f89e549a4da90cfd064a8813d8f23a792cf4e08d) Update middleware.py
### 📊 Changes
**1 file changed** (+4 additions, -0 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/utils/middleware.py` (+4 -0)
</details>
### 📄 Description
### Description
- Tools in Openwebui have access to some reserved variable names, for example to the attached files in a chat. For MCP this so far doesn't work. This PR introduces reserved variable names (to be more precise: __files__) to also work with MCP.
A MCP server that accepts __files__: dict get access to the file information
Example mcp tool:
```
@mcp.tool
def process_files(__files__: dict):
"""
give information on the attached file
"""
print(str(__files__))
return str(__files__)
```
This allows an mcp server, with minimal parsing of the dict to know the id and local url on the file server, making it easy to access files via api or on the local file structure to be processed within an mcp tool.
### Added
- reserved __files__ word to also be considered for mcp tool calls.
### Screenshots or Videos
<img width="1054" height="522" alt="Screenshot 2025-11-17 at 21 04 45" src="https://github.com/user-attachments/assets/154cee98-6bf5-48e7-8fd2-59a8ae1e0fdc" />
This is the result of the above mcp tool
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/19241
Author: @tobiasbaur
Created: 11/17/2025
Status: ❌ Closed
Base:
dev← Head:dev📝 Commits (1)
f89e549Update middleware.py📊 Changes
1 file changed (+4 additions, -0 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+4 -0)📄 Description
Description
A MCP server that accepts files: dict get access to the file information
Example mcp tool:
This allows an mcp server, with minimal parsing of the dict to know the id and local url on the file server, making it easy to access files via api or on the local file structure to be processed within an mcp tool.
Added
Screenshots or Videos
This is the result of the above mcp tool
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.