Fix invalid JSON Schema for query_results_cache_retrieve#263
Conversation
…t for lineRange/resultIndices) Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/950558d1-9e5d-4eec-bdd3-0668c904dd1f Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
query_results_cache_retrieve (Copilot Chat HTTP 400)
Adds tests to generically avoid regressions due to invalid schema for any MCP tool.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR fixes a JSON Schema incompatibility that caused GitHub Copilot Chat to reject the MCP server (HTTP 400 ... is not of type 'object', 'boolean') by changing query_results_cache_retrieve input parameters from tuple-form Zod schemas to object-form schemas that serialize cleanly via zod-to-json-schema.
Changes:
- Replace
lineRange/resultIndicesinput types fromz.tuple([start,end])toz.object({ start, end })and adapt the handler by converting back to tuples at the store boundary. - Add/expand regression tests to ensure tool input schemas never contain array-valued JSON Schema nodes (unit-level and VS Code e2e).
- Update the client integration-test fixture inputs and document the breaking input-shape change in
CHANGELOG.md.
Show a summary per file
| File | Description |
|---|---|
| server/src/tools/cache-tools.ts | Changes query_results_cache_retrieve schema for lineRange/resultIndices to object form; converts to tuple internally for existing store APIs. |
| server/test/src/tools/cache-tools.test.ts | Updates schema validation tests for new object shape and adds JSON-schema serialization regression coverage for cache tools. |
| server/test/src/tools/tool-schema-validation.test.ts | Adds a new cross-tool regression test ensuring strict JSON Schema compatibility across all tool input schemas. |
| extensions/vscode/test/suite/mcp-tool-e2e.integration.test.ts | Adds wire-protocol regression coverage ensuring listed tool schemas are strict-validator compatible and exercises new argument shape. |
| client/integration-tests/.../test-config.json | Updates fixture to pass lineRange as {start,end}. |
| client/integration-tests/.../before/monitoring-state.json | Updates stored parameters snapshot to the new {start,end} shape. |
| client/integration-tests/.../after/monitoring-state.json | Updates expected parameters snapshot to the new {start,end} shape. |
| CHANGELOG.md | Documents the Copilot Chat HTTP 400 schema issue and the breaking input-shape change under [Unreleased]. |
| server/dist/codeql-development-mcp-server.js | Rebuilt bundled artifact reflecting the schema and handler changes. |
Copilot's findings
- Files reviewed: 8/10 changed files
- Comments generated: 2
query_results_cache_retrieve (Copilot Chat HTTP 400)query_results_cache_retrieve
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nathan Randall <70299490+data-douser@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes Copilot Chat compatibility by changing query_results_cache_retrieve’s lineRange / resultIndices input shape from Zod tuples (which serialize to array-valued schemas) to { start, end } objects, and adds regression tests to ensure all tool schemas remain strict-JSON-Schema-compatible.
Changes:
- Update
query_results_cache_retrieveinputs to object ranges and adapt handler to pass tuples to the underlying store. - Add unit/e2e regression tests to ensure tool input schemas never contain array-valued schema nodes (Copilot/OpenAI strict validation).
- Document the change in the root changelog and update client integration test fixtures to use the new input shape.
Show a summary per file
| File | Description |
|---|---|
| server/src/tools/cache-tools.ts | Switch lineRange / resultIndices from z.tuple to z.object({ start, end }) and convert back to tuple at the store boundary. |
| server/test/src/tools/cache-tools.test.ts | Update schema validation tests for new object-form inputs and add JSON Schema serialization regression tests for cache tools. |
| server/test/src/tools/tool-schema-validation.test.ts | New global tool-schema regression test validating that tool schemas don’t contain array-valued schema nodes. |
| extensions/vscode/test/suite/mcp-tool-e2e.integration.test.ts | Add wire-level regression test that listTools() returns strict-JSON-Schema-compatible inputSchema for every tool, and exercise new object-form args. |
| client/integration-tests/primitives/tools/query_results_cache_retrieve/retrieve_with_subset/test-config.json | Update integration test tool arguments to include object-form lineRange. |
| client/integration-tests/primitives/tools/query_results_cache_retrieve/retrieve_with_subset/before/monitoring-state.json | Update recorded parameters to include object-form lineRange. |
| client/integration-tests/primitives/tools/query_results_cache_retrieve/retrieve_with_subset/after/monitoring-state.json | Update recorded parameters to include object-form lineRange. |
| CHANGELOG.md | Add an Unreleased entry describing the schema fix and input shape change. |
| server/dist/codeql-development-mcp-server.js | Bundled output reflecting the TypeScript changes. |
Copilot's findings
- Files reviewed: 8/10 changed files
- Comments generated: 2
There was a problem hiding this comment.
Pull request overview
This PR fixes a Copilot Chat compatibility issue by changing query_results_cache_retrieve input parameters from tuple form ([start, end]) to object form ({ start, end }), avoiding invalid JSON Schema serialization that caused tools/list to be rejected.
Changes:
- Update
query_results_cache_retrieveinput schema forlineRangeandresultIndicesfromz.tuple(...)toz.object({ start, end }), converting back to tuples at the store boundary. - Add regression tests to ensure tool input schemas never serialize to array-valued JSON Schema fragments (unit + VS Code e2e).
- Update client integration test fixtures and changelog to reflect the new wire-level input shape.
Show a summary per file
| File | Description |
|---|---|
| server/src/tools/cache-tools.ts | Switch lineRange/resultIndices to object inputs and convert back to tuple internally to keep store APIs unchanged. |
| server/test/src/tools/cache-tools.test.ts | Update schema validation expectations and add cache-tool JSON Schema serialization regression tests. |
| server/test/src/tools/tool-schema-validation.test.ts | New test validating JSON Schema serialization invariants across all registered tools. |
| extensions/vscode/test/suite/mcp-tool-e2e.integration.test.ts | Add wire-level e2e regression asserting all tool schemas are strict-JSON-Schema-valid and validate the new {start,end} inputs. |
| client/integration-tests/**/test-config.json | Update tool invocation arguments to use the new lineRange object form. |
| client/integration-tests/**/monitoring-state.json | Update stored parameters snapshots to match the new input shape. |
| CHANGELOG.md | Document the fix and breaking input-shape change under [Unreleased]. |
| server/dist/codeql-development-mcp-server.js | Regenerated bundle reflecting the schema and handler updates. |
Copilot's findings
- Files reviewed: 8/10 changed files
- Comments generated: 0
Closes #262.
Reported Bug
GitHub Copilot Chat rejects the
ql-mcpserver withHTTP 400 "[...] is not of type 'object', 'boolean'"becausequery_results_cache_retrieveexposeslineRangeandresultIndicesasz.tuple([...]), whichzod-to-json-schemaserializes to an array-style schema (items: [{...}, {...}]) that strict JSON-Schema validators reject.Update Metadata
lineRange/resultIndiceschanges from[start, end]to{ start, end }. The tool was effectively unusable from Copilot Chat before, so the blast radius is small.🎯 Changes Description
Current Behavior
lineRange/resultIndicesare declared withz.tuple([...]). The MCP SDK serializes the tool's input schema viazod-to-json-schema, producing per-property values that are JSON arrays. OpenAI/Copilot's strict validator requires every property's schema value to be an object or boolean, and refuses to load the server.Updated Behavior
Both parameters are declared with
z.object({ start, end })(same min /start <= endrefinements) and converted back to[start, end]tuples at the call boundary, soSqliteStoreis unchanged. Resulting JSON Schema is a cleantype: "object"withstart/endinteger properties — accepted by Copilot Chat.Motivation
Restore usability of the entire
ql-mcpserver in GitHub Copilot Chat, where a single malformed property schema currently fails the wholetools/listvalidation.🔄 Before vs. After Comparison
API Changes
Output Format Changes
Tool output is unchanged. The wire-level input for the affected parameters changes shape:
The serialized JSON Schema for
lineRangeis now:{ "type": "object", "properties": { "start": { "type": "integer", "minimum": 1 }, "end": { "type": "integer", "minimum": 1 } }, "required": ["start", "end"], "additionalProperties": false }Validation Scenarios
inputSchemais an object/boolean (never an array) using the SDK's realtoJsonSchemaCompat.client.listTools()against a spawned server and enforces the same invariant for every registered tool, then invokesquery_results_cache_retrievewith{ start, end }.[start, end]tuple rejected;start > end, negatives, and floats rejected.