Skip to content

Strict-schema OpenAI-compatible endpoints (LM Studio) reject all requests when an MCP tool schema lacks 'properties' #446

Closed

Description

@indh-x

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), model qwen/qwen3.6-35b-a3b
  • Named provider profile [providers.<name>] with type = "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

  1. Configure an openai-compatible provider profile pointing at LM Studio.
  2. Configure any MCP server that declares at least one tool with inputSchema: {"type": "object"} and no properties key (e.g. wiremock MCP).
  3. 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

  1. added
    bug
    priority: high
    triage: fixed-pending-release
    autonomous: clear
    on Jul 6, 2026
  2. 1jehuang commented on Jul 6, 2026

    @1jehuang
    Owner

    Triage: confirmed. MCP no-arg tools commonly declare inputSchema: {"type": "object"} with no properties, and jcode forwarded that schema verbatim in tools[].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:

    • recursively inserts an empty properties: {} into object-typed schema nodes missing it (including nested items/anyOf/$defs/etc),
    • normalizes empty/non-object parameters to an empty object schema.

    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.

  3. 1jehuang commented on Jul 7, 2026

    @1jehuang
    Owner

    Released in v0.37.0. Run jcode update to get it.

  4. removed
    triage: fixed-pending-release
    on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugpriority: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions