[PR #20742] [CLOSED] fix(startup): auto-initialize tool servers from TOOL_SERVER_CONNECTIONS env var #41385

Closed
opened 2026-04-25 13:38:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20742
Author: @SpootyMcSpoot
Created: 1/17/2026
Status: Closed

Base: mainHead: fix/tool-server-connections-auto-init


📝 Commits (1)

  • cb02247 fix(startup): auto-initialize tool servers from TOOL_SERVER_CONNECTIONS env var

📊 Changes

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

View changed files

📝 backend/open_webui/main.py (+30 -0)

📄 Description

Summary

This PR fixes the issue where TOOL_SERVER_CONNECTIONS environment variable is set but tool servers are not actually initialized until the user manually visits the Admin Panel and clicks Save.

Problem: TOOL_SERVER_CONNECTIONS is a PersistentConfig that only pre-populates the Admin Panel settings. The tools don't become available until set_tool_servers() is called, which currently only happens when a user manually saves the config.

Solution: Call set_tool_servers() during application startup (in the lifespan() function) when TOOL_SERVER_CONNECTIONS has entries. This makes tools available immediately without requiring manual intervention.

Use Case

Users deploying Open-WebUI in Kubernetes/containerized environments want to pre-configure tool servers via environment variables for GitOps/IaC workflows. Currently this requires:

  1. Set TOOL_SERVER_CONNECTIONS env var
  2. Wait for pod to start
  3. Manually log into Admin Panel
  4. Navigate to External Tools
  5. Click Save (without changing anything)
  6. Tools finally become available

With this fix, step 3-6 are eliminated - tools work immediately on startup.

Changes

  • Import set_tool_servers from open_webui.utils.tools
  • Add startup initialization in lifespan() function to call set_tool_servers() when TOOL_SERVER_CONNECTIONS is configured
  • Includes proper error handling and logging

Testing

Tested with MCPO (MCP-to-OpenAPI proxy) tool servers configured via environment:

  • Tools are registered in app.state.TOOL_SERVERS on startup
  • OpenAPI specs are fetched and parsed correctly
  • Tools appear in chat interface without manual admin action

Fixes #18140


Contributor License Agreement

I have read and agree to the Open WebUI 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/20742 **Author:** [@SpootyMcSpoot](https://github.com/SpootyMcSpoot) **Created:** 1/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/tool-server-connections-auto-init` --- ### 📝 Commits (1) - [`cb02247`](https://github.com/open-webui/open-webui/commit/cb02247d3e33693410a8090103e1f4cf9045d1b5) fix(startup): auto-initialize tool servers from TOOL_SERVER_CONNECTIONS env var ### 📊 Changes **1 file changed** (+30 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+30 -0) </details> ### 📄 Description ## Summary This PR fixes the issue where `TOOL_SERVER_CONNECTIONS` environment variable is set but tool servers are not actually initialized until the user manually visits the Admin Panel and clicks Save. **Problem:** `TOOL_SERVER_CONNECTIONS` is a `PersistentConfig` that only pre-populates the Admin Panel settings. The tools don't become available until `set_tool_servers()` is called, which currently only happens when a user manually saves the config. **Solution:** Call `set_tool_servers()` during application startup (in the `lifespan()` function) when `TOOL_SERVER_CONNECTIONS` has entries. This makes tools available immediately without requiring manual intervention. ## Use Case Users deploying Open-WebUI in Kubernetes/containerized environments want to pre-configure tool servers via environment variables for GitOps/IaC workflows. Currently this requires: 1. Set `TOOL_SERVER_CONNECTIONS` env var 2. Wait for pod to start 3. Manually log into Admin Panel 4. Navigate to External Tools 5. Click Save (without changing anything) 6. Tools finally become available With this fix, step 3-6 are eliminated - tools work immediately on startup. ## Changes - Import `set_tool_servers` from `open_webui.utils.tools` - Add startup initialization in `lifespan()` function to call `set_tool_servers()` when `TOOL_SERVER_CONNECTIONS` is configured - Includes proper error handling and logging ## Testing Tested with MCPO (MCP-to-OpenAPI proxy) tool servers configured via environment: - Tools are registered in `app.state.TOOL_SERVERS` on startup - OpenAPI specs are fetched and parsed correctly - Tools appear in chat interface without manual admin action Fixes #18140 --- ## Contributor License Agreement I have read and agree to the [Open WebUI Contributor License Agreement](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT). --- <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-25 13:38:25 -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#41385