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:
commit
5079fcfe30
26 changed files with 104 additions and 247 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -6,5 +6,6 @@
|
|||
"eslint.validate": ["typescript"],
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||
}
|
||||
},
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@anthropic-ai/mcpb",
|
||||
"description": "Tools for building MCP Bundles",
|
||||
"version": "1.2.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"
|
||||
}
|
||||
}
|
||||
|
|
@ -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_2 } from "../dist/schemas/0.2.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";
|
||||
|
|
@ -17,7 +14,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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// 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";
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@ export * from "./cli/init.js";
|
|||
export * from "./cli/pack.js";
|
||||
|
||||
// Include all shared 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";
|
||||
|
||||
// Include node exports since CLI needs them
|
||||
export * from "./node/files.js";
|
||||
|
|
|
|||
|
|
@ -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 { McpbManifest } from "../types.js";
|
||||
|
||||
interface PackageJson {
|
||||
name?: string;
|
||||
|
|
@ -874,11 +877,11 @@ export function buildManifest(
|
|||
license: string;
|
||||
repository?: { type: string; url: string };
|
||||
},
|
||||
localization?: {
|
||||
resources: string;
|
||||
default_locale: string;
|
||||
},
|
||||
): McpbManifest {
|
||||
// localization?: {
|
||||
// resources: string;
|
||||
// default_locale: string;
|
||||
// },
|
||||
): z.infer<typeof McpbManifestSchema> {
|
||||
const { name, displayName, version, description, authorName } = basicInfo;
|
||||
const { authorEmail, authorUrl } = authorInfo;
|
||||
const { serverType, entryPoint, mcp_config } = serverConfig;
|
||||
|
|
@ -906,7 +909,7 @@ export function buildManifest(
|
|||
...(visualAssets.screenshots.length > 0
|
||||
? { screenshots: visualAssets.screenshots }
|
||||
: {}),
|
||||
...(localization ? { localization } : {}),
|
||||
// ...(localization ? { localization } : {}),
|
||||
server: {
|
||||
type: serverType,
|
||||
entry_point: entryPoint,
|
||||
|
|
@ -991,9 +994,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);
|
||||
|
|
@ -1026,7 +1029,6 @@ export async function initExtension(
|
|||
compatibility,
|
||||
userConfig,
|
||||
optionalFields,
|
||||
localization,
|
||||
);
|
||||
|
||||
// Write manifest
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ 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/index.js";
|
||||
export * from "./shared/config.js";
|
||||
export * from "./shared/constants.js";
|
||||
export * from "./types.js";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ export * from "./node/sign.js";
|
|||
export * from "./node/validate.js";
|
||||
|
||||
// Include all shared 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";
|
||||
|
|
|
|||
|
|
@ -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<McpbSignatureInfo> {
|
||||
): Promise<z.infer<typeof McpbSignatureInfoSchema>> {
|
||||
try {
|
||||
const fileContent = readFileSync(mcpbPath);
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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_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 {
|
||||
MANIFEST_VERSION as LATEST_MANIFEST_VERSION,
|
||||
McpbManifestSchema,
|
||||
} from "./latest.js";
|
||||
export * as vAny from "./any.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;
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export * from "./0.3.js";
|
||||
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export * from "./0.3.js";
|
||||
15
src/shared/common.ts
Normal file
15
src/shared/common.ts
Normal 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
Loading…
Reference in a new issue