Skip to content

Commit 5079fcf

Browse files
Merge pull request #148 from anthropics/feat/browser-export-versioned-schemas
feat: export versioned zod schemas in mcpb/browser, remove vLatest artifacts
2 parents b75f8a6 + 5f6b15b commit 5079fcf

File tree

26 files changed

+104
-247
lines changed

26 files changed

+104
-247
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"eslint.validate": ["typescript"],
77
"[typescript]": {
88
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
9-
}
9+
},
10+
"typescript.tsdk": "node_modules/typescript/lib"
1011
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@anthropic-ai/mcpb",
33
"description": "Tools for building MCP Bundles",
4-
"version": "1.2.0",
4+
"version": "2.0.0",
55
"type": "module",
66
"main": "dist/index.js",
77
"module": "dist/index.js",
@@ -99,4 +99,4 @@
9999
"@babel/parser": "7.27.3"
100100
},
101101
"packageManager": "[email protected]+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
102-
}
102+
}

scripts/build-mcpb-schema.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import {
2-
McpbManifestSchema as McpbManifestSchemaLatest,
3-
McpbSignatureInfoSchema,
4-
} from "../dist/schemas/latest.js";
51
import { McpbManifestSchema as McpbManifestSchema_v0_1 } from "../dist/schemas/0.1.js";
62
import { McpbManifestSchema as McpbManifestSchema_v0_2 } from "../dist/schemas/0.2.js";
73
import { McpbManifestSchema as McpbManifestSchema_v0_3 } from "../dist/schemas/0.3.js";
4+
import { McpbSignatureInfoSchema } from "../dist/shared/common.js";
85
import { zodToJsonSchema } from "zod-to-json-schema";
96
import fs from "node:fs/promises";
107
import path from "node:path";
@@ -17,7 +14,6 @@ const versionedManifestSchemas = {
1714
"mcpb-manifest-v0.1": McpbManifestSchema_v0_1,
1815
"mcpb-manifest-v0.2": McpbManifestSchema_v0_2,
1916
"mcpb-manifest-v0.3": McpbManifestSchema_v0_3,
20-
"mcpb-manifest-latest": McpbManifestSchemaLatest,
2117
};
2218

2319
// Other schemas

src/browser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Browser-compatible exports
2-
export * from "./schemas/latest.js";
2+
export * from "./schemas/index.js";
33
export * from "./shared/config.js";
44
export * from "./shared/constants.js";
5-
export * from "./types.js";

src/cli.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ export * from "./cli/init.js";
33
export * from "./cli/pack.js";
44

55
// Include all shared exports
6-
export * from "./schemas/latest.js";
6+
export * from "./schemas/index.js";
77
export * from "./shared/config.js";
88
export * from "./shared/constants.js";
9-
export * from "./types.js";
109

1110
// Include node exports since CLI needs them
1211
export * from "./node/files.js";

src/cli/init.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { confirm, input, select } from "@inquirer/prompts";
22
import { existsSync, readFileSync, writeFileSync } from "fs";
33
import { basename, join, resolve } from "path";
4+
import type { z } from "zod";
45

6+
// Import the schema for DEFAULT_MANIFEST_VERSION
7+
// TODO: Allow dynamic manifest version choice
8+
import type { McpbManifestSchema } from "../schemas/0.2.js";
59
import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js";
6-
import type { McpbManifest } from "../types.js";
710

811
interface PackageJson {
912
name?: string;
@@ -874,11 +877,11 @@ export function buildManifest(
874877
license: string;
875878
repository?: { type: string; url: string };
876879
},
877-
localization?: {
878-
resources: string;
879-
default_locale: string;
880-
},
881-
): McpbManifest {
880+
// localization?: {
881+
// resources: string;
882+
// default_locale: string;
883+
// },
884+
): z.infer<typeof McpbManifestSchema> {
882885
const { name, displayName, version, description, authorName } = basicInfo;
883886
const { authorEmail, authorUrl } = authorInfo;
884887
const { serverType, entryPoint, mcp_config } = serverConfig;
@@ -906,7 +909,7 @@ export function buildManifest(
906909
...(visualAssets.screenshots.length > 0
907910
? { screenshots: visualAssets.screenshots }
908911
: {}),
909-
...(localization ? { localization } : {}),
912+
// ...(localization ? { localization } : {}),
910913
server: {
911914
type: serverType,
912915
entry_point: entryPoint,
@@ -991,9 +994,9 @@ export async function initExtension(
991994
const visualAssets = nonInteractive
992995
? { icon: "", icons: [], screenshots: [] }
993996
: await promptVisualAssets();
994-
const localization = nonInteractive
995-
? undefined
996-
: await promptLocalization();
997+
// const localization = nonInteractive
998+
// ? undefined
999+
// : await promptLocalization();
9971000
const serverConfig = nonInteractive
9981001
? getDefaultServerConfig(packageData)
9991002
: await promptServerConfig(packageData);
@@ -1026,7 +1029,6 @@ export async function initExtension(
10261029
compatibility,
10271030
userConfig,
10281031
optionalFields,
1029-
localization,
10301032
);
10311033

10321034
// Write manifest

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export * from "./cli/unpack.js";
55
export * from "./node/files.js";
66
export * from "./node/sign.js";
77
export * from "./node/validate.js";
8-
export * from "./schemas/latest.js";
8+
export * from "./schemas/index.js";
99
export * from "./shared/config.js";
1010
export * from "./shared/constants.js";
11-
export * from "./types.js";

src/node.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export * from "./node/sign.js";
44
export * from "./node/validate.js";
55

66
// Include all shared exports
7-
export * from "./schemas/latest.js";
7+
export * from "./schemas/index.js";
88
export * from "./shared/config.js";
99
export * from "./shared/constants.js";
10-
export * from "./types.js";

src/node/sign.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import forge from "node-forge";
55
import { tmpdir } from "os";
66
import { join } from "path";
77
import { promisify } from "util";
8+
import type { z } from "zod";
89

9-
import type { McpbSignatureInfo } from "../types.js";
10+
import type { McpbSignatureInfoSchema } from "../shared/common.js";
1011

1112
// Signature block markers
1213
const SIGNATURE_HEADER = "MCPB_SIG_V1";
@@ -101,7 +102,7 @@ export function signMcpbFile(
101102
*/
102103
export async function verifyMcpbFile(
103104
mcpbPath: string,
104-
): Promise<McpbSignatureInfo> {
105+
): Promise<z.infer<typeof McpbSignatureInfoSchema>> {
105106
try {
106107
const fileContent = readFileSync(mcpbPath);
107108

src/schemas/0.1.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ export const McpbUserConfigurationOptionSchema = z.strictObject({
7171
max: z.number().optional(),
7272
});
7373

74-
export const McpbUserConfigValuesSchema = z.record(
75-
z.string(),
76-
z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
77-
);
78-
7974
export const McpbManifestSchema = z
8075
.strictObject({
8176
$schema: z.string().optional(),
@@ -113,12 +108,3 @@ export const McpbManifestSchema = z
113108
message:
114109
"Either 'dxt_version' (deprecated) or 'manifest_version' must be provided",
115110
});
116-
117-
export const McpbSignatureInfoSchema = z.strictObject({
118-
status: z.enum(["signed", "unsigned", "self-signed"]),
119-
publisher: z.string().optional(),
120-
issuer: z.string().optional(),
121-
valid_from: z.string().optional(),
122-
valid_to: z.string().optional(),
123-
fingerprint: z.string().optional(),
124-
});

0 commit comments

Comments
 (0)