Skip to content

Fix invalid schema for query_results_cache_retrieve tool use in VS Code Copilot Chat #262

@data-douser

Description

@data-douser

Bug: query_results_cache_retrieve tool causes 400 error in GitHub Copilot Chat due to invalid JSON Schema

Description

When the ql-mcp MCP server is used via GitHub Copilot Chat, all requests fail with a 400 error because the query_results_cache_retrieve tool exposes an invalid JSON Schema for its lineRange and resultIndices parameters.

Error

Sorry, your request failed. Please try again.

Reason: Request Failed: 400 {"error":{"message":"Invalid schema for function
'mcp_ql-mcp_query_results_cache_retrieve': [{'type': 'integer', 'minimum': 0},
{'type': 'integer', 'minimum': 0}] is not of type 'object', 'boolean'.",
"code":"invalid_request_body"}}

Root Cause

The lineRange and resultIndices parameters are defined using z.tuple([...]):

lineRange: z.tuple([z.number().int().min(1), z.number().int().min(1)])
.refine(([start, end]) => start <= end, ...)
.optional(),

resultIndices: z.tuple([z.number().int().min(0), z.number().int().min(0)])
.refine(([start, end]) => start <= end, ...)
.optional(),

When the MCP SDK serializes these Zod tuple schemas to JSON Schema, it produces a bare array as the schema value (e.g. [{"type": "integer", "minimum": 1}, {"type": "integer", "minimum": 1}]) rather than a valid JSON Schema object. The GitHub Copilot API enforces strict JSON Schema validation and rejects any schema value that is not of type "object" or "boolean".

Expected Behavior

The parameters should serialize to a valid JSON Schema object, e.g.:

{
  "lineRange": {
  "type": "array",
  "prefixItems": [
    {"type": "integer", "minimum": 1},
    {"type": "integer", "minimum": 1}
  ],
  "minItems": 2,
  "maxItems": 2
  }
}

Affected Tool

  • Tool name: query_results_cache_retrieve
  • Affected parameters: lineRange, resultIndices

Environment

  • Extension: advanced-security.vscode-codeql-development-mcp-server v2.25.2
  • Client: GitHub Copilot Chat in VS Code

Workaround

Use the MCP server from a client that does not enforce strict JSON Schema validation (e.g. Claude Code), which handles the malformed tuple schema without error.

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions