Skip to content

Commit 92af8e0

Browse files
Copilotdata-douser
andauthored
[UPDATE PRIMITIVE] Fix ZodEffects schema rejection in CLI tool registration and resolve_queries parameter name (#225)
* fix: use registerTool() instead of deprecated tool() to fix ZodEffects schema rejection by MCP SDK The MCP SDK's tool() method argument parsing rejects ZodEffects schemas (from buildEnhancedToolSchema) as 'unrecognized objects' because its isZodRawShapeCompat() check returns false for Zod schema instances. registerTool() passes inputSchema directly to getZodSchemaObject(), which correctly recognises any Zod schema instance, avoiding the error: 'Tool codeql_bqrs_decode expected a Zod schema or ToolAnnotations, but received an unrecognized object' Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/ba14c9e0-173d-49fd-820b-b77bfdd973b0 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> * fix: use correct parameter name 'directory' instead of 'path' for codeql_resolve_queries integration test The codeql_resolve_queries tool schema defines 'directory' as the parameter for specifying the directory to search for queries, but the integration test runner was sending 'path' which was rejected as an unknown property by the parameter normalization layer. Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/ba14c9e0-173d-49fd-820b-b77bfdd973b0 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
1 parent b5ceba5 commit 92af8e0

File tree

6 files changed

+93
-71
lines changed

6 files changed

+93
-71
lines changed

client/src/lib/integration-test-runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,8 @@ export class IntegrationTestRunner {
10841084
throw new Error(`Test directory ${beforeDir} not found for ${toolName}/${testCase}`);
10851085
}
10861086
} else if (toolName === "codeql_resolve_queries") {
1087-
// Use the test case directory as the queries path
1088-
params.path = beforeDir;
1087+
// Use the static examples directory which already contains installed QL packs
1088+
params.directory = path.join(staticPath, "src");
10891089
} else if (toolName === "codeql_resolve_tests") {
10901090
// Use the test case directory as the tests path
10911091
params.tests = [beforeDir];

server/dist/codeql-development-mcp-server.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193542,13 +193542,17 @@ function registerCLITool(server, definition) {
193542193542
resultProcessor = defaultCLIResultProcessor
193543193543
} = definition;
193544193544
const enhancedSchema = buildEnhancedToolSchema(inputSchema);
193545-
server.tool(
193545+
server.registerTool(
193546193546
name,
193547-
description,
193548-
// The enhanced schema is a pre-built ZodEffects (passthrough + transform).
193549-
// The MCP SDK's getZodSchemaObject() detects it as a Zod schema instance
193550-
// and passes it through without re-wrapping.
193551-
enhancedSchema,
193547+
{
193548+
description,
193549+
// The enhanced schema is a pre-built ZodEffects (passthrough + transform).
193550+
// Using registerTool() instead of tool() because the latter's argument
193551+
// parsing rejects ZodEffects as "unrecognized objects". registerTool()
193552+
// passes inputSchema directly to getZodSchemaObject(), which correctly
193553+
// recognises any Zod schema instance.
193554+
inputSchema: enhancedSchema
193555+
},
193552193556
async (params) => {
193553193557
const tempDirsToCleanup = [];
193554193558
try {

server/dist/codeql-development-mcp-server.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/lib/cli-tool-registry.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,17 @@ export function registerCLITool(server: McpServer, definition: CLIToolDefinition
115115
// produces actionable error messages for truly unknown keys.
116116
const enhancedSchema = buildEnhancedToolSchema(inputSchema);
117117

118-
server.tool(
118+
server.registerTool(
119119
name,
120-
description,
121-
// The enhanced schema is a pre-built ZodEffects (passthrough + transform).
122-
// The MCP SDK's getZodSchemaObject() detects it as a Zod schema instance
123-
// and passes it through without re-wrapping.
124-
enhancedSchema as unknown as Record<string, z.ZodTypeAny>,
120+
{
121+
description,
122+
// The enhanced schema is a pre-built ZodEffects (passthrough + transform).
123+
// Using registerTool() instead of tool() because the latter's argument
124+
// parsing rejects ZodEffects as "unrecognized objects". registerTool()
125+
// passes inputSchema directly to getZodSchemaObject(), which correctly
126+
// recognises any Zod schema instance.
127+
inputSchema: enhancedSchema,
128+
},
125129
async (params: Record<string, unknown>) => {
126130
// Track temporary directories for cleanup
127131
const tempDirsToCleanup: string[] = [];

0 commit comments

Comments
 (0)