mirror of
https://github.com/open-webui/mcpo.git
synced 2026-11-05 01:27:39 +00:00
[PR #114] [CLOSED] fix: ensure MCP server tools are loaded before generating API docs or OpenWebUI integration #174
Labels
No labels
bug
can't reproduce
documentation
enhancement
good first issue
help wanted
invalid
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
open-webui/mcpo#174
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/mcpo/pull/114
Author: @Lin-jun-xiang
Created: 5/2/2025
Status: ❌ Closed
Base:
main← Head:fix/server-startup-delay📝 Commits (1)
46586ebfix: wait for MCP server tools to be ready before listing (tools_timeout/tools_interval)📊 Changes
3 files changed (+62 additions, -5 deletions)
View changed files
📝
src/mcpo/__init__.py(+8 -0)📝
src/mcpo/main.py(+34 -5)📝
src/mcpo/utils/main.py(+20 -0)📄 Description
Pull Request Checklist
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
tools_timeoutandtools_intervalparameters to ensure the client waits for the MCP server to be fully ready before listing tools. This prevents issues where the tool list is empty if the server is not ready, which can break API docs and OpenWebUI integration.I believe that every MCP server should provide tools—otherwise, there would be no point in building it. However, at the current stage, during the MCP connection process, some servers (when started via
session.initialize) do not return any results fromlist_tools(instead, it returns an empty list []). It is necessary to wait for a while before callinglist_toolsto get the correct results.Based on my testing with an MCP server developed using
mcpsharp(please forgive me for not being able to share the code due to security concerns), starting the MCP server takes some time. When I added print(tools) to the source code, I observed the following output:Since the tools have not yet been loaded, the API documentation (
localhost:8000/docs) appears empty (at this point, OpenWebUI will hang), as shown below:This improvement for MCPO serves as a temporary workaround. The ideal solution would be to address the issue on the MCP server side, ensuring that tools are available immediately after the server starts. However, this change provides a quick and efficient fix without impacting performance, and also adds a check to ensure MCP tools are present (otherwise, a
runtime errorisraised).Added
tools_timeoutandtools_intervalparameters, configurable via CLI or config, passed through app state. ex:mcpo --port 8000 --tools-timeout 5 -- cmd.exe /c "C:\example.exe"wait_list_toolsto wait for tools to be available.Changed
Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Screenshots or Videos
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.