Skip to content

[FEA]: Add MCP support for handling union types in lists #371

@cheese-head

Description

@cheese-head

Is this a new feature, an improvement, or a change to existing functionality?

Improvement

How would you describe the priority of this feature request

Critical (currently preventing usage)

Please provide a clear description of problem this feature solves

I would like to be able to use a MCP server that has a tool with a union type.
An example tool that has a union type:

field_name: new_line field_properties: {'type': ['number', 'null'], 'description': 'Line number after change'}

Will cause a fatal error:

[ERROR] Failed to fetch tools via MCPBuilder: unhashable type: 'list'

The MCP server being used https://github.com/zereight/gitlab-mcp

Describe your ideal solution

Add a new elif clause in mcp_client.py

        elif isinstance(json_type, list):
            nullable = "null" in json_type
            main_type = next((t for t in json_type if t != "null"), "string")
            field_type = _type_map.get(main_type, Any)
            if nullable:
                field_type = field_type | None
            return field_type, Field(
                default=field_properties.get("default", None if nullable else ...),
                description=field_properties.get("description", "")
            )

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I have searched the open feature requests and have found no duplicates for this feature request

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions