Skip to content

Comments

Fix OpenAI API schema validation errors for MCP tools#80

Open
MaxGfeller wants to merge 1 commit intogrll:mainfrom
MaxGfeller:fix/openai-schema-validation
Open

Fix OpenAI API schema validation errors for MCP tools#80
MaxGfeller wants to merge 1 commit intogrll:mainfrom
MaxGfeller:fix/openai-schema-validation

Conversation

@MaxGfeller
Copy link

Remove extra Field() kwargs (items, anyOf, enum, properties, title) that were being stored in Pydantic's json_schema_extra and serialized with None/empty values.

OpenAI's API rejects schemas containing:

  • "items": null
  • "enum": null
  • "anyOf": []
  • "properties": {}

These values were being passed even when not present in the original MCP tool schema, causing tools like Playwright MCP to fail with: "Invalid schema for function: None is not of type 'object', 'boolean'"

The fix keeps only standard Field parameters (default, description) which Pydantic handles correctly.

Remove extra Field() kwargs (items, anyOf, enum, properties, title) that
were being stored in Pydantic's json_schema_extra and serialized with
None/empty values. OpenAI's API rejects schemas containing:
- "items": null
- "enum": null
- "anyOf": []
- "properties": {}

These values were being passed even when not present in the original
MCP tool schema, causing tools like Playwright MCP to fail with:
"Invalid schema for function: None is not of type 'object', 'boolean'"

The fix keeps only standard Field parameters (default, description)
which Pydantic handles correctly.
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