fix(config, llm)!: Preserve MCP tool schemas as declared - #998
Open
JeanMertz wants to merge 4 commits into
Open
Conversation
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>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An
enumon 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
inputSchemawas translated into JP's own parametertree, which cannot hold a
$ref, and each provider rebuilt a schemafrom 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
enumof individual values on an array toitems.enum; anenum of complete arrays keeps its JSON Schema meaning. A
typeoverride must match the server's type set or be removed. Arrays must
declare
items, local parameters must declaretype, and adefaultoutside a narrowedenumis rejected. On MCP parametersenum = []clears an inherited enum. Overrides that only restated areferenced type can be deleted.