Files
crewAI/lib
Devin AI 5b296fa20f fix: handle complex JSON schemas in MCP adapter to prevent KeyError
Fixes #4312

The issue was that MCP servers with complex JSON schemas containing internal
$ref references (like Mapbox MCP server) would cause a KeyError when
Pydantic tried to generate JSON schemas from dynamically created models.

This fix:
- Creates a custom CrewAI adapter (CrewAIAdapterWithSchemaFix) that properly
  resolves all $ref references using jsonref before creating Pydantic models
- Implements _resolve_all_refs() to fully resolve JSON Schema references
- Implements _create_model_from_schema() that creates Pydantic models without
  passing problematic extra fields that cause issues during schema generation
- Adds comprehensive tests for the new schema handling functionality

Co-Authored-By: João <joao@crewai.com>
2026-01-30 17:27:59 +00:00
..