Merge pull request #148 from anthropics/feat/browser-export-versioned-schemas

feat: export versioned zod schemas in mcpb/browser, remove vLatest artifacts
This commit is contained in:
joan-anthropic 2025-11-04 10:39:43 -08:00 • committed by GitHub
commit 5079fcfe30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 104 additions and 247 deletions

View file

@ -6,5 +6,6 @@
"eslint.validate": ["typescript"], "eslint.validate": ["typescript"],
"[typescript]": { "[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint" "editor.defaultFormatter": "dbaeumer.vscode-eslint"
} },
"typescript.tsdk": "node_modules/typescript/lib"
} }

View file

@ -1,7 +1,7 @@
{ {
"name": "@anthropic-ai/mcpb", "name": "@anthropic-ai/mcpb",
"description": "Tools for building MCP Bundles", "description": "Tools for building MCP Bundles",
"version": "1.2.0", "version": "2.0.0",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/index.js", "module": "dist/index.js",
@ -99,4 +99,4 @@
"@babel/parser": "7.27.3" "@babel/parser": "7.27.3"
}, },
"packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f" "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
} }

View file

@ -1,10 +1,7 @@
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_1 } from "../dist/schemas/0.1.js";
import { McpbManifestSchema as McpbManifestSchema_v0_2 } from "../dist/schemas/0.2.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 } from "../dist/schemas/0.3.js";
import { McpbSignatureInfoSchema } from "../dist/shared/common.js";
import { zodToJsonSchema } from "zod-to-json-schema"; import { zodToJsonSchema } from "zod-to-json-schema";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import path from "node:path"; import path from "node:path";
@ -17,7 +14,6 @@ const versionedManifestSchemas = {
"mcpb-manifest-v0.1": McpbManifestSchema_v0_1, "mcpb-manifest-v0.1": McpbManifestSchema_v0_1,
"mcpb-manifest-v0.2": McpbManifestSchema_v0_2, "mcpb-manifest-v0.2": McpbManifestSchema_v0_2,
"mcpb-manifest-v0.3": McpbManifestSchema_v0_3, "mcpb-manifest-v0.3": McpbManifestSchema_v0_3,
"mcpb-manifest-latest": McpbManifestSchemaLatest,
}; };
// Other schemas // Other schemas

View file

@ -1,5 +1,4 @@
// Browser-compatible exports // Browser-compatible exports
export * from "./schemas/latest.js"; export * from "./schemas/index.js";
export * from "./shared/config.js"; export * from "./shared/config.js";
export * from "./shared/constants.js"; export * from "./shared/constants.js";
export * from "./types.js";

View file

@ -3,10 +3,9 @@ export * from "./cli/init.js";
export * from "./cli/pack.js"; export * from "./cli/pack.js";
// Include all shared exports // Include all shared exports
export * from "./schemas/latest.js"; export * from "./schemas/index.js";
export * from "./shared/config.js"; export * from "./shared/config.js";
export * from "./shared/constants.js"; export * from "./shared/constants.js";
export * from "./types.js";
// Include node exports since CLI needs them // Include node exports since CLI needs them
export * from "./node/files.js"; export * from "./node/files.js";

View file

