fix: accept singular query in ctx_search input schema - #1207
Open
rubenmarcus wants to merge 1 commit into
Open
rubenmarcus wants to merge 1 commit into
rubenmarcus wants to merge 1 commit into
Conversation
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.
ctx_searchanswers{ query: "some search" }withError: provide query or queries.even though the handler normalizes the singular form. The field never made it into the Zod input schema, so the MCP SDK's argument validation strips it before the handler runs: the TS SDK validates tool arguments withsafeParseAsyncand a Zod object parse drops unknown keys. The normalize block atsrc/server.ts:2617-2623(added in 43667c0, "accept both query (string) and queries (array)") is dead code on every schema-conforming host.Fixes #1200.
Changes:
src/search/ctx-search-schema.ts: declare the optionalquerystring alias next toqueries, so the payload that survives validation matches the contract the handler already implements. Both DB modes get the field;sanitizeSchemaForStrictClientspicks it up automatically.tests/core/search-singular-query.test.ts: pins the schema layer.queryis declared in both shared-DB modes and survivesparse; the plural form, the [Bug]: ctx_search parameters incorrectly stringified by OpenCode adapter — Zod validation fails #627 bare-string lift, coercions, and defaults are unchanged.Verification (RED to GREEN):
The neighboring suites are identical with and without this change on my machine:
search-project-filter6 passed / 13 failed both ways, and theserver/searchbatch 501 passed / 175 failed both ways. Those failures are local-environment (they spawnbuild/server.js, which needsnpm run build, and reproduce on pristine main at the same counts).Prepared with AI assistance (GLM via Oh My Pi); reviewed before submission.