Skip to content

Conversation

@bmen25124
Copy link
Contributor

Fixes: #117

I added unit tests to make sure it is working.

@ShineQi
Copy link

ShineQi commented May 18, 2025

This fix will produce another error

 |   File "D:\open-webui\mcpo\src\mcpo\utils\main.py", line 183, in _process_schema_property
      |     item_type_hint, _ = _process_schema_property(
      |                         ^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\src\mcpo\utils\main.py", line 156, in _process_schema_property
      |     nested_type_hint, nested_pydantic_field = _process_schema_property(
      |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\src\mcpo\utils\main.py", line 101, in _process_schema_property
      |     pydantic_field = Field(default=default_value, description=prop_desc)
      |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\.venv\Lib\site-packages\pydantic\fields.py", line 1102, in Field
      |     return FieldInfo.from_field(
      |            ^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\.venv\Lib\site-packages\pydantic\fields.py", line 288, in from_field
      |     return FieldInfo(default=default, **kwargs)
      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\.venv\Lib\site-packages\pydantic\fields.py", line 234, in __init__
      |     alias_is_set = any(alias is not None for alias in (self.alias, self.validation_alias, self.serialization_alias))
      |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      | RecursionError: maximum recursion depth exceeded

with

{
  "mcpServers": {
    "mcp-server-chart": {
      "command": "npx",
      "args": [
        "-y",
        "@antv/mcp-server-chart"
      ],
      "name": "mcp-server-chart"
    }
}

@bmen25124
Copy link
Contributor Author

Unfortunately, I'm not available for the fix, I'll not be here for a while. Feel free to fix or create a new PR for the issue.

@bipedalBit
Copy link
Contributor

bipedalBit commented Jun 6, 2025

This fix will produce another error

 |   File "D:\open-webui\mcpo\src\mcpo\utils\main.py", line 183, in _process_schema_property
      |     item_type_hint, _ = _process_schema_property(
      |                         ^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\src\mcpo\utils\main.py", line 156, in _process_schema_property
      |     nested_type_hint, nested_pydantic_field = _process_schema_property(
      |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\src\mcpo\utils\main.py", line 101, in _process_schema_property
      |     pydantic_field = Field(default=default_value, description=prop_desc)
      |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\.venv\Lib\site-packages\pydantic\fields.py", line 1102, in Field
      |     return FieldInfo.from_field(
      |            ^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\.venv\Lib\site-packages\pydantic\fields.py", line 288, in from_field
      |     return FieldInfo(default=default, **kwargs)
      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "D:\open-webui\mcpo\.venv\Lib\site-packages\pydantic\fields.py", line 234, in __init__
      |     alias_is_set = any(alias is not None for alias in (self.alias, self.validation_alias, self.serialization_alias))
      |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      | RecursionError: maximum recursion depth exceeded

with

{
  "mcpServers": {
    "mcp-server-chart": {
      "command": "npx",
      "args": [
        "-y",
        "@antv/mcp-server-chart"
      ],
      "name": "mcp-server-chart"
    }
}

Actually, the failure to start mcp-server-chart with mcpo and the "Custom field not found" error occur due to a $ref loop in the schema of mcp-server-chart's tool. To resolve this issue, you need to return the tuple (<python_type_hint>, <pydantic_field>)) at the appropriate time in the _process_schema_property() function within mcpo/utils/main.py to break this loop. I'm attempting to draft a commit for this fix.

A schema with a $ref causing loop for example:

{
    "type": "object",
    "properties": {
        "data": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "children": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string"
                            },
                            "children": {
                                "type": "array",
                                "items": {
                                    "$ref": "#/properties/data/properties/children/items"
                                }
                            }
                        },
                        "required": [
                            "name"
                        ]
                    }
                }
            },
            "required": [
                "name"
            ],
            "description": "Data for fishbone diagram chart, such as, { name: 'main topic', children: [{ name: 'topic 1', children: [{ name: 'subtopic 1-1' }] }."
        },
        "theme": {
            "type": "string",
            "enum": [
                "default",
                "academy"
            ],
            "default": "default",
            "description": "Set the theme for the chart, optional, default is 'default'."
        },
        "width": {
            "type": "number",
            "default": 600,
            "description": "Set the width of chart, default is 600."
        },
        "height": {
            "type": "number",
            "default": 400,
            "description": "Set the height of chart, default is 400."
        }
    },
    "required": [
        "data"
    ],
    "$schema": "http://json-schema.org/draft-07/schema#"
}

pr commited: #174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants