Skip to content

Remove invalid JSON schema in query gmail emails tool - #34

Open
adrianlzt wants to merge 1 commit into
MarkusPfundstein:mainfrom
adrianlzt:fix/query_gmail_emails_invalid
Open

Remove invalid JSON schema in query gmail emails tool#34
adrianlzt wants to merge 1 commit into
MarkusPfundstein:mainfrom
adrianlzt:fix/query_gmail_emails_invalid

Conversation

@adrianlzt

Copy link
Copy Markdown

Resolves this error returned by the OpenAI API:
{'error': {'message': "Invalid schema for function 'google-suite__query_gmail_emails': False is not of type 'array'.", 'type': 'invalid_request_error', 'param': 'tools[5].function.parameters', 'code': 'invalid_function_parameters'}

Resolves this error returned by the OpenAI API:
{'error': {'message': \"Invalid schema for function 'google-suite__query_gmail_emails': False is not of type 'array'.\", 'type': 'invalid_request_error', 'param': 'tools[5].function.parameters', 'code': 'invalid_function_parameters'}
@MarkusPfundstein

Copy link
Copy Markdown
Owner

mh interesting. how does this affect Anthropic?

@adrianlzt

Copy link
Copy Markdown
Author

With anthropic:

400 Bad Request. Message: tools.11.custom.input_schema: JSON schema is invalid. It must match JSON Schema draft 2020-12 (https://json-schema.org/draft/2020-12). Learn more about tool use at https://docs.anthropic.com/en/docs/tool-use

I am using goose as my MCP client.

@skorfmann

Copy link
Copy Markdown

I can confirm this issue affects Claude Code (Claude's official CLI) as well. When trying to use the mcp-gsuite server via Claude Code's stdio integration, I get the same schema validation error:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools.15.custom.input_schema: JSON schema is invalid. It must match JSON Schema draft 2020-12 (https://json-schema.org/draft/2020-12). Learn more about tool use at https://docs.anthropic.com/en/docs/tool-use."}}

After investigating, I found additional schema validation issues beyond the "required": false fix in this PR:

  1. This PR's fix is correct - the "required": false inside property definitions is invalid JSON Schema syntax
  2. Additional issue: The schemas also contain "default" values throughout the codebase (in both tools_gmail.py and tools_calendar.py), which can cause validation issues with Claude's stricter JSON Schema draft 2020-12 requirements

While this PR fixes the immediate issue with the query tool, you might want to consider removing all "default" values from the input schemas and moving that information to the description field instead. For example:

  • Change: "default": 100
  • To: "description": "Maximum number of emails to retrieve (1-500). Defaults to 100 if not specified."

This would ensure full compatibility with Claude and other APIs that strictly validate against JSON Schema draft 2020-12.

Thanks for the fix! The removal of "required": false is definitely needed and will help many users.

idirkev added a commit to idirkev/mcp-gsuite that referenced this pull request Aug 18, 2026
…ails

JSON Schema draft 2020-12 requires `required` to be an array at object
level. A boolean inside a property is a draft-3 relic, and the Anthropic
API rejects the whole request with

  400 tools.N.custom.input_schema: JSON schema is invalid

the moment this tool enters the tools array, hard-wedging the client
session until it is cleared. Upstream has five open PRs for this same
line (MarkusPfundstein#34, MarkusPfundstein#52, MarkusPfundstein#54, MarkusPfundstein#61) and has not shipped since 2025-04.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W2NqixEf6Ud6XM9XydfXN2
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.

3 participants