mcpb/scripts/build-mcpb-schema.js
Joan Xie d90365e626
feat: add UV runtime support in manifest v0.4
Add UV as a new server type for Python extensions that use UV runtime
for dependency management instead of bundling dependencies.

Schema changes (v0.4):
- Add "uv" to server.type enum
- Make mcp_config optional (not needed for UV type)
- UV extensions rely on pyproject.toml for dependencies

Documentation:
- Add UV runtime section to MANIFEST.md explaining benefits and usage
- Update README.md to recommend UV runtime for Python
- Add complete hello-world-uv example

Benefits of UV runtime:
- Cross-platform support (Windows/macOS/Linux, Intel/ARM)
- Small bundle size (~100 KB vs 5-10 MB)
- Handles compiled dependencies portably
- No user Python installation required

Example manifest:
{
  "manifest_version": "0.4",
  "server": {
    "type": "uv",
    "entry_point": "src/server.py"
  }
}

Co-authored-by: Joan <joan@anthropic.com>
2025-12-02 21:22:19 -08:00

46 lines
1.8 KiB
JavaScript

import { McpbManifestSchema as McpbManifestSchema_v0_1 } from "../dist/schemas/0.1.js";
import { McpbManifestSchema as McpbManifestSchema_v0_2 } from "../dist/schemas/0.2.js";
import { McpbManifestSchema as McpbManifestSchema_v0_3 } from "../dist/schemas/0.3.js";
import { McpbManifestSchema as McpbManifestSchema_v0_4 } from "../dist/schemas/0.4.js";
import { McpbSignatureInfoSchema } from "../dist/shared/common.js";
import { zodToJsonSchema } from "zod-to-json-schema";
import fs from "node:fs/promises";
import path from "node:path";
const distDir = path.join(import.meta.dirname, "../dist");
const schemasDir = path.join(import.meta.dirname, "../schemas");
// Versioned manifest schemas
const versionedManifestSchemas = {
"mcpb-manifest-v0.1": McpbManifestSchema_v0_1,
"mcpb-manifest-v0.2": McpbManifestSchema_v0_2,
"mcpb-manifest-v0.3": McpbManifestSchema_v0_3,
"mcpb-manifest-v0.4": McpbManifestSchema_v0_4,
};
// Other schemas
const otherSchemas = {
"mcpb-signature-info": McpbSignatureInfoSchema,
};
const allSchemas = { ...versionedManifestSchemas, ...otherSchemas };
// Generate all schemas to dist/
await fs.mkdir(distDir, { recursive: true });
for (const [key, schema] of Object.entries(allSchemas)) {
const jsonSchema = zodToJsonSchema(schema);
const filePath = path.join(distDir, `${key}.schema.json`);
await fs.writeFile(filePath, JSON.stringify(jsonSchema, null, 2), {
encoding: "utf8",
});
}
// Generate all versioned manifest schemas to schemas/
await fs.mkdir(schemasDir, { recursive: true });
for (const [key, schema] of Object.entries(versionedManifestSchemas)) {
const jsonSchema = zodToJsonSchema(schema);
const filePath = path.join(schemasDir, `${key}.schema.json`);
await fs.writeFile(filePath, JSON.stringify(jsonSchema, null, 2), {
encoding: "utf8",
});
}