[PR #24045] [CLOSED] fix: handle 'resource' content type in process_tool_result for MCP tools #66346

Closed
opened 2026-05-06 12:39:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24045
Author: @franciseliang99-dot
Created: 4/23/2026
Status: Closed

Base: devHead: fix/mcp-resource-type


📝 Commits (2)

  • ec1ffb6 fix: handle 'resource' content type in process_tool_result for MCP tools
  • 2a9128f fix: guard against non-dict 'resource' field in MCP tool result

📊 Changes

1 file changed (+11 additions, -0 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+11 -0)

📄 Description

MCP servers can return tool results with type: "resource" (per the MCP spec), but process_tool_result() in backend/open_webui/utils/middleware.py only handles text, image, and audio. Resource-type items fall through without being appended to tool_response, leaving it empty, so the LLM receives {"results": []} and reports that the server returned no data.

This adds an elif item.get('type') == 'resource' branch that extracts resource.text and attempts a JSON parse — structured payloads (e.g. lists of records) survive as proper data, and plain-text resources fall back to the raw string. The logic mirrors the existing text branch.

Closes #24038

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/24045 **Author:** [@franciseliang99-dot](https://github.com/franciseliang99-dot) **Created:** 4/23/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/mcp-resource-type` --- ### 📝 Commits (2) - [`ec1ffb6`](https://github.com/open-webui/open-webui/commit/ec1ffb631509d3373b06d7db39d2419e4f598c6b) fix: handle 'resource' content type in process_tool_result for MCP tools - [`2a9128f`](https://github.com/open-webui/open-webui/commit/2a9128fd5b5cc6deb9e8b46d6cdb27a50dc2cf2c) fix: guard against non-dict 'resource' field in MCP tool result ### 📊 Changes **1 file changed** (+11 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+11 -0) </details> ### 📄 Description MCP servers can return tool results with `type: "resource"` (per the MCP spec), but `process_tool_result()` in `backend/open_webui/utils/middleware.py` only handles `text`, `image`, and `audio`. Resource-type items fall through without being appended to `tool_response`, leaving it empty, so the LLM receives `{"results": []}` and reports that the server returned no data. This adds an `elif item.get('type') == 'resource'` branch that extracts `resource.text` and attempts a JSON parse — structured payloads (e.g. lists of records) survive as proper data, and plain-text resources fall back to the raw string. The logic mirrors the existing `text` branch. Closes #24038 ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [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. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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:39:51 -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#66346