diff --git a/schemas/mcpb-manifest-v0.4.schema.json b/schemas/mcpb-manifest-v0.4.schema.json index 5917415..a27a457 100644 --- a/schemas/mcpb-manifest-v0.4.schema.json +++ b/schemas/mcpb-manifest-v0.4.schema.json @@ -129,69 +129,130 @@ "additionalProperties": false }, "server": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "python", - "node", - "binary", - "uv" - ] - }, - "entry_point": { - "type": "string" - }, - "mcp_config": { + "anyOf": [ + { "type": "object", "properties": { - "command": { + "entry_point": { "type": "string" }, - "args": { - "type": "array", - "items": { - "type": "string" - } - }, - "env": { + "mcp_config": { "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "platform_overrides": { - "type": "object", - "additionalProperties": { - "type": "object", - "properties": { - "command": { - "$ref": "#/properties/server/properties/mcp_config/properties/command" - }, - "args": { - "$ref": "#/properties/server/properties/mcp_config/properties/args" - }, - "env": { - "$ref": "#/properties/server/properties/mcp_config/properties/env" + "properties": { + "command": { + "type": "string" + }, + "args": { + "type": "array", + "items": { + "type": "string" } }, - "additionalProperties": false - } + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "platform_overrides": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "command": { + "$ref": "#/properties/server/anyOf/0/properties/mcp_config/properties/command" + }, + "args": { + "$ref": "#/properties/server/anyOf/0/properties/mcp_config/properties/args" + }, + "env": { + "$ref": "#/properties/server/anyOf/0/properties/mcp_config/properties/env" + } + }, + "additionalProperties": false + } + } + }, + "required": [ + "command" + ], + "additionalProperties": false + }, + "type": { + "type": "string", + "const": "python" + } + }, + "required": [ + "entry_point", + "mcp_config", + "type" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "entry_point": { + "$ref": "#/properties/server/anyOf/0/properties/entry_point" + }, + "mcp_config": { + "$ref": "#/properties/server/anyOf/0/properties/mcp_config" + }, + "type": { + "type": "string", + "const": "node" } }, "required": [ - "command" + "entry_point", + "mcp_config", + "type" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "entry_point": { + "$ref": "#/properties/server/anyOf/0/properties/entry_point" + }, + "mcp_config": { + "$ref": "#/properties/server/anyOf/0/properties/mcp_config" + }, + "type": { + "type": "string", + "const": "binary" + } + }, + "required": [ + "entry_point", + "mcp_config", + "type" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "entry_point": { + "$ref": "#/properties/server/anyOf/0/properties/entry_point" + }, + "mcp_config": { + "$ref": "#/properties/server/anyOf/0/properties/mcp_config" + }, + "type": { + "type": "string", + "const": "uv" + } + }, + "required": [ + "entry_point", + "type" ], "additionalProperties": false } - }, - "required": [ - "type", - "entry_point", - "mcp_config" - ], - "additionalProperties": false + ] }, "tools": { "type": "array", diff --git a/src/schemas/0.4.ts b/src/schemas/0.4.ts index e044b91..fe56842 100644 --- a/src/schemas/0.4.ts +++ b/src/schemas/0.4.ts @@ -34,12 +34,21 @@ export const McpbManifestMcpConfigSchema = McpServerConfigSchema.extend({ .optional(), }); -export const McpbManifestServerSchema = z.strictObject({ - type: z.enum(["python", "node", "binary", "uv"]), +const BaseServerSchema = z.strictObject({ entry_point: z.string(), mcp_config: McpbManifestMcpConfigSchema, }); +export const McpbManifestServerSchema = z.discriminatedUnion("type", [ + BaseServerSchema.extend({ type: z.literal("python") }), + BaseServerSchema.extend({ type: z.literal("node") }), + BaseServerSchema.extend({ type: z.literal("binary") }), + BaseServerSchema.extend({ + type: z.literal("uv"), + mcp_config: McpbManifestMcpConfigSchema.optional(), + }), +]); + export const McpbManifestCompatibilitySchema = z.strictObject({ claude_desktop: z.string().optional(), platforms: z.array(z.enum(["darwin", "win32", "linux"])).optional(),