From 98fc900d5ace8574db9bddec84ab2644596baa24 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 15:07:43 -0700 Subject: [PATCH 01/25] WIP --- src/schemas/any.ts | 27 ++++++++++++++++++++------- src/schemas/index.ts | 4 ++-- src/types.ts | 10 ++++++++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/schemas/any.ts b/src/schemas/any.ts index bd7cec8..000eba4 100644 --- a/src/schemas/any.ts +++ b/src/schemas/any.ts @@ -5,11 +5,24 @@ import * as v0_2 from "./0.2.js"; import * as v0_3 from "./0.3.js"; /** - * Union schema that accepts any supported manifest version (0.1, 0.2, 0.3). - * Use this when you need to validate manifests of any version. + * Union schema that accepts any supported manifest version. + * Uses preprocessing to normalize dxt_version to manifest_version, + * then efficiently discriminates based on the now-required manifest_version field. */ -export const McpbManifestSchema = z.union([ - v0_1.McpbManifestSchema, - v0_2.McpbManifestSchema, - v0_3.McpbManifestSchema, -]); +export const McpbManifestSchema = z.preprocess( + (val) => { + // Normalize: if it has dxt_version, ensure manifest_version is also set + if (val && typeof val === "object" && "dxt_version" in val) { + const obj = val as Record; + if (!obj.manifest_version && obj.dxt_version) { + return { ...obj, manifest_version: obj.dxt_version }; + } + } + return val; + }, + z.union([ + v0_1.McpbManifestSchema, + v0_2.McpbManifestSchema, + v0_3.McpbManifestSchema, + ]), +); diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 3729f0e..df8ff1e 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -1,8 +1,8 @@ export * as v0_1 from "./0.1.js"; export * as v0_2 from "./0.2.js"; export * as v0_3 from "./0.3.js"; -export * as any from "./any.js"; -export * as latest from "./latest.js"; +export * as vAny from "./any.js"; +export * as vLatest from "./latest.js"; export { MANIFEST_VERSION as LATEST_MANIFEST_VERSION, McpbManifestSchema, diff --git a/src/types.ts b/src/types.ts index 9fb510f..e6ba766 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,6 @@ import type * as z from "zod"; -import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; +import type { McpbManifestSchema as McpbManifestSchema_vAny } from "./schemas/any.js"; import type { McpbManifestAuthorSchema, McpbManifestCompatibilitySchema, @@ -51,7 +51,7 @@ export type McpbUserConfigValues = z.infer; * McpbManifest type that accepts any supported manifest version * This is the default manifest type that should be used for maximum compatibility. */ -export type McpbManifest = z.infer; +export type McpbManifestAny = z.infer; /** * McpbManifest type for the latest manifest version only @@ -59,6 +59,12 @@ export type McpbManifest = z.infer; */ export type McpbManifestLatest = z.infer; +/** + * @deprecated Use McpbManifestAny instead + * Default manifest type that accepts any supported version + */ +export type McpbManifest = McpbManifestAny; + /** * Information about a MCPB package signature */ From f3ac79afda5d58823d2230256c0bc60912581823 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 15:27:38 -0700 Subject: [PATCH 02/25] update browser exports to incl. vAny schema --- src/browser.ts | 2 +- src/schemas/index.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/browser.ts b/src/browser.ts index d3f0598..36898b3 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1,5 +1,5 @@ // Browser-compatible exports export * from "./schemas/latest.js"; +export * from "./schemas/index.js"; export * from "./shared/config.js"; -export * from "./shared/constants.js"; export * from "./types.js"; diff --git a/src/schemas/index.ts b/src/schemas/index.ts index df8ff1e..06ad45c 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -1,3 +1,7 @@ +import { McpbManifestSchema as ManifestSchemaV0_1 } from "./0.1.js"; +import { McpbManifestSchema as ManifestSchemaV0_2 } from "./0.2.js"; +import { McpbManifestSchema as ManifestSchemaV0_3 } from "./0.3.js"; + export * as v0_1 from "./0.1.js"; export * as v0_2 from "./0.2.js"; export * as v0_3 from "./0.3.js"; @@ -5,5 +9,14 @@ export * as vAny from "./any.js"; export * as vLatest from "./latest.js"; export { MANIFEST_VERSION as LATEST_MANIFEST_VERSION, - McpbManifestSchema, + McpbManifestSchema as LatestMcpbManifestSchema, } from "./latest.js"; + +/** + * Map of manifest versions to their strict schemas + */ +export const VERSIONED_MANIFEST_SCHEMAS = { + "0.1": ManifestSchemaV0_1, + "0.2": ManifestSchemaV0_2, + "0.3": ManifestSchemaV0_3, +} as const; \ No newline at end of file From 86166630b449a31e5933e8b6b893a80a239bc45e Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 15:37:15 -0700 Subject: [PATCH 03/25] revert: undo preprocessing changes to any.ts and types.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts the preprocessing logic and type name changes to restore the simpler union schema approach. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/schemas/any.ts | 27 +++++++-------------------- src/types.ts | 10 ++-------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/schemas/any.ts b/src/schemas/any.ts index 000eba4..bd7cec8 100644 --- a/src/schemas/any.ts +++ b/src/schemas/any.ts @@ -5,24 +5,11 @@ import * as v0_2 from "./0.2.js"; import * as v0_3 from "./0.3.js"; /** - * Union schema that accepts any supported manifest version. - * Uses preprocessing to normalize dxt_version to manifest_version, - * then efficiently discriminates based on the now-required manifest_version field. + * Union schema that accepts any supported manifest version (0.1, 0.2, 0.3). + * Use this when you need to validate manifests of any version. */ -export const McpbManifestSchema = z.preprocess( - (val) => { - // Normalize: if it has dxt_version, ensure manifest_version is also set - if (val && typeof val === "object" && "dxt_version" in val) { - const obj = val as Record; - if (!obj.manifest_version && obj.dxt_version) { - return { ...obj, manifest_version: obj.dxt_version }; - } - } - return val; - }, - z.union([ - v0_1.McpbManifestSchema, - v0_2.McpbManifestSchema, - v0_3.McpbManifestSchema, - ]), -); +export const McpbManifestSchema = z.union([ + v0_1.McpbManifestSchema, + v0_2.McpbManifestSchema, + v0_3.McpbManifestSchema, +]); diff --git a/src/types.ts b/src/types.ts index e6ba766..9fb510f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,6 @@ import type * as z from "zod"; -import type { McpbManifestSchema as McpbManifestSchema_vAny } from "./schemas/any.js"; +import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; import type { McpbManifestAuthorSchema, McpbManifestCompatibilitySchema, @@ -51,7 +51,7 @@ export type McpbUserConfigValues = z.infer; * McpbManifest type that accepts any supported manifest version * This is the default manifest type that should be used for maximum compatibility. */ -export type McpbManifestAny = z.infer; +export type McpbManifest = z.infer; /** * McpbManifest type for the latest manifest version only @@ -59,12 +59,6 @@ export type McpbManifestAny = z.infer; */ export type McpbManifestLatest = z.infer; -/** - * @deprecated Use McpbManifestAny instead - * Default manifest type that accepts any supported version - */ -export type McpbManifest = McpbManifestAny; - /** * Information about a MCPB package signature */ From 5fb25a253e2d384b90d35fb457ba20de4c8f6c99 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 15:46:37 -0700 Subject: [PATCH 04/25] add McpbManifestAny type --- package.json | 2 +- src/types.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 8749e20..77f437a 100644 --- a/package.json +++ b/package.json @@ -99,4 +99,4 @@ "@babel/parser": "7.27.3" }, "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f" -} \ No newline at end of file +} diff --git a/src/types.ts b/src/types.ts index 9fb510f..44997e4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -47,18 +47,22 @@ export type McpbUserConfigurationOption = z.infer< export type McpbUserConfigValues = z.infer; -/** - * McpbManifest type that accepts any supported manifest version - * This is the default manifest type that should be used for maximum compatibility. - */ -export type McpbManifest = z.infer; - /** * McpbManifest type for the latest manifest version only * Use this when you specifically need the latest version. */ export type McpbManifestLatest = z.infer; +/** + * Alias for McpbManifestLatest for backwards compatibility. + */ +export type McpbManifest = McpbManifestLatest; + +/** + * McpbManifest type representing the union of all manifest versions + */ +export type McpbManifestAny = z.infer;; + /** * Information about a MCPB package signature */ From 2d76201204aed41f010b2ca9ff4779c2b3157548 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 16:34:02 -0700 Subject: [PATCH 05/25] Export versioned schemas and validation utilities in browser bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update browser.ts to export validation utilities - Export McpbManifestSchema for backwards compatibility - Update config.ts to accept McpbManifestAny for broader manifest version support - Add validate.ts with version-aware validation functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/browser.ts | 2 +- src/schemas/index.ts | 1 + src/schemas/validate.ts | 100 ++++++++++++++++++++++++++++++++++++++++ src/shared/config.ts | 5 +- 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 src/schemas/validate.ts diff --git a/src/browser.ts b/src/browser.ts index 36898b3..fcf4e14 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1,5 +1,5 @@ // Browser-compatible exports -export * from "./schemas/latest.js"; export * from "./schemas/index.js"; +export * from "./schemas/validate.js"; export * from "./shared/config.js"; export * from "./types.js"; diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 06ad45c..3afe1b1 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -10,6 +10,7 @@ export * as vLatest from "./latest.js"; export { MANIFEST_VERSION as LATEST_MANIFEST_VERSION, McpbManifestSchema as LatestMcpbManifestSchema, + McpbManifestSchema, // backwards compatibility - exports latest schema } from "./latest.js"; /** diff --git a/src/schemas/validate.ts b/src/schemas/validate.ts new file mode 100644 index 0000000..89063f7 --- /dev/null +++ b/src/schemas/validate.ts @@ -0,0 +1,100 @@ +import type * as z from "zod"; + +import * as v0_1 from "./0.1.js"; +import * as v0_2 from "./0.2.js"; +import * as v0_3 from "./0.3.js"; + +type McpbManifestV0_1 = z.infer; +type McpbManifestV0_2 = z.infer; +type McpbManifestV0_3 = z.infer; + +/** + * Union type representing any supported manifest version. + * This is the return type of validateManifest. + */ +type ValidatedManifest = McpbManifestV0_1 | McpbManifestV0_2 | McpbManifestV0_3; + +/** + * Validates a manifest using the appropriate schema based on its manifest_version. + * + * This function automatically detects the manifest version from the data and applies + * the correct schema. This avoids TypeScript "excessively deep" errors that can occur + * when using union schemas across package boundaries. + * + * @param data - The manifest data to validate + * @returns The validated manifest with the correct type + * @throws ZodError if validation fails + * + * @example + * ```typescript + * import { validateManifest } from '@anthropic-ai/mcpb/browser'; + * + * const manifest = validateManifest(unknownData); + * // manifest is typed as McpbManifestAny (union of all versions) + * ``` + */ +export function validateManifest(data: unknown): ValidatedManifest { + // Read manifest_version or dxt_version from data + const version = (data as any)?.manifest_version || (data as any)?.dxt_version; + + // Use appropriate schema based on version + if (version === "0.1") { + return v0_1.McpbManifestSchema.parse(data); + } + + if (version === "0.2") { + return v0_2.McpbManifestSchema.parse(data); + } + + // Default to latest version (0.3) if not specified or if version is "0.3" + return v0_3.McpbManifestSchema.parse(data); +} + +/** + * Validates a manifest using the appropriate schema, returning a Result-style object. + * + * @param data - The manifest data to validate + * @returns An object with either { success: true, data } or { success: false, error } + * + * @example + * ```typescript + * import { validateManifestSafe } from '@anthropic-ai/mcpb/browser'; + * + * const result = validateManifestSafe(unknownData); + * if (result.success) { + * console.log(result.data); + * } else { + * console.error(result.error); + * } + * ``` + */ +export function validateManifestSafe(data: unknown): + | { success: true; data: ValidatedManifest } + | { success: false; error: unknown } { + try { + return { success: true, data: validateManifest(data) }; + } catch (error) { + return { success: false, error }; + } +} + +/** + * Get the appropriate schema for a given manifest version. + * Useful when you need to work with the schema directly. + * + * @param version - The manifest version (e.g., "0.1", "0.2", "0.3") + * @returns The schema for that version + * + * @example + * ```typescript + * import { getSchemaForVersion } from '@anthropic-ai/mcpb/browser'; + * + * const schema = getSchemaForVersion("0.2"); + * const result = schema.safeParse(data); + * ``` + */ +export function getSchemaForVersion(version: "0.1" | "0.2" | "0.3") { + if (version === "0.1") return v0_1.McpbManifestSchema; + if (version === "0.2") return v0_2.McpbManifestSchema; + return v0_3.McpbManifestSchema; +} diff --git a/src/shared/config.ts b/src/shared/config.ts index 20e4262..bf8391c 100644 --- a/src/shared/config.ts +++ b/src/shared/config.ts @@ -1,6 +1,7 @@ import type { Logger, McpbManifest, + McpbManifestAny, McpbUserConfigValues, McpServerConfig, } from "../types.js"; @@ -85,7 +86,7 @@ export function replaceVariables( } interface GetMcpConfigForManifestOptions { - manifest: McpbManifest; + manifest: McpbManifestAny; extensionPath: string; systemDirs: Record; userConfig: McpbUserConfigValues; @@ -179,7 +180,7 @@ export async function getMcpConfigForManifest( } interface HasRequiredConfigMissingOptions { - manifest: McpbManifest; + manifest: McpbManifestAny; userConfig?: McpbUserConfigValues; } From c137df512d41cfce5bc251d7089f1a2b8b3bd03f Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 19:44:19 -0700 Subject: [PATCH 06/25] Remove validate utilities from browser exports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes the validateManifest utilities that were added to the browser bundle. These functions are not needed for the browser export. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/browser.ts | 1 - src/schemas/validate.ts | 100 ---------------------------------------- 2 files changed, 101 deletions(-) delete mode 100644 src/schemas/validate.ts diff --git a/src/browser.ts b/src/browser.ts index fcf4e14..71c124f 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1,5 +1,4 @@ // Browser-compatible exports export * from "./schemas/index.js"; -export * from "./schemas/validate.js"; export * from "./shared/config.js"; export * from "./types.js"; diff --git a/src/schemas/validate.ts b/src/schemas/validate.ts deleted file mode 100644 index 89063f7..0000000 --- a/src/schemas/validate.ts +++ /dev/null @@ -1,100 +0,0 @@ -import type * as z from "zod"; - -import * as v0_1 from "./0.1.js"; -import * as v0_2 from "./0.2.js"; -import * as v0_3 from "./0.3.js"; - -type McpbManifestV0_1 = z.infer; -type McpbManifestV0_2 = z.infer; -type McpbManifestV0_3 = z.infer; - -/** - * Union type representing any supported manifest version. - * This is the return type of validateManifest. - */ -type ValidatedManifest = McpbManifestV0_1 | McpbManifestV0_2 | McpbManifestV0_3; - -/** - * Validates a manifest using the appropriate schema based on its manifest_version. - * - * This function automatically detects the manifest version from the data and applies - * the correct schema. This avoids TypeScript "excessively deep" errors that can occur - * when using union schemas across package boundaries. - * - * @param data - The manifest data to validate - * @returns The validated manifest with the correct type - * @throws ZodError if validation fails - * - * @example - * ```typescript - * import { validateManifest } from '@anthropic-ai/mcpb/browser'; - * - * const manifest = validateManifest(unknownData); - * // manifest is typed as McpbManifestAny (union of all versions) - * ``` - */ -export function validateManifest(data: unknown): ValidatedManifest { - // Read manifest_version or dxt_version from data - const version = (data as any)?.manifest_version || (data as any)?.dxt_version; - - // Use appropriate schema based on version - if (version === "0.1") { - return v0_1.McpbManifestSchema.parse(data); - } - - if (version === "0.2") { - return v0_2.McpbManifestSchema.parse(data); - } - - // Default to latest version (0.3) if not specified or if version is "0.3" - return v0_3.McpbManifestSchema.parse(data); -} - -/** - * Validates a manifest using the appropriate schema, returning a Result-style object. - * - * @param data - The manifest data to validate - * @returns An object with either { success: true, data } or { success: false, error } - * - * @example - * ```typescript - * import { validateManifestSafe } from '@anthropic-ai/mcpb/browser'; - * - * const result = validateManifestSafe(unknownData); - * if (result.success) { - * console.log(result.data); - * } else { - * console.error(result.error); - * } - * ``` - */ -export function validateManifestSafe(data: unknown): - | { success: true; data: ValidatedManifest } - | { success: false; error: unknown } { - try { - return { success: true, data: validateManifest(data) }; - } catch (error) { - return { success: false, error }; - } -} - -/** - * Get the appropriate schema for a given manifest version. - * Useful when you need to work with the schema directly. - * - * @param version - The manifest version (e.g., "0.1", "0.2", "0.3") - * @returns The schema for that version - * - * @example - * ```typescript - * import { getSchemaForVersion } from '@anthropic-ai/mcpb/browser'; - * - * const schema = getSchemaForVersion("0.2"); - * const result = schema.safeParse(data); - * ``` - */ -export function getSchemaForVersion(version: "0.1" | "0.2" | "0.3") { - if (version === "0.1") return v0_1.McpbManifestSchema; - if (version === "0.2") return v0_2.McpbManifestSchema; - return v0_3.McpbManifestSchema; -} From 05187d72359bf77c631b2dc772a6ae24d2fa1023 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 20:27:58 -0700 Subject: [PATCH 07/25] Remove zod resolution and bump version to 1.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed zod version resolution from package.json - Bumped version from 1.1.5 to 1.2.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- package.json | 2 +- src/schemas/index.ts | 1 + yarn.lock | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 77f437a..92a270e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@anthropic-ai/mcpb", "description": "Tools for building MCP Bundles", - "version": "1.1.5", + "version": "1.2.0", "type": "module", "main": "dist/index.js", "module": "dist/index.js", diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 3afe1b1..c87eb72 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -11,6 +11,7 @@ export { MANIFEST_VERSION as LATEST_MANIFEST_VERSION, McpbManifestSchema as LatestMcpbManifestSchema, McpbManifestSchema, // backwards compatibility - exports latest schema + McpbUserConfigValuesSchema, // lightweight schema for direct import without loading full vLatest namespace } from "./latest.js"; /** diff --git a/yarn.lock b/yarn.lock index 593a7a5..220968b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6398,8 +6398,8 @@ __metadata: linkType: hard "zod@npm:^3.25.67": - version: 3.25.67 - resolution: "zod@npm:3.25.67" - checksum: 10c0/80a0cab3033272c4ab9312198081f0c4ea88e9673c059aa36dc32024906363729db54bdb78f3dc9d5529bd1601f74974d5a56c0a23e40c6f04a9270c9ff22336 + version: 3.25.76 + resolution: "zod@npm:3.25.76" + checksum: 10c0/5718ec35e3c40b600316c5b4c5e4976f7fee68151bc8f8d90ec18a469be9571f072e1bbaace10f1e85cf8892ea12d90821b200e980ab46916a6166a4260a983c languageName: node linkType: hard From 3538bd4f3b8b4d23b942bf85fe9caa72b1aa8d0a Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 20:29:04 -0700 Subject: [PATCH 08/25] Bump version to 1.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 92a270e..4e7f01b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@anthropic-ai/mcpb", "description": "Tools for building MCP Bundles", - "version": "1.2.0", + "version": "1.3.0", "type": "module", "main": "dist/index.js", "module": "dist/index.js", From 753f27e1ba0786421166d8b542ee5341c8d5479f Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 20:31:26 -0700 Subject: [PATCH 09/25] Revert yarn.lock to match main (zod 3.25.67) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 220968b..593a7a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6398,8 +6398,8 @@ __metadata: linkType: hard "zod@npm:^3.25.67": - version: 3.25.76 - resolution: "zod@npm:3.25.76" - checksum: 10c0/5718ec35e3c40b600316c5b4c5e4976f7fee68151bc8f8d90ec18a469be9571f072e1bbaace10f1e85cf8892ea12d90821b200e980ab46916a6166a4260a983c + version: 3.25.67 + resolution: "zod@npm:3.25.67" + checksum: 10c0/80a0cab3033272c4ab9312198081f0c4ea88e9673c059aa36dc32024906363729db54bdb78f3dc9d5529bd1601f74974d5a56c0a23e40c6f04a9270c9ff22336 languageName: node linkType: hard From 7f40d5be4228d860861fd9deb8e2a8ee9619a10f Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 20:34:47 -0700 Subject: [PATCH 10/25] rm McpbUserConfigValuesSchema export --- src/schemas/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/schemas/index.ts b/src/schemas/index.ts index c87eb72..3afe1b1 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -11,7 +11,6 @@ export { MANIFEST_VERSION as LATEST_MANIFEST_VERSION, McpbManifestSchema as LatestMcpbManifestSchema, McpbManifestSchema, // backwards compatibility - exports latest schema - McpbUserConfigValuesSchema, // lightweight schema for direct import without loading full vLatest namespace } from "./latest.js"; /** From e7d6ea3e6819ed32caeeefccd83f1ed69439f4f7 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 20:37:15 -0700 Subject: [PATCH 11/25] Fix type error in buildManifest return type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed return type to use the specific v0.2 manifest schema type since the function returns a manifest with DEFAULT_MANIFEST_VERSION (0.2). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/init.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index 7682e0f..b462ced 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -3,7 +3,8 @@ import { existsSync, readFileSync, writeFileSync } from "fs"; import { basename, join, resolve } from "path"; import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js"; -import type { McpbManifest } from "../types.js"; +import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "../schemas/0.2.js"; +import type * as z from "zod"; interface PackageJson { name?: string; @@ -878,7 +879,7 @@ export function buildManifest( resources: string; default_locale: string; }, -): McpbManifest { +): z.infer { const { name, displayName, version, description, authorName } = basicInfo; const { authorEmail, authorUrl } = authorInfo; const { serverType, entryPoint, mcp_config } = serverConfig; From d7f76fc02d428c5c476af5cbd124e62664b632a0 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Sat, 1 Nov 2025 20:41:34 -0700 Subject: [PATCH 12/25] Fix linting issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove unused McpbManifest import from config.ts - Auto-fix formatting and import sorting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/init.ts | 4 ++-- src/schemas/index.ts | 2 +- src/shared/config.ts | 1 - src/types.ts | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index b462ced..3b2ad80 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -1,10 +1,10 @@ import { confirm, input, select } from "@inquirer/prompts"; import { existsSync, readFileSync, writeFileSync } from "fs"; import { basename, join, resolve } from "path"; +import type * as z from "zod"; -import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js"; import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "../schemas/0.2.js"; -import type * as z from "zod"; +import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js"; interface PackageJson { name?: string; diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 3afe1b1..70a8e32 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -20,4 +20,4 @@ export const VERSIONED_MANIFEST_SCHEMAS = { "0.1": ManifestSchemaV0_1, "0.2": ManifestSchemaV0_2, "0.3": ManifestSchemaV0_3, -} as const; \ No newline at end of file +} as const; diff --git a/src/shared/config.ts b/src/shared/config.ts index bf8391c..9ce016c 100644 --- a/src/shared/config.ts +++ b/src/shared/config.ts @@ -1,6 +1,5 @@ import type { Logger, - McpbManifest, McpbManifestAny, McpbUserConfigValues, McpServerConfig, diff --git a/src/types.ts b/src/types.ts index 44997e4..f8b7966 100644 --- a/src/types.ts +++ b/src/types.ts @@ -61,7 +61,7 @@ export type McpbManifest = McpbManifestLatest; /** * McpbManifest type representing the union of all manifest versions */ -export type McpbManifestAny = z.infer;; +export type McpbManifestAny = z.infer; /** * Information about a MCPB package signature From 30a3b8e7798792abff5a102220e6e4cf443139d6 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 15:30:03 -0800 Subject: [PATCH 13/25] Remove vLatest concept and associated files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the concept of "vLatest" throughout the codebase to encourage use of McpbManifestAny which supports all manifest versions. Changes include: - Delete src/schemas/latest.ts and src/schemas_loose/latest.ts - Remove vLatest and latest-related exports from schema index files - Remove McpbManifestLatest type, replace McpbManifest to point to McpbManifestAny - Remove LATEST_MANIFEST_VERSION, LATEST_MANIFEST_SCHEMA constants - Update all main export files (index.ts, cli.ts, node.ts) to export from 0.3.js instead of latest.js - Update tests to use v0_3.McpbManifestSchema explicitly - Add @deprecated annotation to McpbManifest directing users to McpbManifestAny This encourages better version compatibility by using the union type that supports all manifest versions rather than assuming a single "latest" version. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli.ts | 2 +- src/index.ts | 2 +- src/node.ts | 2 +- src/schemas/index.ts | 6 ------ src/schemas/latest.ts | 1 - src/schemas_loose/index.ts | 1 - src/schemas_loose/latest.ts | 1 - src/shared/constants.ts | 20 -------------------- src/types.ts | 17 +++++------------ test/schemas.test.ts | 24 ++++++++++++------------ 10 files changed, 20 insertions(+), 56 deletions(-) delete mode 100644 src/schemas/latest.ts delete mode 100644 src/schemas_loose/latest.ts diff --git a/src/cli.ts b/src/cli.ts index 5dc861c..809d6d4 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -3,7 +3,7 @@ export * from "./cli/init.js"; export * from "./cli/pack.js"; // Include all shared exports -export * from "./schemas/latest.js"; +export * from "./schemas/0.3.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; export * from "./types.js"; diff --git a/src/index.ts b/src/index.ts index 62ada47..114e50d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ export * from "./cli/unpack.js"; export * from "./node/files.js"; export * from "./node/sign.js"; export * from "./node/validate.js"; -export * from "./schemas/latest.js"; +export * from "./schemas/0.3.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; export * from "./types.js"; diff --git a/src/node.ts b/src/node.ts index 12a7edb..10aa2b5 100644 --- a/src/node.ts +++ b/src/node.ts @@ -4,7 +4,7 @@ export * from "./node/sign.js"; export * from "./node/validate.js"; // Include all shared exports -export * from "./schemas/latest.js"; +export * from "./schemas/0.3.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; export * from "./types.js"; diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 70a8e32..897b95b 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -6,12 +6,6 @@ export * as v0_1 from "./0.1.js"; export * as v0_2 from "./0.2.js"; export * as v0_3 from "./0.3.js"; export * as vAny from "./any.js"; -export * as vLatest from "./latest.js"; -export { - MANIFEST_VERSION as LATEST_MANIFEST_VERSION, - McpbManifestSchema as LatestMcpbManifestSchema, - McpbManifestSchema, // backwards compatibility - exports latest schema -} from "./latest.js"; /** * Map of manifest versions to their strict schemas diff --git a/src/schemas/latest.ts b/src/schemas/latest.ts deleted file mode 100644 index e79a613..0000000 --- a/src/schemas/latest.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./0.3.js"; diff --git a/src/schemas_loose/index.ts b/src/schemas_loose/index.ts index 3548b1d..f84f84c 100644 --- a/src/schemas_loose/index.ts +++ b/src/schemas_loose/index.ts @@ -1,4 +1,3 @@ export * as v0_1 from "./0.1.js"; export * as v0_2 from "./0.2.js"; export * as v0_3 from "./0.3.js"; -export * as latest from "./latest.js"; diff --git a/src/schemas_loose/latest.ts b/src/schemas_loose/latest.ts deleted file mode 100644 index e79a613..0000000 --- a/src/schemas_loose/latest.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./0.3.js"; diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 6d16f5d..b39e27c 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -1,17 +1,9 @@ import { McpbManifestSchema as ManifestSchemaV0_1 } from "../schemas/0.1.js"; import { McpbManifestSchema as ManifestSchemaV0_2 } from "../schemas/0.2.js"; import { McpbManifestSchema as ManifestSchemaV0_3 } from "../schemas/0.3.js"; -import { McpbManifestSchema as CurrentManifestSchema } from "../schemas/latest.js"; import { McpbManifestSchema as LooseManifestSchemaV0_1 } from "../schemas_loose/0.1.js"; import { McpbManifestSchema as LooseManifestSchemaV0_2 } from "../schemas_loose/0.2.js"; import { McpbManifestSchema as LooseManifestSchemaV0_3 } from "../schemas_loose/0.3.js"; -import { McpbManifestSchema as CurrentLooseManifestSchema } from "../schemas_loose/latest.js"; - -/** - * Latest manifest version - the version that new manifests should use - * @deprecated - */ -export const LATEST_MANIFEST_VERSION = "0.3" as const; /** * Default manifest version for new packages @@ -35,15 +27,3 @@ export const MANIFEST_SCHEMAS_LOOSE = { "0.2": LooseManifestSchemaV0_2, "0.3": LooseManifestSchemaV0_3, } as const; - -/** - * Get the latest manifest schema based on LATEST_MANIFEST_VERSION - * @deprecated - */ -export const LATEST_MANIFEST_SCHEMA = CurrentManifestSchema; - -/** - * Get the latest loose manifest schema based on LATEST_MANIFEST_VERSION - * @deprecated - */ -export const LATEST_MANIFEST_SCHEMA_LOOSE = CurrentLooseManifestSchema; diff --git a/src/types.ts b/src/types.ts index f8b7966..6ca81ff 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,14 +8,13 @@ import type { McpbManifestPlatformOverrideSchema, McpbManifestPromptSchema, McpbManifestRepositorySchema, - McpbManifestSchema, McpbManifestServerSchema, McpbManifestToolSchema, McpbSignatureInfoSchema, McpbUserConfigurationOptionSchema, McpbUserConfigValuesSchema, McpServerConfigSchema, -} from "./schemas/latest.js"; +} from "./schemas/0.3.js"; export type McpServerConfig = z.infer; @@ -48,20 +47,14 @@ export type McpbUserConfigurationOption = z.infer< export type McpbUserConfigValues = z.infer; /** - * McpbManifest type for the latest manifest version only - * Use this when you specifically need the latest version. - */ -export type McpbManifestLatest = z.infer; - -/** - * Alias for McpbManifestLatest for backwards compatibility. + * McpbManifest type representing the union of all manifest versions */ -export type McpbManifest = McpbManifestLatest; +export type McpbManifestAny = z.infer; /** - * McpbManifest type representing the union of all manifest versions + * @deprecated Use McpbManifestAny instead to support all manifest versions. */ -export type McpbManifestAny = z.infer; +export type McpbManifest = McpbManifestAny; /** * Information about a MCPB package signature diff --git a/test/schemas.test.ts b/test/schemas.test.ts index 70f181f..6dab726 100644 --- a/test/schemas.test.ts +++ b/test/schemas.test.ts @@ -1,7 +1,7 @@ import { readFileSync } from "fs"; import { join } from "path"; -import { McpbManifestSchema, v0_2, v0_3 } from "../src/schemas/index.js"; +import { v0_2, v0_3 } from "../src/schemas/index.js"; describe("McpbManifestSchema", () => { it("should validate a valid manifest", () => { @@ -9,7 +9,7 @@ describe("McpbManifestSchema", () => { const manifestContent = readFileSync(manifestPath, "utf-8"); const manifestData = JSON.parse(manifestContent); - const result = McpbManifestSchema.safeParse(manifestData); + const result = v0_3.McpbManifestSchema.safeParse(manifestData); expect(result.success).toBe(true); if (result.success) { @@ -23,11 +23,11 @@ describe("McpbManifestSchema", () => { const manifestContent = readFileSync(manifestPath, "utf-8"); const manifestData = JSON.parse(manifestContent); - const result = McpbManifestSchema.safeParse(manifestData); + const result = v0_3.McpbManifestSchema.safeParse(manifestData); expect(result.success).toBe(false); if (!result.success) { - const errors = result.error.issues.map((issue) => issue.path.join(".")); + const errors = result.error.issues.map((issue: any) => issue.path.join(".")); expect(errors).toContain("author.name"); expect(errors).toContain("author.email"); expect(errors).toContain("server.type"); @@ -134,7 +134,7 @@ describe("McpbManifestSchema", () => { }, }; - const result = McpbManifestSchema.safeParse(fullManifest); + const result = v0_3.McpbManifestSchema.safeParse(fullManifest); expect(result.success).toBe(true); if (result.success) { @@ -167,7 +167,7 @@ describe("McpbManifestSchema", () => { }, }; - const result = McpbManifestSchema.safeParse(manifest); + const result = v0_3.McpbManifestSchema.safeParse(manifest); expect(result.success).toBe(true); }); }); @@ -270,10 +270,10 @@ describe("McpbManifestSchema", () => { default_locale: "en-US", }, }; - const result = McpbManifestSchema.safeParse(manifest); + const result = v0_3.McpbManifestSchema.safeParse(manifest); expect(result.success).toBe(false); if (!result.success) { - const messages = result.error.issues.map((issue) => issue.message); + const messages = result.error.issues.map((issue: any) => issue.message); expect(messages.join(" ")).toContain("${locale}"); } }); @@ -286,7 +286,7 @@ describe("McpbManifestSchema", () => { default_locale: "en_us", }, }; - const result = McpbManifestSchema.safeParse(manifest); + const result = v0_3.McpbManifestSchema.safeParse(manifest); expect(result.success).toBe(false); }); @@ -298,7 +298,7 @@ describe("McpbManifestSchema", () => { default_locale: "en-US", }, }; - const result = McpbManifestSchema.safeParse(manifest); + const result = v0_3.McpbManifestSchema.safeParse(manifest); expect(result.success).toBe(true); }); }); @@ -322,7 +322,7 @@ describe("McpbManifestSchema", () => { ...base, icons: [{ src: "assets/icon.png", size: "16", theme: "light" }], }; - const result = McpbManifestSchema.safeParse(manifest); + const result = v0_3.McpbManifestSchema.safeParse(manifest); expect(result.success).toBe(false); }); @@ -331,7 +331,7 @@ describe("McpbManifestSchema", () => { ...base, icons: [{ src: "assets/icon.png", size: "128x128" }], }; - const result = McpbManifestSchema.safeParse(manifest); + const result = v0_3.McpbManifestSchema.safeParse(manifest); expect(result.success).toBe(true); }); }); From efe9e3345dd5d612257bab157dd0e0b935dc8722 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 15:33:31 -0800 Subject: [PATCH 14/25] Make McpbManifest point to v0.2 for backwards compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change McpbManifest type to point to v0.2 schema instead of McpbManifestAny - Add DEFAULT_MANIFEST_VERSION export to browser.ts - Update test fixtures to use manifest_version "0.2" when using McpbManifest type - Keep @deprecated annotation directing users to McpbManifestAny for multi-version support This maintains backwards compatibility for existing code using McpbManifest while encouraging new code to use McpbManifestAny for broader version support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/browser.ts | 1 + src/types.ts | 4 +++- test/config.test.ts | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/browser.ts b/src/browser.ts index 71c124f..037b024 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1,4 +1,5 @@ // Browser-compatible exports export * from "./schemas/index.js"; export * from "./shared/config.js"; +export * from "./shared/constants.js"; export * from "./types.js"; diff --git a/src/types.ts b/src/types.ts index 6ca81ff..20296af 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,7 @@ import type * as z from "zod"; import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; +import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "./schemas/0.2.js"; import type { McpbManifestAuthorSchema, McpbManifestCompatibilitySchema, @@ -52,9 +53,10 @@ export type McpbUserConfigValues = z.infer; export type McpbManifestAny = z.infer; /** + * McpbManifest type for v0.2 (default version) for backwards compatibility * @deprecated Use McpbManifestAny instead to support all manifest versions. */ -export type McpbManifest = McpbManifestAny; +export type McpbManifest = z.infer; /** * Information about a MCPB package signature diff --git a/test/config.test.ts b/test/config.test.ts index f7a0eb8..062c66e 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -90,7 +90,7 @@ describe("getMcpConfigForManifest", () => { }; const baseManifest: McpbManifest = { - manifest_version: "0.3", + manifest_version: "0.2", name: "test-extension", version: "1.0.0", description: "Test extension", @@ -305,7 +305,7 @@ describe("getMcpConfigForManifest", () => { describe("hasRequiredConfigMissing", () => { const baseManifest: McpbManifest = { - manifest_version: "0.3", + manifest_version: "0.2", name: "test-extension", version: "1.0.0", description: "Test extension", From 70c3615fc92e7c3beeba565c9a7ddc2aeeb496f5 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 15:35:15 -0800 Subject: [PATCH 15/25] Add LATEST_MANIFEST_VERSION export (hardcoded to 0.3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Export LATEST_MANIFEST_VERSION to indicate the maximum supported manifest version by the vAny schema. This allows clients to know what the highest version is that they can use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/shared/constants.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shared/constants.ts b/src/shared/constants.ts index b39e27c..53b08ed 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -5,6 +5,11 @@ import { McpbManifestSchema as LooseManifestSchemaV0_1 } from "../schemas_loose/ import { McpbManifestSchema as LooseManifestSchemaV0_2 } from "../schemas_loose/0.2.js"; import { McpbManifestSchema as LooseManifestSchemaV0_3 } from "../schemas_loose/0.3.js"; +/** + * Latest manifest version - indicates the maximum supported version by vAny schema + */ +export const LATEST_MANIFEST_VERSION = "0.3" as const; + /** * Default manifest version for new packages */ From 3fffc30560cee0ef99560c2f3e542a15c72d795e Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 15:47:05 -0800 Subject: [PATCH 16/25] Use McpbManifestDefault derived from DEFAULT_MANIFEST_VERSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Create McpbManifestDefault type derived from VERSIONED_MANIFEST_SCHEMAS[DEFAULT_MANIFEST_VERSION] - Update init.ts to use McpbManifestDefault instead of hardcoded v0.2 schema - Import schema types from version matching DEFAULT_MANIFEST_VERSION (0.2) - Update test to match commented-out localization field - Make McpbManifest (deprecated) point to McpbManifestDefault This makes the codebase more maintainable by deriving types from DEFAULT_MANIFEST_VERSION instead of hardcoding version references. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/init.ts | 7 +++---- src/types.ts | 19 ++++++++++++++----- test/init.test.ts | 4 ---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index 3b2ad80..be8eaa5 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -1,10 +1,9 @@ import { confirm, input, select } from "@inquirer/prompts"; import { existsSync, readFileSync, writeFileSync } from "fs"; import { basename, join, resolve } from "path"; -import type * as z from "zod"; -import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "../schemas/0.2.js"; import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js"; +import type { McpbManifestDefault } from "../types.js"; interface PackageJson { name?: string; @@ -879,7 +878,7 @@ export function buildManifest( resources: string; default_locale: string; }, -): z.infer { +): McpbManifestDefault { const { name, displayName, version, description, authorName } = basicInfo; const { authorEmail, authorUrl } = authorInfo; const { serverType, entryPoint, mcp_config } = serverConfig; @@ -907,7 +906,7 @@ export function buildManifest( ...(visualAssets.screenshots.length > 0 ? { screenshots: visualAssets.screenshots } : {}), - ...(localization ? { localization } : {}), + // ...(localization ? { localization } : {}), server: { type: serverType, entry_point: entryPoint, diff --git a/src/types.ts b/src/types.ts index 20296af..90c5c1d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,8 @@ import type * as z from "zod"; import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; -import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "./schemas/0.2.js"; +import { VERSIONED_MANIFEST_SCHEMAS } from "./schemas/index.js"; +// Import schema types from the version matching DEFAULT_MANIFEST_VERSION import type { McpbManifestAuthorSchema, McpbManifestCompatibilitySchema, @@ -15,7 +16,8 @@ import type { McpbUserConfigurationOptionSchema, McpbUserConfigValuesSchema, McpServerConfigSchema, -} from "./schemas/0.3.js"; +} from "./schemas/0.2.js"; +import { DEFAULT_MANIFEST_VERSION } from "./shared/constants.js"; export type McpServerConfig = z.infer; @@ -53,10 +55,17 @@ export type McpbUserConfigValues = z.infer; export type McpbManifestAny = z.infer; /** - * McpbManifest type for v0.2 (default version) for backwards compatibility - * @deprecated Use McpbManifestAny instead to support all manifest versions. + * McpbManifest type for the DEFAULT_MANIFEST_VERSION + * Use this for creating new manifests with the default version. */ -export type McpbManifest = z.infer; +export type McpbManifestDefault = z.infer< + (typeof VERSIONED_MANIFEST_SCHEMAS)[typeof DEFAULT_MANIFEST_VERSION] +>; + +/** + * @deprecated Use McpbManifestAny instead to support all manifest versions, or McpbManifestDefault for the default version. + */ +export type McpbManifest = McpbManifestDefault; /** * Information about a MCPB package signature diff --git a/test/init.test.ts b/test/init.test.ts index a9b9bf4..def2e9c 100644 --- a/test/init.test.ts +++ b/test/init.test.ts @@ -351,10 +351,6 @@ describe("init functions", () => { }, ], screenshots: ["screen1.png", "screen2.png"], - localization: { - resources: "resources/${locale}.json", - default_locale: "en-US", - }, server: { type: "python", entry_point: "server/main.py", From 8018a9a2e097c8c8ae0625e6ad47a0c8082d258c Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 15:54:54 -0800 Subject: [PATCH 17/25] Remove latest schema reference from build script The build script was still importing from the deleted schemas/latest.js file. Updated to import McpbSignatureInfoSchema from 0.3.js and removed the mcpb-manifest-latest entry from versionedManifestSchemas. --- scripts/build-mcpb-schema.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/build-mcpb-schema.js b/scripts/build-mcpb-schema.js index a62fcdb..dce003b 100644 --- a/scripts/build-mcpb-schema.js +++ b/scripts/build-mcpb-schema.js @@ -1,10 +1,9 @@ -import { - McpbManifestSchema as McpbManifestSchemaLatest, - McpbSignatureInfoSchema, -} from "../dist/schemas/latest.js"; import { McpbManifestSchema as McpbManifestSchema_v0_1 } from "../dist/schemas/0.1.js"; import { McpbManifestSchema as McpbManifestSchema_v0_2 } from "../dist/schemas/0.2.js"; -import { McpbManifestSchema as McpbManifestSchema_v0_3 } from "../dist/schemas/0.3.js"; +import { + McpbManifestSchema as McpbManifestSchema_v0_3, + McpbSignatureInfoSchema, +} from "../dist/schemas/0.3.js"; import { zodToJsonSchema } from "zod-to-json-schema"; import fs from "node:fs/promises"; import path from "node:path"; @@ -17,7 +16,6 @@ const versionedManifestSchemas = { "mcpb-manifest-v0.1": McpbManifestSchema_v0_1, "mcpb-manifest-v0.2": McpbManifestSchema_v0_2, "mcpb-manifest-v0.3": McpbManifestSchema_v0_3, - "mcpb-manifest-latest": McpbManifestSchemaLatest, }; // Other schemas From 21c97105842bf09d213d3bdc0bd35073095b8e25 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 15:57:20 -0800 Subject: [PATCH 18/25] Fix lint errors in types.ts and remove any casts - Use import type for VERSIONED_MANIFEST_SCHEMAS and DEFAULT_MANIFEST_VERSION - Remove unnecessary any type annotations from test file --- src/types.ts | 4 ++-- test/schemas.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/types.ts b/src/types.ts index 90c5c1d..63e5e38 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,8 @@ import type * as z from "zod"; import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; -import { VERSIONED_MANIFEST_SCHEMAS } from "./schemas/index.js"; +import type { VERSIONED_MANIFEST_SCHEMAS } from "./schemas/index.js"; +import type { DEFAULT_MANIFEST_VERSION } from "./shared/constants.js"; // Import schema types from the version matching DEFAULT_MANIFEST_VERSION import type { McpbManifestAuthorSchema, @@ -17,7 +18,6 @@ import type { McpbUserConfigValuesSchema, McpServerConfigSchema, } from "./schemas/0.2.js"; -import { DEFAULT_MANIFEST_VERSION } from "./shared/constants.js"; export type McpServerConfig = z.infer; diff --git a/test/schemas.test.ts b/test/schemas.test.ts index 6dab726..52943e0 100644 --- a/test/schemas.test.ts +++ b/test/schemas.test.ts @@ -27,7 +27,7 @@ describe("McpbManifestSchema", () => { expect(result.success).toBe(false); if (!result.success) { - const errors = result.error.issues.map((issue: any) => issue.path.join(".")); + const errors = result.error.issues.map((issue) => issue.path.join(".")); expect(errors).toContain("author.name"); expect(errors).toContain("author.email"); expect(errors).toContain("server.type"); @@ -273,7 +273,7 @@ describe("McpbManifestSchema", () => { const result = v0_3.McpbManifestSchema.safeParse(manifest); expect(result.success).toBe(false); if (!result.success) { - const messages = result.error.issues.map((issue: any) => issue.message); + const messages = result.error.issues.map((issue) => issue.message); expect(messages.join(" ")).toContain("${locale}"); } }); From 3a9ee6e0071149d1137eef0b76a991a7c3dd7a2d Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 15:59:40 -0800 Subject: [PATCH 19/25] Export schemas/index instead of specific version Changed all entry points (index.ts, cli.ts, node.ts) to export from schemas/index.js instead of schemas/0.3.js. This provides access to all versioned schemas (v0_1, v0_2, v0_3, vAny) and VERSIONED_MANIFEST_SCHEMAS without exposing a specific version. --- src/cli.ts | 2 +- src/index.ts | 2 +- src/node.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 809d6d4..a11144a 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -3,7 +3,7 @@ export * from "./cli/init.js"; export * from "./cli/pack.js"; // Include all shared exports -export * from "./schemas/0.3.js"; +export * from "./schemas/index.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; export * from "./types.js"; diff --git a/src/index.ts b/src/index.ts index 114e50d..1aad967 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ export * from "./cli/unpack.js"; export * from "./node/files.js"; export * from "./node/sign.js"; export * from "./node/validate.js"; -export * from "./schemas/0.3.js"; +export * from "./schemas/index.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; export * from "./types.js"; diff --git a/src/node.ts b/src/node.ts index 10aa2b5..193df7b 100644 --- a/src/node.ts +++ b/src/node.ts @@ -4,7 +4,7 @@ export * from "./node/sign.js"; export * from "./node/validate.js"; // Include all shared exports -export * from "./schemas/0.3.js"; +export * from "./schemas/index.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; export * from "./types.js"; From 07b77432a6e9099dfcbce9c215bb1d4566ac287d Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 16:02:09 -0800 Subject: [PATCH 20/25] Fix lint errors: sort imports and rename unused parameter - Reorganize imports in types.ts to satisfy simple-import-sort - Rename unused localization parameter to _localization in init.ts --- src/cli/init.ts | 2 +- src/types.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index be8eaa5..a7fe811 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -874,7 +874,7 @@ export function buildManifest( license: string; repository?: { type: string; url: string }; }, - localization?: { + _localization?: { resources: string; default_locale: string; }, diff --git a/src/types.ts b/src/types.ts index 63e5e38..c949a0d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,5 @@ import type * as z from "zod"; -import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; -import type { VERSIONED_MANIFEST_SCHEMAS } from "./schemas/index.js"; -import type { DEFAULT_MANIFEST_VERSION } from "./shared/constants.js"; // Import schema types from the version matching DEFAULT_MANIFEST_VERSION import type { McpbManifestAuthorSchema, @@ -18,6 +15,9 @@ import type { McpbUserConfigValuesSchema, McpServerConfigSchema, } from "./schemas/0.2.js"; +import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; +import type { VERSIONED_MANIFEST_SCHEMAS } from "./schemas/index.js"; +import type { DEFAULT_MANIFEST_VERSION } from "./shared/constants.js"; export type McpServerConfig = z.infer; From e59797f9ce86fa61a7e1507cd6779fcd4857ceac Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 16:04:56 -0800 Subject: [PATCH 21/25] chore: major version bump --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4e7f01b..6a81a79 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@anthropic-ai/mcpb", "description": "Tools for building MCP Bundles", - "version": "1.3.0", + "version": "2.0.0", "type": "module", "main": "dist/index.js", "module": "dist/index.js", @@ -99,4 +99,4 @@ "@babel/parser": "7.27.3" }, "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f" -} +} \ No newline at end of file From 08cb52bc86405d1c31b6933d80d8464ba5622515 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 16:07:24 -0800 Subject: [PATCH 22/25] remove localization param --- src/cli/init.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index a7fe811..f14b5d0 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -874,10 +874,10 @@ export function buildManifest( license: string; repository?: { type: string; url: string }; }, - _localization?: { - resources: string; - default_locale: string; - }, + // localization?: { + // resources: string; + // default_locale: string; + // }, ): McpbManifestDefault { const { name, displayName, version, description, authorName } = basicInfo; const { authorEmail, authorUrl } = authorInfo; From e4f1236bf268a8c2b2661880f64734d6f2b7e7f2 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 16:26:38 -0800 Subject: [PATCH 23/25] Fix TypeScript error: remove localization argument from buildManifest call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The buildManifest function signature has the localization parameter commented out (expecting 13 params), but the function call was still passing it as the 14th argument, causing a type error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/init.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index f14b5d0..3d2af9f 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -1026,7 +1026,6 @@ export async function initExtension( compatibility, userConfig, optionalFields, - localization, ); // Write manifest From 5f87ea58d68f1fb82b330a984ce318413a4418e0 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Mon, 3 Nov 2025 16:37:27 -0800 Subject: [PATCH 24/25] Comment out localization parameter in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The localization parameter is commented out in the buildManifest function signature, so it should also be commented out in the test calls. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/init.ts | 6 +++--- test/init.test.ts | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index 3d2af9f..f6a99a6 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -991,9 +991,9 @@ export async function initExtension( const visualAssets = nonInteractive ? { icon: "", icons: [], screenshots: [] } : await promptVisualAssets(); - const localization = nonInteractive - ? undefined - : await promptLocalization(); + // const localization = nonInteractive + // ? undefined + // : await promptLocalization(); const serverConfig = nonInteractive ? getDefaultServerConfig(packageData) : await promptServerConfig(packageData); diff --git a/test/init.test.ts b/test/init.test.ts index def2e9c..7acd57a 100644 --- a/test/init.test.ts +++ b/test/init.test.ts @@ -216,7 +216,7 @@ describe("init functions", () => { keywords: "", license: "", }, - undefined, + // undefined, // localization ); expect(manifest).toEqual({ @@ -315,10 +315,10 @@ describe("init functions", () => { license: "MIT", repository: { type: "git", url: "https://github.com/user/repo" }, }, - { - resources: "resources/${locale}.json", - default_locale: "en-US", - }, + // { // localization + // resources: "resources/${locale}.json", + // default_locale: "en-US", + // }, ); expect(manifest).toEqual({ From 5f6b15bc81beff615ac16d125110de7699e61b46 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 4 Nov 2025 10:33:16 -0800 Subject: [PATCH 25/25] remove da bad tings --- .vscode/settings.json | 3 +- scripts/build-mcpb-schema.js | 6 ++-- src/browser.ts | 1 - src/cli.ts | 1 - src/cli/init.ts | 7 ++-- src/index.ts | 1 - src/node.ts | 1 - src/node/sign.ts | 5 +-- src/schemas/0.1.ts | 14 -------- src/schemas/0.2.ts | 14 -------- src/schemas/0.3.ts | 14 -------- src/schemas_loose/0.1.ts | 14 -------- src/schemas_loose/0.2.ts | 14 -------- src/schemas_loose/0.3.ts | 14 -------- src/shared/common.ts | 15 +++++++++ src/shared/config.ts | 23 +++++++------ src/types.ts | 65 ------------------------------------ test/config.test.ts | 32 +++++++++--------- 18 files changed, 55 insertions(+), 189 deletions(-) create mode 100644 src/shared/common.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 14ac857..73dc7c2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,5 +6,6 @@ "eslint.validate": ["typescript"], "[typescript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" - } + }, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/scripts/build-mcpb-schema.js b/scripts/build-mcpb-schema.js index dce003b..6d884e1 100644 --- a/scripts/build-mcpb-schema.js +++ b/scripts/build-mcpb-schema.js @@ -1,9 +1,7 @@ import { McpbManifestSchema as McpbManifestSchema_v0_1 } from "../dist/schemas/0.1.js"; import { McpbManifestSchema as McpbManifestSchema_v0_2 } from "../dist/schemas/0.2.js"; -import { - McpbManifestSchema as McpbManifestSchema_v0_3, - McpbSignatureInfoSchema, -} from "../dist/schemas/0.3.js"; +import { McpbManifestSchema as McpbManifestSchema_v0_3 } from "../dist/schemas/0.3.js"; +import { McpbSignatureInfoSchema } from "../dist/shared/common.js"; import { zodToJsonSchema } from "zod-to-json-schema"; import fs from "node:fs/promises"; import path from "node:path"; diff --git a/src/browser.ts b/src/browser.ts index 037b024..b8d3fa9 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -2,4 +2,3 @@ export * from "./schemas/index.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; -export * from "./types.js"; diff --git a/src/cli.ts b/src/cli.ts index a11144a..c5266d4 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -6,7 +6,6 @@ export * from "./cli/pack.js"; export * from "./schemas/index.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; -export * from "./types.js"; // Include node exports since CLI needs them export * from "./node/files.js"; diff --git a/src/cli/init.ts b/src/cli/init.ts index f6a99a6..9e62777 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -1,9 +1,12 @@ import { confirm, input, select } from "@inquirer/prompts"; import { existsSync, readFileSync, writeFileSync } from "fs"; import { basename, join, resolve } from "path"; +import type { z } from "zod"; +// Import the schema for DEFAULT_MANIFEST_VERSION +// TODO: Allow dynamic manifest version choice +import type { McpbManifestSchema } from "../schemas/0.2.js"; import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js"; -import type { McpbManifestDefault } from "../types.js"; interface PackageJson { name?: string; @@ -878,7 +881,7 @@ export function buildManifest( // resources: string; // default_locale: string; // }, -): McpbManifestDefault { +): z.infer { const { name, displayName, version, description, authorName } = basicInfo; const { authorEmail, authorUrl } = authorInfo; const { serverType, entryPoint, mcp_config } = serverConfig; diff --git a/src/index.ts b/src/index.ts index 1aad967..58387f8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,4 +8,3 @@ export * from "./node/validate.js"; export * from "./schemas/index.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; -export * from "./types.js"; diff --git a/src/node.ts b/src/node.ts index 193df7b..f7f48a0 100644 --- a/src/node.ts +++ b/src/node.ts @@ -7,4 +7,3 @@ export * from "./node/validate.js"; export * from "./schemas/index.js"; export * from "./shared/config.js"; export * from "./shared/constants.js"; -export * from "./types.js"; diff --git a/src/node/sign.ts b/src/node/sign.ts index bb83389..e0ed5ce 100644 --- a/src/node/sign.ts +++ b/src/node/sign.ts @@ -5,8 +5,9 @@ import forge from "node-forge"; import { tmpdir } from "os"; import { join } from "path"; import { promisify } from "util"; +import type { z } from "zod"; -import type { McpbSignatureInfo } from "../types.js"; +import type { McpbSignatureInfoSchema } from "../shared/common.js"; // Signature block markers const SIGNATURE_HEADER = "MCPB_SIG_V1"; @@ -101,7 +102,7 @@ export function signMcpbFile( */ export async function verifyMcpbFile( mcpbPath: string, -): Promise { +): Promise> { try { const fileContent = readFileSync(mcpbPath); diff --git a/src/schemas/0.1.ts b/src/schemas/0.1.ts index 4d77ccc..e41d69c 100644 --- a/src/schemas/0.1.ts +++ b/src/schemas/0.1.ts @@ -71,11 +71,6 @@ export const McpbUserConfigurationOptionSchema = z.strictObject({ max: z.number().optional(), }); -export const McpbUserConfigValuesSchema = z.record( - z.string(), - z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]), -); - export const McpbManifestSchema = z .strictObject({ $schema: z.string().optional(), @@ -113,12 +108,3 @@ export const McpbManifestSchema = z message: "Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", }); - -export const McpbSignatureInfoSchema = z.strictObject({ - status: z.enum(["signed", "unsigned", "self-signed"]), - publisher: z.string().optional(), - issuer: z.string().optional(), - valid_from: z.string().optional(), - valid_to: z.string().optional(), - fingerprint: z.string().optional(), -}); diff --git a/src/schemas/0.2.ts b/src/schemas/0.2.ts index f5d4d03..bb1de16 100644 --- a/src/schemas/0.2.ts +++ b/src/schemas/0.2.ts @@ -71,11 +71,6 @@ export const McpbUserConfigurationOptionSchema = z.strictObject({ max: z.number().optional(), }); -export const McpbUserConfigValuesSchema = z.record( - z.string(), - z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]), -); - export const McpbManifestSchema = z .strictObject({ $schema: z.string().optional(), @@ -113,12 +108,3 @@ export const McpbManifestSchema = z message: "Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", }); - -export const McpbSignatureInfoSchema = z.strictObject({ - status: z.enum(["signed", "unsigned", "self-signed"]), - publisher: z.string().optional(), - issuer: z.string().optional(), - valid_from: z.string().optional(), - valid_to: z.string().optional(), - fingerprint: z.string().optional(), -}); diff --git a/src/schemas/0.3.ts b/src/schemas/0.3.ts index 2bdc946..2ca0206 100644 --- a/src/schemas/0.3.ts +++ b/src/schemas/0.3.ts @@ -76,11 +76,6 @@ export const McpbUserConfigurationOptionSchema = z.strictObject({ max: z.number().optional(), }); -export const McpbUserConfigValuesSchema = z.record( - z.string(), - z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]), -); - export const McpbManifestLocalizationSchema = z.strictObject({ resources: z .string() @@ -147,12 +142,3 @@ export const McpbManifestSchema = z message: "Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", }); - -export const McpbSignatureInfoSchema = z.strictObject({ - status: z.enum(["signed", "unsigned", "self-signed"]), - publisher: z.string().optional(), - issuer: z.string().optional(), - valid_from: z.string().optional(), - valid_to: z.string().optional(), - fingerprint: z.string().optional(), -}); diff --git a/src/schemas_loose/0.1.ts b/src/schemas_loose/0.1.ts index 2ab5e56..406d6c1 100644 --- a/src/schemas_loose/0.1.ts +++ b/src/schemas_loose/0.1.ts @@ -73,11 +73,6 @@ export const McpbUserConfigurationOptionSchema = z.object({ max: z.number().optional(), }); -export const McpbUserConfigValuesSchema = z.record( - z.string(), - z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]), -); - export const McpbManifestSchema = z .object({ $schema: z.string().optional(), @@ -115,12 +110,3 @@ export const McpbManifestSchema = z message: "Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", }); - -export const McpbSignatureInfoSchema = z.object({ - status: z.enum(["signed", "unsigned", "self-signed"]), - publisher: z.string().optional(), - issuer: z.string().optional(), - valid_from: z.string().optional(), - valid_to: z.string().optional(), - fingerprint: z.string().optional(), -}); diff --git a/src/schemas_loose/0.2.ts b/src/schemas_loose/0.2.ts index 7cdbc1a..bc177d2 100644 --- a/src/schemas_loose/0.2.ts +++ b/src/schemas_loose/0.2.ts @@ -73,11 +73,6 @@ export const McpbUserConfigurationOptionSchema = z.object({ max: z.number().optional(), }); -export const McpbUserConfigValuesSchema = z.record( - z.string(), - z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]), -); - export const McpbManifestSchema = z .object({ $schema: z.string().optional(), @@ -116,12 +111,3 @@ export const McpbManifestSchema = z message: "Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", }); - -export const McpbSignatureInfoSchema = z.object({ - status: z.enum(["signed", "unsigned", "self-signed"]), - publisher: z.string().optional(), - issuer: z.string().optional(), - valid_from: z.string().optional(), - valid_to: z.string().optional(), - fingerprint: z.string().optional(), -}); diff --git a/src/schemas_loose/0.3.ts b/src/schemas_loose/0.3.ts index 87ac125..a96894b 100644 --- a/src/schemas_loose/0.3.ts +++ b/src/schemas_loose/0.3.ts @@ -77,11 +77,6 @@ export const McpbUserConfigurationOptionSchema = z.object({ max: z.number().optional(), }); -export const McpbUserConfigValuesSchema = z.record( - z.string(), - z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]), -); - export const McpbManifestLocalizationSchema = z .object({ resources: z @@ -153,12 +148,3 @@ export const McpbManifestSchema = z message: "Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", }); - -export const McpbSignatureInfoSchema = z.object({ - status: z.enum(["signed", "unsigned", "self-signed"]), - publisher: z.string().optional(), - issuer: z.string().optional(), - valid_from: z.string().optional(), - valid_to: z.string().optional(), - fingerprint: z.string().optional(), -}); diff --git a/src/shared/common.ts b/src/shared/common.ts new file mode 100644 index 0000000..9449ee7 --- /dev/null +++ b/src/shared/common.ts @@ -0,0 +1,15 @@ +import { z } from "zod"; + +export const McpbUserConfigValuesSchema = z.record( + z.string(), + z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]), +); + +export const McpbSignatureInfoSchema = z.strictObject({ + status: z.enum(["signed", "unsigned", "self-signed"]), + publisher: z.string().optional(), + issuer: z.string().optional(), + valid_from: z.string().optional(), + valid_to: z.string().optional(), + fingerprint: z.string().optional(), +}); diff --git a/src/shared/config.ts b/src/shared/config.ts index 9ce016c..b4638bc 100644 --- a/src/shared/config.ts +++ b/src/shared/config.ts @@ -1,9 +1,7 @@ -import type { - Logger, - McpbManifestAny, - McpbUserConfigValues, - McpServerConfig, -} from "../types.js"; +import type { z } from "zod"; + +import type { Logger, McpbManifestAny } from "../types.js"; +import type { McpbUserConfigValuesSchema } from "./common.js"; /** * This file contains utility functions for handling MCPB configuration, @@ -88,14 +86,14 @@ interface GetMcpConfigForManifestOptions { manifest: McpbManifestAny; extensionPath: string; systemDirs: Record; - userConfig: McpbUserConfigValues; + userConfig: z.infer; pathSeparator: string; logger?: Logger; } export async function getMcpConfigForManifest( options: GetMcpConfigForManifestOptions, -): Promise { +): Promise { const { manifest, extensionPath, @@ -109,7 +107,7 @@ export async function getMcpConfigForManifest( return undefined; } - let result: McpServerConfig = { + let result: McpbManifestAny["server"]["mcp_config"] = { ...baseConfig, }; @@ -173,14 +171,17 @@ export async function getMcpConfigForManifest( } // Replace all variables in the config - result = replaceVariables(result, variables) as McpServerConfig; + result = replaceVariables( + result, + variables, + ) as McpbManifestAny["server"]["mcp_config"]; return result; } interface HasRequiredConfigMissingOptions { manifest: McpbManifestAny; - userConfig?: McpbUserConfigValues; + userConfig?: z.infer; } function isInvalidSingleValue(value: unknown): boolean { diff --git a/src/types.ts b/src/types.ts index c949a0d..655bffa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,77 +1,12 @@ import type * as z from "zod"; -// Import schema types from the version matching DEFAULT_MANIFEST_VERSION -import type { - McpbManifestAuthorSchema, - McpbManifestCompatibilitySchema, - McpbManifestMcpConfigSchema, - McpbManifestPlatformOverrideSchema, - McpbManifestPromptSchema, - McpbManifestRepositorySchema, - McpbManifestServerSchema, - McpbManifestToolSchema, - McpbSignatureInfoSchema, - McpbUserConfigurationOptionSchema, - McpbUserConfigValuesSchema, - McpServerConfigSchema, -} from "./schemas/0.2.js"; import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js"; -import type { VERSIONED_MANIFEST_SCHEMAS } from "./schemas/index.js"; -import type { DEFAULT_MANIFEST_VERSION } from "./shared/constants.js"; - -export type McpServerConfig = z.infer; - -export type McpbManifestAuthor = z.infer; - -export type McpbManifestRepository = z.infer< - typeof McpbManifestRepositorySchema ->; - -export type McpbManifestPlatformOverride = z.infer< - typeof McpbManifestPlatformOverrideSchema ->; - -export type McpbManifestMcpConfig = z.infer; - -export type McpbManifestServer = z.infer; - -export type McpbManifestCompatibility = z.infer< - typeof McpbManifestCompatibilitySchema ->; - -export type McpbManifestTool = z.infer; - -export type McpbManifestPrompt = z.infer; - -export type McpbUserConfigurationOption = z.infer< - typeof McpbUserConfigurationOptionSchema ->; - -export type McpbUserConfigValues = z.infer; /** * McpbManifest type representing the union of all manifest versions */ export type McpbManifestAny = z.infer; -/** - * McpbManifest type for the DEFAULT_MANIFEST_VERSION - * Use this for creating new manifests with the default version. - */ -export type McpbManifestDefault = z.infer< - (typeof VERSIONED_MANIFEST_SCHEMAS)[typeof DEFAULT_MANIFEST_VERSION] ->; - -/** - * @deprecated Use McpbManifestAny instead to support all manifest versions, or McpbManifestDefault for the default version. - */ -export type McpbManifest = McpbManifestDefault; - -/** - * Information about a MCPB package signature - */ -export type McpbSignatureInfo = z.infer; - export interface Logger { log: (...args: unknown[]) => void; error: (...args: unknown[]) => void; diff --git a/test/config.test.ts b/test/config.test.ts index 062c66e..1c34faf 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -3,7 +3,7 @@ import { hasRequiredConfigMissing, replaceVariables, } from "../src/shared/config"; -import type { Logger, McpbManifest } from "../src/types"; +import type { Logger, McpbManifestAny } from "../src/types"; describe("replaceVariables", () => { it("should replace variables in strings", () => { @@ -89,7 +89,7 @@ describe("getMcpConfigForManifest", () => { data: "/data", }; - const baseManifest: McpbManifest = { + const baseManifest: McpbManifestAny = { manifest_version: "0.2", name: "test-extension", version: "1.0.0", @@ -114,7 +114,7 @@ describe("getMcpConfigForManifest", () => { const manifest = { ...baseManifest, server: undefined, - } as unknown as McpbManifest; + } as unknown as McpbManifestAny; const result = await getMcpConfigForManifest({ manifest, @@ -129,7 +129,7 @@ describe("getMcpConfigForManifest", () => { }); it("should return undefined when required config is missing", async () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { apiKey: { @@ -171,7 +171,7 @@ describe("getMcpConfigForManifest", () => { }); it("should apply platform overrides", async () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, server: { type: "node", @@ -203,7 +203,7 @@ describe("getMcpConfigForManifest", () => { }); it("should handle user config variable replacement with defaults", async () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { port: { @@ -236,7 +236,7 @@ describe("getMcpConfigForManifest", () => { }); it("should handle user config variable replacement with user values", async () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { paths: { @@ -270,7 +270,7 @@ describe("getMcpConfigForManifest", () => { }); it("should convert boolean user config values to strings", async () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { verbose: { @@ -304,7 +304,7 @@ describe("getMcpConfigForManifest", () => { }); describe("hasRequiredConfigMissing", () => { - const baseManifest: McpbManifest = { + const baseManifest: McpbManifestAny = { manifest_version: "0.2", name: "test-extension", version: "1.0.0", @@ -329,7 +329,7 @@ describe("hasRequiredConfigMissing", () => { }); it("should return false when no config fields are required", () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { port: { @@ -349,7 +349,7 @@ describe("hasRequiredConfigMissing", () => { }); it("should return false when required config is provided", () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { apiKey: { @@ -369,7 +369,7 @@ describe("hasRequiredConfigMissing", () => { }); it("should return true when required config is undefined", () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { apiKey: { @@ -389,7 +389,7 @@ describe("hasRequiredConfigMissing", () => { }); it("should return true when required config is empty string", () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { apiKey: { @@ -409,7 +409,7 @@ describe("hasRequiredConfigMissing", () => { }); it("should return true when required config is array with invalid values", () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { paths: { @@ -430,7 +430,7 @@ describe("hasRequiredConfigMissing", () => { }); it("should return true when required config is empty array", () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { paths: { @@ -459,7 +459,7 @@ describe("hasRequiredConfigMissing", () => { }); it("should handle multiple required config fields", () => { - const manifest: McpbManifest = { + const manifest: McpbManifestAny = { ...baseManifest, user_config: { apiKey: {