Skip to content

Support parsing anyOf from MCP tools #1708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

duguyue100
Copy link
Contributor

@duguyue100 duguyue100 commented Aug 22, 2025

Smolagents uses MCPAdapt, one problem is that it doesn't handle anyOf field from the input schema.

To mitigate this problem, I expanded get_tool_json_schema function that parses the argument properly.

Here is an example of before and after the change:
Before:

    'lifecycle_stage': {'anyOf': [{'enum': ['development',
        'ideation',
        'r_and_d',
        'testing',
        'production',
        'retired'],
       'type': 'string'},
      {'type': 'null'}],
     'default': None,
     'description': 'The lifecycle stage of the Software.',
     'title': 'Lifecycle Stage',
     'type': 'string'},

After

    'lifecycle_stage': {'default': None,
     'description': 'The lifecycle stage of the Software',
     'title': 'Lifecycle Stage',
     'type': 'string',
     'nullable': True,
     'enum': ['development',
      'ideation',
      'r_and_d',
      'testing',
      'production',
      'retired']},

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.

1 participant