style(setup): format retained field validation

This commit is contained in:
morluto
2026-10-13 20:20:42 +08:00
parent 69582df9c3
commit 3370bab50b
4 changed files with 46 additions and 19 deletions
+2 -1
View File
@@ -36,7 +36,8 @@ export const registrationFieldAccepted = (
key: string,
value: unknown,
): boolean => {
const shape: Readonly<Record<string, z.ZodType>> = registrationSchemaFor(dialect).shape;
const shape: Readonly<Record<string, z.ZodType>> =
registrationSchemaFor(dialect).shape;
const field = Object.hasOwn(shape, key) ? shape[key] : undefined;
return field === undefined || field.safeParse(value).success;
};
+7 -2
View File
@@ -14,7 +14,10 @@ import { resolve } from "node:path";
import { z } from "zod";
import { registrationSchema, registrationSchemaFor } from "./ClientRegistrationShape.js";
import {
registrationSchema,
registrationSchemaFor,
} from "./ClientRegistrationShape.js";
import { PRODUCT_IDENTITY } from "../identity.js";
import { MCP_STARTUP_POLICY } from "../mcpStartupPolicy.js";
import {
@@ -322,7 +325,9 @@ const parseRegistration = (
args,
});
}
const registration = registrationSchemaFor(client.format ?? "json").parse(value);
const registration = registrationSchemaFor(client.format ?? "json").parse(
value,
);
if (
(client.format === "vscode" || client.format === "copilot_cli") &&
registration.type !== "stdio"
@@ -476,7 +476,6 @@ export const inspectClientConfiguration = async (
"The existing configuration is malformed. Repair it before setup applies any other changes.",
};
}
};
const clientRegistrationDialect = (