@ -1,9 +1,12 @@
import { confirm, input, select } from "@inquirer/prompts"; import { confirm, input, select } from "@inquirer/prompts";
import { existsSync, readFileSync, writeFileSync } from "fs"; import { existsSync, readFileSync, writeFileSync } from "fs";
import { basename, join, resolve } from "path"; 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 { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js";
import type { McpbManifest } from "../types.js";
interface PackageJson { interface PackageJson {
name?: string; name?: string;
@ -874,11 +877,11 @@ export function buildManifest(
license: string; license: string;
repository?: { type: string; url: string }; repository?: { type: string; url: string };
}, },
localization?: { // localization?: {
resources: string; // resources: string;
default_locale: string; // default_locale: string;
}, // },
): McpbManifest { ): z.infer<typeof McpbManifestSchema> {
const { name, displayName, version, description, authorName } = basicInfo; const { name, displayName, version, description, authorName } = basicInfo;
const { authorEmail, authorUrl } = authorInfo; const { authorEmail, authorUrl } = authorInfo;
const { serverType, entryPoint, mcp_config } = serverConfig; const { serverType, entryPoint, mcp_config } = serverConfig;
@ -906,7 +909,7 @@ export function buildManifest(
...(visualAssets.screenshots.length > 0 ...(visualAssets.screenshots.length > 0
? { screenshots: visualAssets.screenshots } ? { screenshots: visualAssets.screenshots }
: {}), : {}),
...(localization ? { localization } : {}), // ...(localization ? { localization } : {}),
server: { server: {
type: serverType, type: serverType,
entry_point: entryPoint, entry_point: entryPoint,
@ -991,9 +994,9 @@ export async function initExtension(
const visualAssets = nonInteractive const visualAssets = nonInteractive
? { icon: "", icons: [], screenshots: [] } ? { icon: "", icons: [], screenshots: [] }
: await promptVisualAssets(); : await promptVisualAssets();
const localization = nonInteractive // const localization = nonInteractive
? undefined // ? undefined
: await promptLocalization(); // : await promptLocalization();
const serverConfig = nonInteractive const serverConfig = nonInteractive
? getDefaultServerConfig(packageData) ? getDefaultServerConfig(packageData)
: await promptServerConfig(packageData); : await promptServerConfig(packageData);
@ -1026,7 +1029,6 @@ export async function initExtension(
compatibility, compatibility,
userConfig, userConfig,
optionalFields, optionalFields,
localization,
); );
// Write manifest // Write manifest

View file

@ -5,7 +5,6 @@ export * from "./cli/unpack.js";
export * from "./node/files.js"; export * from "./node/files.js";
export * from "./node/sign.js"; export * from "./node/sign.js";
export * from "./node/validate.js"; export * from "./node/validate.js";
export * from "./schemas/latest.js"; export * from "./schemas/index.js";
export * from "./shared/config.js"; export * from "./shared/config.js";
export * from "./shared/constants.js"; export * from "./shared/constants.js";
export * from "./types.js";

View file

@ -4,7 +4,6 @@ export * from "./node/sign.js";
export * from "./node/validate.js"; export * from "./node/validate.js";
// Include all shared exports // Include all shared exports
export * from "./schemas/latest.js"; export * from "./schemas/index.js";
export * from "./shared/config.js"; export * from "./shared/config.js";
export * from "./shared/constants.js"; export * from "./shared/constants.js";
export * from "./types.js";

View file

@ -5,8 +5,9 @@ import forge from "node-forge";
import { tmpdir } from "os"; import { tmpdir } from "os";
import { join } from "path"; import { join } from "path";
import { promisify } from "util"; 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 // Signature block markers
const SIGNATURE_HEADER = "MCPB_SIG_V1"; const SIGNATURE_HEADER = "MCPB_SIG_V1";
@ -101,7 +102,7 @@ export function signMcpbFile(
*/ */
export async function verifyMcpbFile( export async function verifyMcpbFile(
mcpbPath: string, mcpbPath: string,
): Promise<McpbSignatureInfo> { ): Promise<z.infer<typeof McpbSignatureInfoSchema>> {
try { try {
const fileContent = readFileSync(mcpbPath); const fileContent = readFileSync(mcpbPath);

View file

@ -71,11 +71,6 @@ export const McpbUserConfigurationOptionSchema = z.strictObject({
max: z.number().optional(), 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 export const McpbManifestSchema = z
.strictObject({ .strictObject({
$schema: z.string().optional(), $schema: z.string().optional(),
@ -113,12 +108,3 @@ export const McpbManifestSchema = z
message: message:
"Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", "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(),
});

View file

@ -71,11 +71,6 @@ export const McpbUserConfigurationOptionSchema = z.strictObject({
max: z.number().optional(), 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 export const McpbManifestSchema = z
.strictObject({ .strictObject({
$schema: z.string().optional(), $schema: z.string().optional(),
@ -113,12 +108,3 @@ export const McpbManifestSchema = z
message: message:
"Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", "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(),
});

View file

@ -76,11 +76,6 @@ export const McpbUserConfigurationOptionSchema = z.strictObject({
max: z.number().optional(), 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({ export const McpbManifestLocalizationSchema = z.strictObject({
resources: z resources: z
.string() .string()
@ -147,12 +142,3 @@ export const McpbManifestSchema = z
message: message:
"Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", "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(),
});

View file

@ -1,9 +1,17 @@
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_1 from "./0.1.js";
export * as v0_2 from "./0.2.js"; export * as v0_2 from "./0.2.js";
export * as v0_3 from "./0.3.js"; export * as v0_3 from "./0.3.js";
export * as any from "./any.js"; export * as vAny from "./any.js";
export * as latest from "./latest.js";
export { /**
MANIFEST_VERSION as LATEST_MANIFEST_VERSION, * Map of manifest versions to their strict schemas
McpbManifestSchema, */
} from "./latest.js"; export const VERSIONED_MANIFEST_SCHEMAS = {
"0.1": ManifestSchemaV0_1,
"0.2": ManifestSchemaV0_2,
"0.3": ManifestSchemaV0_3,
} as const;

View file

@ -1 +0,0 @@
export * from "./0.3.js";

View file

@ -73,11 +73,6 @@ export const McpbUserConfigurationOptionSchema = z.object({
max: z.number().optional(), 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 export const McpbManifestSchema = z
.object({ .object({
$schema: z.string().optional(), $schema: z.string().optional(),
@ -115,12 +110,3 @@ export const McpbManifestSchema = z
message: message:
"Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", "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(),
});

View file

@ -73,11 +73,6 @@ export const McpbUserConfigurationOptionSchema = z.object({
max: z.number().optional(), 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 export const McpbManifestSchema = z
.object({ .object({
$schema: z.string().optional(), $schema: z.string().optional(),
@ -116,12 +111,3 @@ export const McpbManifestSchema = z
message: message:
"Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", "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(),
});

View file

@ -77,11 +77,6 @@ export const McpbUserConfigurationOptionSchema = z.object({
max: z.number().optional(), 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 export const McpbManifestLocalizationSchema = z
.object({ .object({
resources: z resources: z
@ -153,12 +148,3 @@ export const McpbManifestSchema = z
message: message:
"Either 'dxt_version' (deprecated) or 'manifest_version' must be provided", "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(),
});

View file

@ -1,4 +1,3 @@
export * as v0_1 from "./0.1.js"; export * as v0_1 from "./0.1.js";
export * as v0_2 from "./0.2.js"; export * as v0_2 from "./0.2.js";
export * as v0_3 from "./0.3.js"; export * as v0_3 from "./0.3.js";
export * as latest from "./latest.js";

View file

@ -1 +0,0 @@
export * from "./0.3.js";

15
src/shared/common.ts Normal file
View file

@ -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(),
});

Some files were not shown because too many files have changed in this diff Show more