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"],
|
"eslint.validate": ["typescript"],
|
||||||
"[typescript]": {
|
"[typescript]": {
|
||||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||||
}
|
},
|
||||||
|
"typescript.tsdk": "node_modules/typescript/lib"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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";
|
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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";
|
|
||||||
|
|
|
||||||
|
|
@ -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";
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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(),
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -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(),
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -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(),
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from "./0.3.js";
|
|
||||||
|
|
@ -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(),
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -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(),
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -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(),
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -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";
|
|
||||||
|
|
|
||||||
|
|
@ -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