Skip to content

fix(config, llm)!: Preserve MCP tool schemas as declared - #998

Open
JeanMertz wants to merge 4 commits into
mainfrom
openai-tool-schema-issue
Open

fix(config, llm)!: Preserve MCP tool schemas as declared#998
JeanMertz wants to merge 4 commits into
mainfrom
openai-tool-schema-issue

Conversation

@JeanMertz

@JeanMertz JeanMertz commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

An enum on an array parameter produced a schema OpenAI rejects,
failing every query that enabled the tool. The enum belonged under
items, but nothing said so until the provider refused the request.

An MCP server's inputSchema was translated into JP's own parameter
tree, which cannot hold a $ref, and each provider rebuilt a schema
from it. A tool's parameters are now the document its source
declared, with configuration written into it as an overlay. Reading
follows same-document references, so a referenced enum constrains
values like an inline one, and adapting a schema to what an API
accepts is left to the provider that needs it.

That closed two silent failures: Ollama received no parameter schema
at all, and referenced types were dropped for every provider.
Schemas are validated before the request, reporting the config key
at fault instead of an HTTP 400, and a tool JP cannot describe is
skipped rather than failing the query.

BREAKING CHANGE: MCP overrides may no longer contradict the server.

Move an enum of individual values on an array to items.enum; an
enum of complete arrays keeps its JSON Schema meaning. A type
override must match the server's type set or be removed. Arrays must
declare items, local parameters must declare type, and a
default outside a narrowed enum is rejected. On MCP parameters
enum = [] clears an inherited enum. Overrides that only restated a
referenced type can be deleted.

Tool definitions reject invalid local and MCP parameter schemas before
sending them to a provider. MCP overrides inherit unset nested fields,
while incompatible type overrides return paths that identify the faulty
configuration.

Array enums retain their JSON Schema meaning as complete array values.
Use `items.enum` to constrain individual array elements, avoiding
provider-specific enum rewriting.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Tools retain MCP JSON Schema documents, including `$defs` and
references, so providers receive the types and constraints declared by
the server. Ollama expands same-document references before sending them.

Invalid optional tool schemas are skipped with a warning, while an
explicit `--tool` request still reports the schema error.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz changed the title fix(config, llm): Validate resolved tool schemas fix(config, llm)!: Preserve MCP tool schemas as declared Aug 21, 2026
Signed-off-by: Jean Mertz <git@jeanmertz.com>
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