Merge pull request #117 from anthropics/fix/json-schema-generation
fix: restore JSON schema generation
This commit is contained in:
commit
ef6908e612
4 changed files with 363 additions and 15 deletions
11
package.json
11
package.json
|
|
@ -26,14 +26,16 @@
|
||||||
"types": "./dist/cli.d.ts",
|
"types": "./dist/cli.d.ts",
|
||||||
"import": "./dist/cli.js",
|
"import": "./dist/cli.js",
|
||||||
"require": "./dist/cli.js"
|
"require": "./dist/cli.js"
|
||||||
}
|
},
|
||||||
|
"./mcpb-manifest.schema.json": "./dist/mcpb-manifest.schema.json"
|
||||||
},
|
},
|
||||||
"bin": "dist/cli/cli.js",
|
"bin": "dist/cli/cli.js",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist",
|
||||||
|
"schemas"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "yarn run build:code",
|
"build": "yarn run build:code && yarn run build:schema",
|
||||||
"build:code": "tsc",
|
"build:code": "tsc",
|
||||||
"build:schema": "node ./scripts/build-mcpb-schema.js",
|
"build:schema": "node ./scripts/build-mcpb-schema.js",
|
||||||
"dev": "tsc --watch",
|
"dev": "tsc --watch",
|
||||||
|
|
@ -71,7 +73,8 @@
|
||||||
"ignore": "^7.0.5",
|
"ignore": "^7.0.5",
|
||||||
"node-forge": "^1.3.1",
|
"node-forge": "^1.3.1",
|
||||||
"pretty-bytes": "^5.6.0",
|
"pretty-bytes": "^5.6.0",
|
||||||
"zod": "^3.25.67"
|
"zod": "^3.25.67",
|
||||||
|
"zod-to-json-schema": "^3.24.6"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@babel/helpers": "7.27.1",
|
"@babel/helpers": "7.27.1",
|
||||||
|
|
|
||||||
327
schemas/mcpb-manifest.schema.json
Normal file
327
schemas/mcpb-manifest.schema.json
Normal file
|
|
@ -0,0 +1,327 @@
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"$schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"dxt_version": {
|
||||||
|
"type": "string",
|
||||||
|
"const": "0.2",
|
||||||
|
"description": "@deprecated Use manifest_version instead"
|
||||||
|
},
|
||||||
|
"manifest_version": {
|
||||||
|
"type": "string",
|
||||||
|
"const": "0.2"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"display_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"long_description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "email"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type",
|
||||||
|
"url"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"homepage": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri"
|
||||||
|
},
|
||||||
|
"documentation": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri"
|
||||||
|
},
|
||||||
|
"support": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri"
|
||||||
|
},
|
||||||
|
"icon": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"screenshots": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"python",
|
||||||
|
"node",
|
||||||
|
"binary"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"entry_point": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"mcp_config": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"command": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"args": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"command"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type",
|
||||||
|
"entry_point",
|
||||||
|
"mcp_config"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"tools": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tools_generated": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"prompts": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"arguments": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"text"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"prompts_generated": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"keywords": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"privacy_policies": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compatibility": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"claude_desktop": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"platforms": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"darwin",
|
||||||
|
"win32",
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimes": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"python": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"node": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"user_config": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"directory",
|
||||||
|
"file"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"multiple": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"sensitive": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"min": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"max": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type",
|
||||||
|
"title",
|
||||||
|
"description"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"version",
|
||||||
|
"description",
|
||||||
|
"author",
|
||||||
|
"server"
|
||||||
|
],
|
||||||
|
"additionalProperties": false,
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import {
|
import {
|
||||||
McpbManifestSchema,
|
McpbManifestSchema,
|
||||||
McpbSignatureInfoSchema,
|
McpbSignatureInfoSchema,
|
||||||
} from "../dist/schemas.js";
|
} from "../dist/schemas/latest.js";
|
||||||
import * as z from "zod/v4";
|
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";
|
||||||
|
|
||||||
|
|
@ -11,15 +11,23 @@ const schemasToWrite = {
|
||||||
"mcpb-signature-info": McpbSignatureInfoSchema,
|
"mcpb-signature-info": McpbSignatureInfoSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
await fs.mkdir(path.join(import.meta.dirname, "../dist"), { recursive: true });
|
const distDir = path.join(import.meta.dirname, "../dist");
|
||||||
|
const schemasDir = path.join(import.meta.dirname, "../schemas");
|
||||||
|
|
||||||
|
// Generate all schemas to dist/
|
||||||
|
await fs.mkdir(distDir, { recursive: true });
|
||||||
for (const key in schemasToWrite) {
|
for (const key in schemasToWrite) {
|
||||||
const schema = z.toJSONSchema(schemasToWrite[key]);
|
const schema = zodToJsonSchema(schemasToWrite[key]);
|
||||||
await fs.writeFile(
|
const filePath = path.join(distDir, `${key}.schema.json`);
|
||||||
path.join(import.meta.dirname, "../dist", `${key}.schema.json`),
|
await fs.writeFile(filePath, JSON.stringify(schema, null, 2), {
|
||||||
JSON.stringify(schema, null, 2),
|
encoding: "utf8",
|
||||||
{
|
});
|
||||||
encoding: "utf8",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate only manifest schema to schemas/
|
||||||
|
await fs.mkdir(schemasDir, { recursive: true });
|
||||||
|
const manifestSchema = zodToJsonSchema(McpbManifestSchema);
|
||||||
|
const manifestPath = path.join(schemasDir, "mcpb-manifest.schema.json");
|
||||||
|
await fs.writeFile(manifestPath, JSON.stringify(manifestSchema, null, 2), {
|
||||||
|
encoding: "utf8",
|
||||||
|
});
|
||||||
|
|
|
||||||
10
yarn.lock
10
yarn.lock
|
|
@ -42,6 +42,7 @@ __metadata:
|
||||||
ts-jest: "npm:^29.3.2"
|
ts-jest: "npm:^29.3.2"
|
||||||
typescript: "npm:^5.6.3"
|
typescript: "npm:^5.6.3"
|
||||||
zod: "npm:^3.25.67"
|
zod: "npm:^3.25.67"
|
||||||
|
zod-to-json-schema: "npm:^3.24.6"
|
||||||
bin:
|
bin:
|
||||||
mcpb: dist/cli/cli.js
|
mcpb: dist/cli/cli.js
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
|
|
@ -6387,6 +6388,15 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"zod-to-json-schema@npm:^3.24.6":
|
||||||
|
version: 3.24.6
|
||||||
|
resolution: "zod-to-json-schema@npm:3.24.6"
|
||||||
|
peerDependencies:
|
||||||
|
zod: ^3.24.1
|
||||||
|
checksum: 10c0/b907ab6d057100bd25a37e5545bf5f0efa5902cd84d3c3ec05c2e51541431a47bd9bf1e5e151a244273409b45f5986d55b26e5d207f98abc5200702f733eb368
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"zod@npm:^3.25.67":
|
"zod@npm:^3.25.67":
|
||||||
version: 3.25.67
|
version: 3.25.67
|
||||||
resolution: "zod@npm:3.25.67"
|
resolution: "zod@npm:3.25.67"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue