add WIP 0.3
This commit is contained in:
parent
143aa9a63c
commit
f7efd3a444
3 changed files with 143 additions and 10 deletions
126
src/schemas/0.3.ts
Normal file
126
src/schemas/0.3.ts
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
// WIP: This schema is under development and not yet finalized
|
||||||
|
import * as z from "zod";
|
||||||
|
|
||||||
|
export const MANIFEST_VERSION = "0.3";
|
||||||
|
|
||||||
|
export const McpServerConfigSchema = z.strictObject({
|
||||||
|
command: z.string(),
|
||||||
|
args: z.array(z.string()).optional(),
|
||||||
|
env: z.record(z.string(), z.string()).optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const McpbManifestAuthorSchema = z.strictObject({
|
||||||
|
name: z.string(),
|
||||||
|
email: z.string().email().optional(),
|
||||||
|
url: z.string().url().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const McpbManifestRepositorySchema = z.strictObject({
|
||||||
|
type: z.string(),
|
||||||
|
url: z.string().url(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const McpbManifestPlatformOverrideSchema =
|
||||||
|
McpServerConfigSchema.partial();
|
||||||
|
|
||||||
|
export const McpbManifestMcpConfigSchema = McpServerConfigSchema.extend({
|
||||||
|
platform_overrides: z
|
||||||
|
.record(z.string(), McpbManifestPlatformOverrideSchema)
|
||||||
|
.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const McpbManifestServerSchema = z.strictObject({
|
||||||
|
type: z.enum(["python", "node", "binary"]),
|
||||||
|
entry_point: z.string(),
|
||||||
|
mcp_config: McpbManifestMcpConfigSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const McpbManifestCompatibilitySchema = z.strictObject({
|
||||||
|
claude_desktop: z.string().optional(),
|
||||||
|
platforms: z.array(z.enum(["darwin", "win32", "linux"])).optional(),
|
||||||
|
runtimes: z
|
||||||
|
.strictObject({
|
||||||
|
python: z.string().optional(),
|
||||||
|
node: z.string().optional(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const McpbManifestToolSchema = z.strictObject({
|
||||||
|
name: z.string(),
|
||||||
|
description: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const McpbManifestPromptSchema = z.strictObject({
|
||||||
|
name: z.string(),
|
||||||
|
description: z.string().optional(),
|
||||||
|
arguments: z.array(z.string()).optional(),
|
||||||
|
text: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const McpbUserConfigurationOptionSchema = z.strictObject({
|
||||||
|
type: z.enum(["string", "number", "boolean", "directory", "file"]),
|
||||||
|
title: z.string(),
|
||||||
|
description: z.string(),
|
||||||
|
required: z.boolean().optional(),
|
||||||
|
default: z
|
||||||
|
.union([z.string(), z.number(), z.boolean(), z.array(z.string())])
|
||||||
|
.optional(),
|
||||||
|
multiple: z.boolean().optional(),
|
||||||
|
sensitive: z.boolean().optional(),
|
||||||
|
min: 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
|
||||||
|
.strictObject({
|
||||||
|
$schema: z.string().optional(),
|
||||||
|
dxt_version: z
|
||||||
|
.literal(MANIFEST_VERSION)
|
||||||
|
.optional()
|
||||||
|
.describe("@deprecated Use manifest_version instead"),
|
||||||
|
manifest_version: z.literal(MANIFEST_VERSION).optional(),
|
||||||
|
name: z.string(),
|
||||||
|
display_name: z.string().optional(),
|
||||||
|
version: z.string(),
|
||||||
|
description: z.string(),
|
||||||
|
long_description: z.string().optional(),
|
||||||
|
author: McpbManifestAuthorSchema,
|
||||||
|
repository: McpbManifestRepositorySchema.optional(),
|
||||||
|
homepage: z.string().url().optional(),
|
||||||
|
documentation: z.string().url().optional(),
|
||||||
|
support: z.string().url().optional(),
|
||||||
|
icon: z.string().optional(),
|
||||||
|
screenshots: z.array(z.string()).optional(),
|
||||||
|
server: McpbManifestServerSchema,
|
||||||
|
tools: z.array(McpbManifestToolSchema).optional(),
|
||||||
|
tools_generated: z.boolean().optional(),
|
||||||
|
prompts: z.array(McpbManifestPromptSchema).optional(),
|
||||||
|
prompts_generated: z.boolean().optional(),
|
||||||
|
keywords: z.array(z.string()).optional(),
|
||||||
|
license: z.string().optional(),
|
||||||
|
privacy_policies: z.array(z.string().url()).optional(),
|
||||||
|
compatibility: McpbManifestCompatibilitySchema.optional(),
|
||||||
|
user_config: z
|
||||||
|
.record(z.string(), McpbUserConfigurationOptionSchema)
|
||||||
|
.optional(),
|
||||||
|
_meta: z.record(z.string(), z.record(z.string(), z.any())).optional(),
|
||||||
|
})
|
||||||
|
.refine((data) => !!(data.dxt_version || data.manifest_version), {
|
||||||
|
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,5 +1,6 @@
|
||||||
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 latest from "./latest.js";
|
export * as latest from "./latest.js";
|
||||||
export {
|
export {
|
||||||
MANIFEST_VERSION as LATEST_MANIFEST_VERSION,
|
MANIFEST_VERSION as LATEST_MANIFEST_VERSION,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
import { McpbManifestSchema } from "../src/schemas/index.js";
|
import { McpbManifestSchema, v0_3 } from "../src/schemas/index.js";
|
||||||
|
|
||||||
describe("McpbManifestSchema", () => {
|
describe("McpbManifestSchema", () => {
|
||||||
it("should validate a valid manifest", () => {
|
it("should validate a valid manifest", () => {
|
||||||
|
|
@ -137,9 +137,9 @@ describe("McpbManifestSchema", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.skip("_meta", () => {
|
describe("_meta", () => {
|
||||||
const base = {
|
const base = {
|
||||||
manifest_version: "0.2",
|
manifest_version: "0.3",
|
||||||
name: "client-ext-test",
|
name: "client-ext-test",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
description: "Test manifest",
|
description: "Test manifest",
|
||||||
|
|
@ -155,11 +155,14 @@ describe("McpbManifestSchema", () => {
|
||||||
const manifest = {
|
const manifest = {
|
||||||
...base,
|
...base,
|
||||||
_meta: {
|
_meta: {
|
||||||
"com.microsoft.windows": { package_family_name: "Pkg_123", channel: "stable" },
|
"com.microsoft.windows": {
|
||||||
|
package_family_name: "Pkg_123",
|
||||||
|
channel: "stable",
|
||||||
|
},
|
||||||
"com.apple.darwin": { bundle_id: "com.example.app", notarized: true },
|
"com.apple.darwin": { bundle_id: "com.example.app", notarized: true },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const result = McpbManifestSchema.safeParse(manifest);
|
const result = v0_3.McpbManifestSchema.safeParse(manifest);
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -167,10 +170,13 @@ describe("McpbManifestSchema", () => {
|
||||||
const manifest = {
|
const manifest = {
|
||||||
...base,
|
...base,
|
||||||
_meta: {
|
_meta: {
|
||||||
"com.microsoft.windows": "raw-string" as unknown as Record<string, unknown>,
|
"com.microsoft.windows": "raw-string" as unknown as Record<
|
||||||
|
string,
|
||||||
|
unknown
|
||||||
|
>,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const result = McpbManifestSchema.safeParse(manifest);
|
const result = v0_3.McpbManifestSchema.safeParse(manifest);
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
const messages = result.error.issues.map((i) => i.message).join("\n");
|
const messages = result.error.issues.map((i) => i.message).join("\n");
|
||||||
|
|
@ -185,7 +191,7 @@ describe("McpbManifestSchema", () => {
|
||||||
"com.apple.darwin": [] as unknown as Record<string, unknown>,
|
"com.apple.darwin": [] as unknown as Record<string, unknown>,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const result = McpbManifestSchema.safeParse(manifest);
|
const result = v0_3.McpbManifestSchema.safeParse(manifest);
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -196,13 +202,13 @@ describe("McpbManifestSchema", () => {
|
||||||
custom: null as unknown as Record<string, unknown>,
|
custom: null as unknown as Record<string, unknown>,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const result = McpbManifestSchema.safeParse(manifest);
|
const result = v0_3.McpbManifestSchema.safeParse(manifest);
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows empty object for _meta", () => {
|
it("allows empty object for _meta", () => {
|
||||||
const manifest = { ...base, _meta: {} };
|
const manifest = { ...base, _meta: {} };
|
||||||
const result = McpbManifestSchema.safeParse(manifest);
|
const result = v0_3.McpbManifestSchema.safeParse(manifest);
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue