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/24272
**Author:** [@Genmin](https://github.com/Genmin)
**Created:** 5/1/2026
**Status:** 🔄 Open
**Base:** `dev` ← **Head:** `codex/test-mcp-resource-tool-results`
---
### 📝 Commits (1)
- [`9b200a1`](https://github.com/open-webui/open-webui/commit/9b200a185f38e85d7f0c3c8f16a8786982f8ff7b) test: cover MCP resource tool results
### 📊 Changes
**3 files changed** (+83 additions, -16 deletions)
<details>
<summary>View changed files</summary>
➕ `backend/open_webui/test/utils/test_mcp_results.py` (+55 -0)
➕ `backend/open_webui/utils/mcp/results.py` (+25 -0)
📝 `backend/open_webui/utils/middleware.py` (+3 -16)
</details>
### 📄 Description
## Pull Request Checklist
- [x] Target branch: this PR targets `dev`.
- [x] Description: MCP tool result text extraction now handles both text content and MCP resource text payloads through a focused helper.
- [x] Changelog: included below.
- [x] Documentation: no user-facing docs needed; this is internal result handling plus regression tests.
- [x] Dependencies: no dependency changes.
- [x] Testing: focused automated tests and compile checks are listed below.
- [ ] Agentic AI Code: not checked here; Genmin should confirm this according to project policy if needed.
- [x] Code review: reviewed the helper to preserve existing text content behavior and ignore non-text resources.
- [x] Design & Architecture: keeps middleware logic small and extracts parsing into a testable helper.
- [x] Git Hygiene: rebased onto `dev`; one logical change.
- [x] Title Prefix: uses `test:`.
## Changelog Entry
### Description
- Add regression coverage for MCP resource text results and route result extraction through a reusable helper.
### Added
- Tests for MCP `resource.text` payloads containing JSON and plain text.
- Tests preserving existing text content JSON parsing and ignoring non-text resources.
### Changed
- `process_tool_result` now delegates MCP text/resource extraction to a focused helper.
### Deprecated
- None.
### Removed
- None.
### Fixed
- Prevents MCP text resources from being silently omitted when a tool returns data in a resource content item.
### Security
- None.
### Breaking Changes
- None.
---
### Additional Information
Refs #24038.
Validation run:
- `PYTHONPATH=backend uv run --no-sync --with pytest --with typer --with uvicorn pytest backend/open_webui/test/utils/test_mcp_results.py -q`
- `uv run --no-sync --with ruff ruff check backend/open_webui/utils/mcp/results.py backend/open_webui/test/utils/test_mcp_results.py`
- `PYTHONPATH=backend uv run --no-sync --with typer --with uvicorn python -m compileall -q backend/open_webui/utils/mcp/results.py backend/open_webui/test/utils/test_mcp_results.py`
- `git diff --check`
### Screenshots or Videos
- Not applicable; backend result handling tests.
### Contributor License Agreement
- [x] 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/24272
Author: @Genmin
Created: 5/1/2026
Status: 🔄 Open
Base:
dev← Head:codex/test-mcp-resource-tool-results📝 Commits (1)
9b200a1test: cover MCP resource tool results📊 Changes
3 files changed (+83 additions, -16 deletions)
View changed files
➕
backend/open_webui/test/utils/test_mcp_results.py(+55 -0)➕
backend/open_webui/utils/mcp/results.py(+25 -0)📝
backend/open_webui/utils/middleware.py(+3 -16)📄 Description
Pull Request Checklist
dev.dev; one logical change.test:.Changelog Entry
Description
Added
resource.textpayloads containing JSON and plain text.Changed
process_tool_resultnow delegates MCP text/resource extraction to a focused helper.Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Refs #24038.
Validation run:
PYTHONPATH=backend uv run --no-sync --with pytest --with typer --with uvicorn pytest backend/open_webui/test/utils/test_mcp_results.py -quv run --no-sync --with ruff ruff check backend/open_webui/utils/mcp/results.py backend/open_webui/test/utils/test_mcp_results.pyPYTHONPATH=backend uv run --no-sync --with typer --with uvicorn python -m compileall -q backend/open_webui/utils/mcp/results.py backend/open_webui/test/utils/test_mcp_results.pygit diff --checkScreenshots or Videos
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.