[PR #18892] [CLOSED] fix: Enhance error handling of mcp server in chat payload processing by emitting error events to the frontend. #25015

Closed
opened 2026-04-20 05:42:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/18892
Author: @mmlmt2604
Created: 11/3/2025
Status: Closed

Base: devHead: mcp_server_fail_handle


📝 Commits (1)

  • 002568e Enhance error handling of mcp server in chat payload processing by emitting error events to the frontend.

📊 Changes

1 file changed (+12 additions, -1 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+12 -1)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Verify that the pull request targets the dev branch. Not targeting the dev branch may lead to immediate closure of the PR.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: If necessary, update relevant documentation Open WebUI Docs like environment variables, the tutorials, or other documentation sources.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description.
  • Agentic AI Code:: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review and manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

  • 🔔 MCP server connection failures now emit error notifications to users, ensuring connection issues are visible instead of silently failing. Previously, MCP connection errors were only logged at debug level without user notification.

Description

When an MCP server connection fails (e.g., server not found, 401 unauthorized, network error), the exception is caught but not surfaced to the user. The chat request continues without MCP tools, producing a response that appears normal. Users have no indication that MCP tools were unavailable, which is misleading.

Root cause:
Connection exceptions are caught during MCP initialization, logged at debug level, and execution continues silently. No error is emitted to the frontend, so users don't know MCP tools were skipped.

Solution:
Emit error events to the frontend when MCP connection fails, following the existing error handling pattern. Users are notified via chat error messages when MCP servers fail to connect, providing visibility into tool availability.

Screenshot 2025-11-03 at 11 52 02 PM

Added

  • [List any new features, functionalities, or additions]

Changed

  • Modified the exception handler in process_chat_payload() to emit error events when MCP connection fails

Deprecated

  • [List any deprecated functionality or features that have been removed]

Removed

  • [List any removed features, files, or functionalities]

Fixed

  • Fixed an issue where MCP server connection failures were silently ignored, causing chat responses to be generated without MCP tools without user notification

Security

  • [List any new or updated security-related changes, including vulnerability fixes]

Breaking Changes

  • BREAKING CHANGE: [List any breaking changes affecting compatibility or functionality]

Additional Information

  • [Insert any additional context, notes, or explanations for the changes]
    • [Reference any related issues, commits, or other relevant information]

Screenshots or Videos

  • [Attach any relevant screenshots or videos demonstrating the changes]

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/18892 **Author:** [@mmlmt2604](https://github.com/mmlmt2604) **Created:** 11/3/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `mcp_server_fail_handle` --- ### 📝 Commits (1) - [`002568e`](https://github.com/open-webui/open-webui/commit/002568e7bc63c9b1b074d988bfc526ba9fd28db4) Enhance error handling of mcp server in chat payload processing by emitting error events to the frontend. ### 📊 Changes **1 file changed** (+12 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+12 -1) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Verify that the pull request targets the `dev` branch. Not targeting the `dev` branch may lead to immediate closure of the PR. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** If necessary, update relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs) like environment variables, the tutorials, or other documentation sources. - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description. - [x] **Agentic AI Code:**: Confirm this Pull Request is **not written by any AI Agent** or has at least gone through additional human review **and** manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR. - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry - 🔔 MCP server connection failures now emit error notifications to users, ensuring connection issues are visible instead of silently failing. Previously, MCP connection errors were only logged at debug level without user notification. ### Description When an MCP server connection fails (e.g., server not found, 401 unauthorized, network error), the exception is caught but not surfaced to the user. The chat request continues without MCP tools, producing a response that appears normal. Users have no indication that MCP tools were unavailable, which is misleading. Root cause: Connection exceptions are caught during MCP initialization, logged at debug level, and execution continues silently. No error is emitted to the frontend, so users don't know MCP tools were skipped. Solution: Emit error events to the frontend when MCP connection fails, following the existing error handling pattern. Users are notified via chat error messages when MCP servers fail to connect, providing visibility into tool availability. <img width="1122" height="691" alt="Screenshot 2025-11-03 at 11 52 02 PM" src="https://github.com/user-attachments/assets/a3a37eab-3d7f-4652-b72b-5d630f36635a" /> ### Added - [List any new features, functionalities, or additions] ### Changed - Modified the exception handler in `process_chat_payload()` to emit error events when MCP connection fails ### Deprecated - [List any deprecated functionality or features that have been removed] ### Removed - [List any removed features, files, or functionalities] ### Fixed - Fixed an issue where MCP server connection failures were silently ignored, causing chat responses to be generated without MCP tools without user notification ### Security - [List any new or updated security-related changes, including vulnerability fixes] ### Breaking Changes - **BREAKING CHANGE**: [List any breaking changes affecting compatibility or functionality] --- ### Additional Information - [Insert any additional context, notes, or explanations for the changes] - [Reference any related issues, commits, or other relevant information] ### Screenshots or Videos - [Attach any relevant screenshots or videos demonstrating the changes] ### 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>
GiteaMirror added the pull-request label 2026-04-20 05:42:48 -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#25015