Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(mcp): align runtime unknown argument validation
morlutod1e72207f486
diff --git a/src/server/toolInputValidation.ts b/src/server/toolInputValidation.tsindex ef29abc76..f8973dc62 100644--- a/src/server/toolInputValidation.ts+++ b/src/server/toolInputValidation.ts@@ -6,6 +6,7 @@ import {} from "../domain/errors.js";import { projectInputIssues } from "../domain/inputIssueProjection.js";import { err, ok, type Result } from "../domain/result.js";+import { closeObjectSchemas } from "./toolRegistrationOptions.js";/** Parse one MCP request exactly once and retain only schema-owned correction data. */export const safeParseToolInput = <Schema extends z.ZodType>(@@ -41,7 +42,7 @@ const unknownArgumentIssues = (throw new TypeError("Tool input schema does not expose Standard JSON Schema",);- jsonSchema = converter({ target: "draft-2020-12" });+ jsonSchema = closeObjectSchemas(converter({ target: "draft-2020-12" }));schemaCache.set(schema, jsonSchema);}return scanUnknownArguments(input, jsonSchema, jsonSchema, []);diff --git a/src/server/toolRegistrationOptions.ts b/src/server/toolRegistrationOptions.tsindex 2552c3241..f5d6616f3 100644--- a/src/server/toolRegistrationOptions.ts+++ b/src/server/toolRegistrationOptions.ts@@ -67,7 +67,8 @@ const inputJsonSchema = (schema: z.ZodObject): Record<string, unknown> => {return converter({ target: "draft-2020-12" });};-const closeObjectSchemas = (+/** Close fixed-shape JSON Schema objects while preserving explicit maps. */+export const closeObjectSchemas = (value: Readonly<Record<string, unknown>>,): Record<string, unknown> => {const closed = Object.fromEntries(diff --git a/tests/enhancedTools.test.ts b/tests/enhancedTools.test.tsindex 06dc20cf7..3899b6a57 100644--- a/tests/enhancedTools.test.ts+++ b/tests/enhancedTools.test.ts@@ -629,6 +629,28 @@ describe("enhanced MCP tools", () => {},},});+ const nestedMisspelled = await client.callTool({+ name: "analyze_function",+ arguments: {+ procedure: "0x1",+ collection_offset: { commentz: 1 },+ },+ });+ expect(nestedMisspelled).toMatchObject({+ isError: true,+ structuredContent: {+ error: {+ details: {+ issues: [+ {+ path: ["collection_offset", "commentz"],+ reason: "unknown_argument",+ },+ ],+ },+ },+ },+ });const bounded = await client.callTool({name: "trace_feature",arguments: { query: "needle", max_operations: 101 },