[PR #24272] test: cover MCP resource tool results #66427

Open
opened 2026-05-06 12:47:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24272
Author: @Genmin
Created: 5/1/2026
Status: 🔄 Open

Base: devHead: codex/test-mcp-resource-tool-results


📝 Commits (1)

  • 9b200a1 test: 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

  • Target branch: this PR targets dev.
  • Description: MCP tool result text extraction now handles both text content and MCP resource text payloads through a focused helper.
  • Changelog: included below.
  • Documentation: no user-facing docs needed; this is internal result handling plus regression tests.
  • Dependencies: no dependency changes.
  • 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.
  • Code review: reviewed the helper to preserve existing text content behavior and ignore non-text resources.
  • Design & Architecture: keeps middleware logic small and extracts parsing into a testable helper.
  • Git Hygiene: rebased onto dev; one logical change.
  • 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


🔄 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>
GiteaMirror added the pull-request label 2026-05-06 12:47:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#66427