Skip to content

Commit fb0e98f

Browse files
authored
Merge branch 'modelcontextprotocol:main' into dotnet
2 parents b69dcab + 27083dc commit fb0e98f

5 files changed

Lines changed: 50 additions & 24 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
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": "2.1.1",
4+
"version": "2.1.2",
55
"type": "module",
66
"main": "dist/index.js",
77
"module": "dist/index.js",

schemas/mcpb-manifest-v0.4.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@
188188
},
189189
"required": [
190190
"type",
191-
"entry_point"
191+
"entry_point",
192+
"mcp_config"
192193
],
193194
"additionalProperties": false
194195
},

src/cli/cli.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,32 @@ program
5151
.command("init [directory]")
5252
.description("Create a new MCPB extension manifest")
5353
.option("-y, --yes", "Accept all defaults (non-interactive mode)")
54-
.action((directory?: string, options?: { yes?: boolean }) => {
55-
void (async () => {
56-
try {
57-
const success = await initExtension(directory, options?.yes);
58-
process.exit(success ? 0 : 1);
59-
} catch (error) {
60-
console.error(
61-
`ERROR: ${error instanceof Error ? error.message : "Unknown error"}`,
62-
);
63-
process.exit(1);
64-
}
65-
})();
66-
});
54+
.option(
55+
"--manifest-version <version>",
56+
"Manifest version to use in the generated manifest",
57+
)
58+
.action(
59+
(
60+
directory?: string,
61+
options?: { yes?: boolean; manifestVersion?: string },
62+
) => {
63+
void (async () => {
64+
try {
65+
const success = await initExtension(
66+
directory,
67+
options?.yes,
68+
options?.manifestVersion,
69+
);
70+
process.exit(success ? 0 : 1);
71+
} catch (error) {
72+
console.error(
73+
`ERROR: ${error instanceof Error ? error.message : "Unknown error"}`,
74+
);
75+
process.exit(1);
76+
}
77+
})();
78+
},
79+
);
6780

6881
// Validate command
6982
program

src/cli/init.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +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";
54

6-
// Import the schema for DEFAULT_MANIFEST_VERSION
7-
// TODO: Allow dynamic manifest version choice
8-
import type { McpbManifestSchema } from "../schemas/0.2.js";
9-
import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js";
5+
import {
6+
DEFAULT_MANIFEST_VERSION,
7+
MANIFEST_SCHEMAS,
8+
} from "../shared/constants.js";
9+
import type { McpbManifestAny } from "../types.js";
1010

1111
interface PackageJson {
1212
name?: string;
@@ -877,18 +877,19 @@ export function buildManifest(
877877
license: string;
878878
repository?: { type: string; url: string };
879879
},
880+
manifestVersion: keyof typeof MANIFEST_SCHEMAS = DEFAULT_MANIFEST_VERSION,
880881
// localization?: {
881882
// resources: string;
882883
// default_locale: string;
883884
// },
884-
): z.infer<typeof McpbManifestSchema> {
885+
): McpbManifestAny {
885886
const { name, displayName, version, description, authorName } = basicInfo;
886887
const { authorEmail, authorUrl } = authorInfo;
887888
const { serverType, entryPoint, mcp_config } = serverConfig;
888889
const { keywords, license, repository } = optionalFields;
889890

890891
return {
891-
manifest_version: DEFAULT_MANIFEST_VERSION,
892+
manifest_version: manifestVersion,
892893
name,
893894
...(displayName && displayName !== name
894895
? { display_name: displayName }
@@ -945,10 +946,21 @@ export function printNextSteps() {
945946
export async function initExtension(
946947
targetPath: string = process.cwd(),
947948
nonInteractive = false,
949+
manifestVersion?: string,
948950
): Promise<boolean> {
949951
const resolvedPath = resolve(targetPath);
950952
const manifestPath = join(resolvedPath, "manifest.json");
951953

954+
// Validate manifest version if provided
955+
if (manifestVersion && !(manifestVersion in MANIFEST_SCHEMAS)) {
956+
console.error(
957+
`ERROR: Invalid manifest version "${manifestVersion}". Supported versions: ${Object.keys(MANIFEST_SCHEMAS).join(", ")}`,
958+
);
959+
return false;
960+
}
961+
const effectiveManifestVersion = (manifestVersion ||
962+
DEFAULT_MANIFEST_VERSION) as keyof typeof MANIFEST_SCHEMAS;
963+
952964
if (existsSync(manifestPath)) {
953965
if (nonInteractive) {
954966
console.log(
@@ -1029,6 +1041,7 @@ export async function initExtension(
10291041
compatibility,
10301042
userConfig,
10311043
optionalFields,
1044+
effectiveManifestVersion,
10321045
);
10331046

10341047
// Write manifest

src/schemas/0.4.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ export const McpbManifestMcpConfigSchema = McpServerConfigSchema.extend({
3737
export const McpbManifestServerSchema = z.strictObject({
3838
type: z.enum(["python", "node", "binary", "uv"]),
3939
entry_point: z.string(),
40-
// mcp_config is optional for UV type (UV handles execution)
41-
mcp_config: McpbManifestMcpConfigSchema.optional(),
40+
mcp_config: McpbManifestMcpConfigSchema,
4241
});
4342

4443
export const McpbManifestCompatibilitySchema = z.strictObject({

0 commit comments

Comments
 (0)