diff --git a/src/generated/schema.json b/src/generated/schema.json index 63cb3d3..047ad29 100644 --- a/src/generated/schema.json +++ b/src/generated/schema.json @@ -268,7 +268,7 @@ "description": "CSS variables for theming the app.", "type": "object", "propertyNames": { - "description": "Style variables for theming MCP apps.", + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", "anyOf": [ { "type": "string", @@ -417,8 +417,13 @@ ] }, "additionalProperties": { - "description": "Style variables for theming MCP apps.", - "type": "string" + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", + "anyOf": [ + { + "type": "string" + }, + {} + ] } }, "displayMode": { @@ -711,7 +716,7 @@ "description": "CSS variables for theming the app.", "type": "object", "propertyNames": { - "description": "Style variables for theming MCP apps.", + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", "anyOf": [ { "type": "string", @@ -860,8 +865,13 @@ ] }, "additionalProperties": { - "description": "Style variables for theming MCP apps.", - "type": "string" + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", + "anyOf": [ + { + "type": "string" + }, + {} + ] } }, "displayMode": { @@ -1336,7 +1346,7 @@ "description": "CSS variables for theming the app.", "type": "object", "propertyNames": { - "description": "Style variables for theming MCP apps.", + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", "anyOf": [ { "type": "string", @@ -1485,8 +1495,13 @@ ] }, "additionalProperties": { - "description": "Style variables for theming MCP apps.", - "type": "string" + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", + "anyOf": [ + { + "type": "string" + }, + {} + ] } }, "displayMode": { @@ -2341,10 +2356,10 @@ }, "McpUiStyles": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "Style variables for theming MCP apps.", + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", "type": "object", "propertyNames": { - "description": "Style variables for theming MCP apps.", + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", "anyOf": [ { "type": "string", @@ -2493,8 +2508,13 @@ ] }, "additionalProperties": { - "description": "Style variables for theming MCP apps.", - "type": "string" + "description": "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", + "anyOf": [ + { + "type": "string" + }, + {} + ] } }, "McpUiTheme": { diff --git a/src/generated/schema.ts b/src/generated/schema.ts index 6b804dc..07b82cf 100644 --- a/src/generated/schema.ts +++ b/src/generated/schema.ts @@ -70,15 +70,27 @@ export const McpUiStyleVariableKeySchema = z /** * @description Style variables for theming MCP apps. + * + * Individual style keys are optional - hosts may provide any subset of these values. + * Values are strings containing CSS values (colors, sizes, font stacks, etc.). + * + * Note: This type uses `Record` rather than `Partial>` + * for compatibility with Zod schema generation. Both are functionally equivalent for validation. */ export const McpUiStylesSchema = z .record( McpUiStyleVariableKeySchema.describe( - "Style variables for theming MCP apps.", + "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", ), - z.string().describe("Style variables for theming MCP apps."), + z + .union([z.string(), z.undefined()]) + .describe( + "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", + ), ) - .describe("Style variables for theming MCP apps."); + .describe( + "Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record` rather than `Partial>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.", + ); /** * @description Request to open an external URL in the host's default browser. diff --git a/src/spec.types.ts b/src/spec.types.ts index 0dbfb03..5450f79 100644 --- a/src/spec.types.ts +++ b/src/spec.types.ts @@ -91,8 +91,14 @@ export type McpUiStyleVariableKey = /** * @description Style variables for theming MCP apps. + * + * Individual style keys are optional - hosts may provide any subset of these values. + * Values are strings containing CSS values (colors, sizes, font stacks, etc.). + * + * Note: This type uses `Record` rather than `Partial>` + * for compatibility with Zod schema generation. Both are functionally equivalent for validation. */ -export type McpUiStyles = Record; +export type McpUiStyles = Record; /** * @description Request to open an external URL in the host's default browser. diff --git a/src/styles.ts b/src/styles.ts index 4544248..45957be 100644 --- a/src/styles.ts +++ b/src/styles.ts @@ -109,6 +109,8 @@ export function applyHostStyles( root: HTMLElement = document.documentElement, ): void { for (const [key, value] of Object.entries(styles)) { - root.style.setProperty(key, value); + if (value !== undefined) { + root.style.setProperty(key, value); + } } }