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
**extra support is removed
Steps to Reproduce
- Create a simple JSON schema without
anyOf, items, enum, or properties
- 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 no type)
- Causes validation failures when boolean values are coerced to strings
++
- Will break in Pydantic v3 when
**extra parameter support is removed from Field()
Root Cause
Pydantic's Field() function does NOT accept:
anyOf - JSON schema construct, not a Field parameter
items - JSON schema construct for arrays
enum - 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.
Summary
create_model_from_json_schema()insrc/mcpadapt/utils/modeling.pypasses invalid parameters (anyOf,items,enum,properties) directly to pydantic'sField()constructor. This causes:**extrasupport is removedSteps to Reproduce
anyOf,items,enum, orpropertiesExpected Behavior
Generated schema should only contain relevant JSON schema properties:
Impact
++
anyOf: []with notype)++
**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 objectsEnvironment
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.