OpenAI provider rejects valid MCP schemas containing uniqueItems
Summary
JCode's OpenAI provider rejects an otherwise valid MCP tool catalog when an MCP tool's inputSchema contains the JSON Schema keyword uniqueItems.
This prevents every agent turn from starting once TubeAlfred's batch tools are advertised. The same tools are accepted and displayed correctly by Claude.
Environment
- JCode:
v0.64.2 (6c6fbba1c) - Provider: OpenAI
- Model:
gpt-5.6-sol - MCP server:
@tubealfred/mcp - Platform: Windows x86_64
Error
invalid_request_error (invalid_function_parameters):
Invalid schema for function 'mcp__tubealfred__youtube_channels_batch':
In context=('properties', 'ids'), 'uniqueItems' is not permitted.
The same failure also applies to youtube_videos_batch, which uses the same ids schema.
Minimal reproducing schema
{
"type": "object",
"properties": {
"ids": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"maxItems": 50,
"uniqueItems": true
},
"fields": {
"type": ["string", "null"]
}
},
"required": ["ids"]
}
uniqueItems is valid JSON Schema 2020-12. MCP uses JSON Schema for tool input schemas, so the MCP server schema itself is valid. Claude accepts the tool and renders ids as the required array parameter.
Suspected cause
openai_compatible_schema in crates/jcode-provider-core/src/openai_schema.rs normalizes constructs such as oneOf and allOf, but leaves uniqueItems intact. JCode then sends it in the OpenAI function parameters schema, whose supported subset rejects the keyword.
Because one unsupported keyword invalidates the complete tool request, this makes JCode unusable while this MCP server is enabled.
Suggested fix
- Strip
uniqueItemsin the OpenAI-specific schema compatibility pass. - Continue relying on the MCP server to enforce uniqueness at execution time.
- Add a regression test using the schema above.
- Consider maintaining an explicit set of OpenAI-unsupported JSON Schema keywords so other valid MCP schemas cannot invalidate the full tool catalog.
A narrower alternative would be to mark such schemas as non-strict, but this should be tested because the endpoint may reject uniqueItems regardless of the strict setting.
'This prevents every agent turn from starting once TubeAlfred's batch tools are advertised.' is a mistake. That is only how it looked in TermMate.
Initial concern retracted after direct JCode testing: the failure is not TermMate-specific. A plain
hello fails before model inference whenever the TubeAlfred batch schema is advertised. See the confirmed reproduction below.
Test confirms the failure is severe:
- You entered hello.
- JCode sent the OpenAI request with TubeAlfred’s tool catalog.
- OpenAI rejected the request before producing any model response.
- JCode stopped the attempt as non-retryable and requires /poke, changing provider, or fixing/disabling the schema.
So “prevents the turn from starting” is essentially accurate, but more precise wording would be:
Every OpenAI request fails before model inference while the TubeAlfred batch schema is advertised. No user prompt can receive a response until the schema is sanitized, TubeAlfred is disabled, or JCode switches to a provider that accepts it.█
It does not merely break the TubeAlfred batch call—the batch tool was never invoked. Its presence in the tool catalog blocks even a plain hello. That is worse and is worth adding as confirmed reproduction evidence to issue #687.
JCode’s merge order is a mess:
~/.jcode/mcp.json ↓ overridden by ~/.claude.json
So JCode’s own "enabled": false setting becomes ineffective whenever Claude defines the same server.
The clean next step is to update issue #687 with this second bug: JCode imports Claude’s MCP entry after its own configuration, preventing a JCode-only opt-out.
Fixed in baf0faf59 on master.
The OpenAI compatibility pass now strips JSON Schema keywords that OpenAI's function-parameters subset rejects (uniqueItems, contains/min|maxContains, unevaluated*, propertyNames, min|maxProperties, dependentSchemas/dependentRequired, if/then/else, not), exactly as you suggested, with your minimal schema as a regression test. The stripping is keyword-aware, so a property literally named uniqueItems still survives. Uniqueness stays enforced by the MCP server at execution time.
Thanks for the precise root-cause analysis and the confirmed repro, that made this a one-shot fix. It ships in the next release.
On the second bug you noted (~/.claude.json MCP entries overriding jcode's own enabled: false): that is a genuinely separate config-precedence bug, so it is better tracked on its own rather than buried here. Happy to file it if you have not already.
— Jcode agent (automated triage), on behalf of @1jehuang