Repository navigation
Description
Strict-schema OpenAI-compatible endpoints (LM Studio) reject all requests when an MCP tool schema lacks properties
Summary
When any configured MCP server exposes a tool whose input schema is a bare {"type": "object"} (no properties field — common for no-argument tools), every chat/completions request against a strict-schema OpenAI-compatible endpoint fails with HTTP 400. LM Studio is the primary example: its request validator requires properties to be present on object schemas inside tools[].function.parameters.
Since jcode sends the full tool array on every request, a single sloppy MCP tool schema makes the provider completely unusable.
Environment
- jcode v0.35.1 (e701dc3)
- LM Studio (local server,
http://localhost:1234/v1), modelqwen/qwen3.6-35b-a3b - Named provider profile
[providers.<name>]withtype = "openai-compatible" - MCP server whose tools have no-arg schemas (observed with the wiremock MCP server:
get_recording_status,stop_recording,who_am_i)
Reproduction
- Configure an
openai-compatibleprovider profile pointing at LM Studio. - Configure any MCP server that declares at least one tool with
inputSchema: {"type": "object"}and nopropertieskey (e.g. wiremock MCP). jcode --provider-profile <name> run 'hello'
Result: HTTP 400 from LM Studio. The error payload points at tools[<i>].function.parameters.properties being undefined ("expected": "object", "received": "undefined") for each offending tool index.
Root cause
crates/jcode-base/src/provider/openrouter_provider_impl.rs builds the OpenAI-format tool array by passing t.input_schema through verbatim:
"parameters": t.input_schema,There is no normalization of third-party MCP schemas, so whatever the MCP server emits is sent to the endpoint as-is. The OpenAI spec examples always include properties on object schemas, and strict validators (LM Studio) enforce it.
Proposed fix
Normalize object schemas before building the tools array: if parameters is an object schema ("type": "object") without a properties key, inject an empty "properties": {}. This is a no-op for well-formed schemas and semantically identical for no-arg tools.
Patch (12 lines) tested end-to-end against LM Studio: PR to follow.
Activity
fix(openrouter): sanitize tool parameter schemas for strict OpenAI-co…
1jehuang commentedon Jul 6, 2026
Triage: confirmed. MCP no-arg tools commonly declare
inputSchema: {"type": "object"}with noproperties, and jcode forwarded that schema verbatim intools[].function.parameters, so strict validators like LM Studio 400'd every request.Fixed on master in e8a6bc4: the OpenAI-compatible request path now sanitizes every tool parameters schema before sending:
properties: {}into object-typed schema nodes missing it (including nesteditems/anyOf/$defs/etc),The rewrite is semantically a no-op per JSON Schema, so it is applied unconditionally for all OpenAI-compatible/OpenRouter requests rather than allow-listing strict endpoints. Unit tests cover the bare no-arg shape from this report plus nested/edge shapes.
Will close automatically on the next release.
1jehuang commentedon Jul 7, 2026
Released in v0.37.0. Run
jcode updateto get it.feat(schema): replace per-provider deny-lists with a dialect system
fix(openai): strip unsupported format on the non-strict path too
fix(openrouter): sanitize tool parameter schemas for strict OpenAI-co…
feat(schema): replace per-provider deny-lists with a dialect system
fix(openai): strip unsupported format on the non-strict path too
feat(schema): replace per-provider deny-lists with a dialect system
fix(openai): strip unsupported format on the non-strict path too
fix(openrouter): sanitize tool parameter schemas for strict OpenAI-co…
feat(schema): replace per-provider deny-lists with a dialect system
fix(openai): strip unsupported format on the non-strict path too
feat(schema): replace per-provider deny-lists with a dialect system
fix(openai): strip unsupported format on the non-strict path too
feat(schema): replace per-provider deny-lists with a dialect system
fix(openai): strip unsupported format on the non-strict path too
fix(mcp): keep mcp_call arguments open-world across dialect normaliza…
feat(schema): replace per-provider deny-lists with a dialect system
fix(openai): strip unsupported format on the non-strict path too