Add localization/theming feature to 0.3 version

This commit is contained in:
Alexander Sklar 2025-10-24 15:48:46 -07:00
commit 1640adefe8
No known key found for this signature in database
2 changed files with 559 additions and 18 deletions

View file

@ -3,6 +3,10 @@ import * as z from "zod";
export const MANIFEST_VERSION = "0.3";
const LOCALE_PLACEHOLDER_REGEX = /\$\{locale\}/i;
const BCP47_REGEX = /^[A-Za-z0-9]{2,8}(?:-[A-Za-z0-9]{1,8})*$/;
const ICON_SIZE_REGEX = /^\d+x\d+$/;
export const McpServerConfigSchema = z.strictObject({
command: z.string(),
args: z.array(z.string()).optional(),
@ -77,6 +81,35 @@ export const McpbUserConfigValuesSchema = z.record(
z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
);
export const McpbManifestLocalizationSchema = z.strictObject({
resources: z
.string()
.regex(
LOCALE_PLACEHOLDER_REGEX,
'resources must include a "${locale}" placeholder',
),
default_locale: z
.string()
.regex(
BCP47_REGEX,
"default_locale must be a valid BCP 47 locale identifier",
),
});
export const McpbManifestIconSchema = z.strictObject({
src: z.string(),
sizes: z
.string()
.regex(
ICON_SIZE_REGEX,
'sizes must be in the format "WIDTHxHEIGHT" (e.g., "16x16")',
),
theme: z
.string()
.min(1, "theme cannot be empty when provided")
.optional(),
});
export const McpbManifestSchema = z
.strictObject({
$schema: z.string().optional(),
@ -96,7 +129,9 @@ export const McpbManifestSchema = z
documentation: z.string().url().optional(),
support: z.string().url().optional(),
icon: z.string().optional(),
icons: z.array(McpbManifestIconSchema).optional(),
screenshots: z.array(z.string()).optional(),
localization: McpbManifestLocalizationSchema.optional(),
server: McpbManifestServerSchema,
tools: z.array(McpbManifestToolSchema).optional(),
tools_generated: z.boolean().optional(),

View file

@ -1 +1 @@
export * from "./0.2.js";
export * from "./0.3.js";