[GH-ISSUE #117] issue: schema_defs is not properly passed through this chain. #54

Open
opened 2026-10-18 21:10:55 +00:00 by bsakaguchi · 8 comments
Owner

Originally created by @dmytroDragan on GitHub (May 2, 2025).
Original GitHub issue: https://github.com/open-webui/mcpo/issues/117

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of mcpo.

mcpo Version

v0.0.13

Open WebUI Version (if applicable)

Operating System

macOS Sequoia 15.4.1

Browser (if applicable)

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both MCPO and Open WebUI.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have listed steps to reproduce the bug in detail.

Expected Behavior

When I run

mcpo --port 8085 --env "DATAHUB_GMS_URL=http://localhost:8080" --env "DATAHUB_GMS_TOKEN=anykey" -- uvx mcp-server-datahub --cors-allow-origins

the mcpo will generate a proper endpoints for the mcp-server-datahub (https://github.com/acryldata/mcp-server-datahub) MCP server.

Actual Behavior

Fails with the error

Steps to Reproduce

mcpo --port 8085 --env "DATAHUB_GMS_URL=http://localhost:8080" --env "DATAHUB_GMS_TOKEN=anykey" -- uvx mcp-server-datahub --cors-allow-origins

Logs & Screenshots

[05/02/25 17:45:37] INFO     Processing request of type ListToolsRequest                                                                                                                      server.py:534
ERROR:      + Exception Group Traceback (most recent call last):
  |   File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/starlette/routing.py", line 692, in lifespan
  |     async with self.lifespan_context(app) as maybe_state:
  |   File "/opt/homebrew/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 210, in __aenter__
  |     return await anext(self.gen)
  |            ^^^^^^^^^^^^^^^^^^^^^
  |   File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/main.py", line 104, in lifespan
  |     async with stdio_client(server_params) as (reader, writer):
  |   File "/opt/homebrew/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 231, in __aexit__
  |     await self.gen.athrow(typ, value, traceback)
  |   File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/mcp/client/stdio/__init__.py", line 166, in stdio_client
  |     async with (
  |   File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
  |     raise BaseExceptionGroup(
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    |   File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/mcp/client/stdio/__init__.py", line 173, in stdio_client
    |     yield read_stream, write_stream
    |   File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/main.py", line 105, in lifespan
    |     async with ClientSession(reader, writer) as session:
    |   File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
    |     raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
      | Traceback (most recent call last):
      |   File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/main.py", line 107, in lifespan
      |     await create_dynamic_endpoints(app, api_dependency=api_dependency)
      |   File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/main.py", line 43, in create_dynamic_endpoints
      |     form_model_fields = get_model_fields(
      |                         ^^^^^^^^^^^^^^^^^
      |   File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/utils/main.py", line 182, in get_model_fields
      |     python_type_hint, pydantic_field_info = _process_schema_property(
      |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/utils/main.py", line 84, in _process_schema_property
      |     type_hint, _ = _process_schema_property(
      |                    ^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/utils/main.py", line 70, in _process_schema_property
      |     assert ref in schema_defs, "Custom field not found"
      |            ^^^^^^^^^^^^^^^^^^
      | TypeError: argument of type 'NoneType' is not iterable
      +------------------------------------

Additional Information

This occurs in _process_schema_property when trying to check if a reference exists in schema_defs:

assert ref in schema_defs, "Custom field not found"

The problem is that schema_defs is None when it's being passed to _process_schema_property. This happens because:

  1. The server is trying to create dynamic endpoints for the tools
  2. During this process, it's trying to process the schema of each tool
  3. When processing the schema, it encounters a $ref (reference) to another part of the schema
  4. The schema_defs parameter is not being passed correctly through the call chain

Let's look at the call chain:

  1. lifespan in main.py calls create_dynamic_endpoints
  2. create_dynamic_endpoints calls get_model_fields
  3. get_model_fields calls _process_schema_property
  4. _process_schema_property tries to use schema_defs which is None
  5. The fix should be to ensure that schema_defs is properly passed through this chain
Originally created by @dmytroDragan on GitHub (May 2, 2025). Original GitHub issue: https://github.com/open-webui/mcpo/issues/117 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of mcpo. ### mcpo Version v0.0.13 ### Open WebUI Version (if applicable) - ### Operating System macOS Sequoia 15.4.1 ### Browser (if applicable) - ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** MCPO and Open WebUI. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have listed steps to reproduce the bug in detail. ### Expected Behavior When I run ``` mcpo --port 8085 --env "DATAHUB_GMS_URL=http://localhost:8080" --env "DATAHUB_GMS_TOKEN=anykey" -- uvx mcp-server-datahub --cors-allow-origins ``` the mcpo will generate a proper endpoints for the mcp-server-datahub (https://github.com/acryldata/mcp-server-datahub) MCP server. ### Actual Behavior Fails with the error ### Steps to Reproduce ``` mcpo --port 8085 --env "DATAHUB_GMS_URL=http://localhost:8080" --env "DATAHUB_GMS_TOKEN=anykey" -- uvx mcp-server-datahub --cors-allow-origins ``` ### Logs & Screenshots ``` [05/02/25 17:45:37] INFO Processing request of type ListToolsRequest server.py:534 ERROR: + Exception Group Traceback (most recent call last): | File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/starlette/routing.py", line 692, in lifespan | async with self.lifespan_context(app) as maybe_state: | File "/opt/homebrew/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 210, in __aenter__ | return await anext(self.gen) | ^^^^^^^^^^^^^^^^^^^^^ | File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/main.py", line 104, in lifespan | async with stdio_client(server_params) as (reader, writer): | File "/opt/homebrew/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 231, in __aexit__ | await self.gen.athrow(typ, value, traceback) | File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/mcp/client/stdio/__init__.py", line 166, in stdio_client | async with ( | File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Exception Group Traceback (most recent call last): | File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/mcp/client/stdio/__init__.py", line 173, in stdio_client | yield read_stream, write_stream | File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/main.py", line 105, in lifespan | async with ClientSession(reader, writer) as session: | File "/Users/ddrag/IdeaProjects/mcpo/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/main.py", line 107, in lifespan | await create_dynamic_endpoints(app, api_dependency=api_dependency) | File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/main.py", line 43, in create_dynamic_endpoints | form_model_fields = get_model_fields( | ^^^^^^^^^^^^^^^^^ | File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/utils/main.py", line 182, in get_model_fields | python_type_hint, pydantic_field_info = _process_schema_property( | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/utils/main.py", line 84, in _process_schema_property | type_hint, _ = _process_schema_property( | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/ddrag/IdeaProjects/mcpo/src/mcpo/utils/main.py", line 70, in _process_schema_property | assert ref in schema_defs, "Custom field not found" | ^^^^^^^^^^^^^^^^^^ | TypeError: argument of type 'NoneType' is not iterable +------------------------------------ ``` ### Additional Information This occurs in _process_schema_property when trying to check if a reference exists in schema_defs: ``` assert ref in schema_defs, "Custom field not found" ``` The problem is that schema_defs is None when it's being passed to _process_schema_property. This happens because: 1. The server is trying to create dynamic endpoints for the tools 2. During this process, it's trying to process the schema of each tool 3. When processing the schema, it encounters a $ref (reference) to another part of the schema 4. The schema_defs parameter is not being passed correctly through the call chain Let's look at the call chain: 1. lifespan in main.py calls create_dynamic_endpoints 2. create_dynamic_endpoints calls get_model_fields 3. get_model_fields calls _process_schema_property 4. _process_schema_property tries to use schema_defs which is None 5. The fix should be to ensure that schema_defs is properly passed through this chain
Author
Owner

@tjbck commented on GitHub (May 3, 2025):

PR Welcome!

<!-- gh-comment-id:2848623890 --> @tjbck commented on GitHub (May 3, 2025): PR Welcome!
Author
Owner

@bmen25124 commented on GitHub (May 5, 2025):

I'm getting the same error since the new version. The entire pipeline is broken for me 😶

this pr causing the issue. For example, it tries to get model fields:

Image

But the thing is, there is no $defs in the object.

Image

@JinY0ung-Shin Could you look at this? I tried on 2 different MCP servers, they are not working anymore. Previously, they were working.

<!-- gh-comment-id:2851896218 --> @bmen25124 commented on GitHub (May 5, 2025): I'm getting the same error since the new version. The entire pipeline is broken for me 😶 [this pr](https://github.com/open-webui/mcpo/pull/105) causing the issue. For example, it tries to get model fields: ![Image](https://github.com/user-attachments/assets/4b67f22e-2102-4956-8f27-10744ffe8d8f) But the thing is, there is no `$defs` in the object. ![Image](https://github.com/user-attachments/assets/eb4f4e06-e61a-4741-a75b-5690cfb86d55) @JinY0ung-Shin Could you look at this? I tried on 2 different MCP servers, they are not working anymore. Previously, they were working.
Author
Owner

@bmen25124 commented on GitHub (May 5, 2025):

Okay I looked into the issue. It happens when the reference is not in the defs, but in properties. Example:

Example inputSchema
{
    "type": "object",
    "properties": {
        "keywords": {
            "type": "string",
            "description": "Optional: Search memory descriptions for these space-separated keywords (case-insensitive, all must match)."
        },
        // ...
        "event_time_start": {
            "type": "string",
            "format": "date-time",
            "description": "Optional: Find memories with event_timestamp on or after this ISO 8601 time."
        },
        "event_time_end": {
            "$ref": "#/properties/event_time_start", // Error happens when we tried to process this
            "description": "Optional: Find memories with event_timestamp on or before this ISO 8601 time."
        },
        // ...
    },
    "additionalProperties": false,
    "$schema": "http://json-schema.org/draft-07/schema#"
}
<!-- gh-comment-id:2851958278 --> @bmen25124 commented on GitHub (May 5, 2025): Okay I looked into the issue. It happens when the reference is not in the defs, but in properties. Example: <details> <summary>Example inputSchema</summary> ```json { "type": "object", "properties": { "keywords": { "type": "string", "description": "Optional: Search memory descriptions for these space-separated keywords (case-insensitive, all must match)." }, // ... "event_time_start": { "type": "string", "format": "date-time", "description": "Optional: Find memories with event_timestamp on or after this ISO 8601 time." }, "event_time_end": { "$ref": "#/properties/event_time_start", // Error happens when we tried to process this "description": "Optional: Find memories with event_timestamp on or before this ISO 8601 time." }, // ... }, "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" } ``` </details>
Author
Owner

@pipars commented on GitHub (Jun 27, 2025):

It seems like there is no fix yet, right? Did anyone come up with resulution, becasue I am still at v0.0.12 and cannot move forward. Is it specific to a narrow subset of mcp servers? I am using neo4j and it does not work as soon as I move to v.0.0.13

<!-- gh-comment-id:3012723490 --> @pipars commented on GitHub (Jun 27, 2025): It seems like there is no fix yet, right? Did anyone come up with resulution, becasue I am still at v0.0.12 and cannot move forward. Is it specific to a narrow subset of mcp servers? I am using neo4j and it does not work as soon as I move to v.0.0.13
Author
Owner

@jemilsson commented on GitHub (Jul 2, 2025):

I don't believe this is fixed yet. I've tried running the latest version and the latest commits, but it keeps crashing for us. For us it is using the Shortcut MCP that is resulting in the crashes. We will keep runing 0.0.12 for now.

<!-- gh-comment-id:3026670184 --> @jemilsson commented on GitHub (Jul 2, 2025): I don't believe this is fixed yet. I've tried running the latest version and the latest commits, but it keeps crashing for us. For us it is using the [Shortcut MCP](https://github.com/useshortcut/mcp-server-shortcut) that is resulting in the crashes. We will keep runing 0.0.12 for now.
Author
Owner

@pipars commented on GitHub (Aug 2, 2025):

it seems to be fixed with v0.0.17

<!-- gh-comment-id:3146435380 --> @pipars commented on GitHub (Aug 2, 2025): it seems to be fixed with v0.0.17
Author
Owner

@mekhami commented on GitHub (Aug 28, 2025):

I'm running into this issue as well on 0.0.17 (or at least, I think it's 0.0.17 - the mcpo --version command fails for whatever reason.

<!-- gh-comment-id:3234877895 --> @mekhami commented on GitHub (Aug 28, 2025): I'm running into this issue as well on 0.0.17 (or at least, I think it's 0.0.17 - the `mcpo --version` command fails for whatever reason.
Author
Owner

@DaRacci commented on GitHub (Sep 9, 2025):

Still experiencing this on 0.0.17 too, seeing this with the command mcpo -- npx -y anilist-mcp

<!-- gh-comment-id:3270120706 --> @DaRacci commented on GitHub (Sep 9, 2025): Still experiencing this on 0.0.17 too, seeing this with the command `mcpo -- npx -y anilist-mcp`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/mcpo#54
No description provided.