fix(mcp): align runtime unknown argument validation
This commit is contained in:
@@ -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, []);
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user