-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Summary
create_model_from_json_schema() in src/mcpadapt/utils/modeling.py passes invalid parameters (anyOf, items, enum, properties) directly to pydantic's Field() constructor. This causes:
- Malformed JSON schemas with empty/null values
- Deprecation warnings in Pydantic v2
- Will break in Pydantic v3 when
**extrasupport is removed
Steps to Reproduce
- Create a simple JSON schema without
anyOf,items,enum, orproperties - Observe deprecation warning:
PydanticDeprecatedSince20: Using extra keyword arguments on `Field` is deprecated
and will be removed. Use `json_schema_extra` instead. (Extra keys: 'anyOf', 'items',
'enum', 'properties'). Deprecated in Pydantic V2.0 to be removed in V3.0.
- Check generated schema - contains malformed properties
Expected Behavior
Generated schema should only contain relevant JSON schema properties:
Impact
- Polluted JSON schemas with unnecessary empty/null properties
- Deprecation warnings in Pydantic v2.0+
++ - When using mcpadapt to wrap MCP tools for frameworks like CrewAI
- Multi-integration scenarios where schemas are cached and regenerated
- Type information gets lost in malformed schemas (
anyOf: []with notype) - Causes validation failures when boolean values are coerced to strings
++ - Will break in Pydantic v3 when
**extraparameter support is removed fromField()
Root Cause
Pydantic's Field() function does NOT accept:
anyOf- JSON schema construct, not a Field parameteritems- JSON schema construct for arraysenum- JSON schema construct (should use Literal/Enum types instead)properties- JSON schema construct for nested objects
Environment
- mcpadapt version: v0.1.13 to v0.1.20
- pydantic version: 2.x
- Python version: 3.10+
Additional Context
This issue was discovered while debugging a validation failure where boolean parameters were being coerced to strings in a multi-integration setup. The malformed schemas with anyOf: [] lacked type information, causing downstream validation issues.
Metadata
Metadata
Assignees
Labels
No labels