Allow undefined values

This commit is contained in:
martinalong 2025-12-18 00:01:34 -08:00
commit c22e86233b
No known key found for this signature in database
3 changed files with 106 additions and 20 deletions

View file

@ -330,6 +330,10 @@
"type": "string",
"const": "--color-text-inverse"
},
{
"type": "string",
"const": "--color-text-ghost"
},
{
"type": "string",
"const": "--color-text-info"
@ -634,19 +638,39 @@
"properties": {
"width": {
"description": "Viewport width in pixels (if fixed). Only pass width or maxWidth, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"height": {
"description": "Viewport height in pixels (if fixed). Only pass height or maxHeight, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"maxWidth": {
"description": "Maximum available viewport width in pixels (if constrained). Only pass width or maxWidth, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"maxHeight": {
"description": "Maximum available viewport height in pixels (if constrained). Only pass height or maxHeight, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
}
},
"additionalProperties": false
@ -955,6 +979,10 @@
"type": "string",
"const": "--color-text-inverse"
},
{
"type": "string",
"const": "--color-text-ghost"
},
{
"type": "string",
"const": "--color-text-info"
@ -1259,19 +1287,39 @@
"properties": {
"width": {
"description": "Viewport width in pixels (if fixed). Only pass width or maxWidth, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"height": {
"description": "Viewport height in pixels (if fixed). Only pass height or maxHeight, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"maxWidth": {
"description": "Maximum available viewport width in pixels (if constrained). Only pass width or maxWidth, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"maxHeight": {
"description": "Maximum available viewport height in pixels (if constrained). Only pass height or maxHeight, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
}
},
"additionalProperties": false
@ -1424,6 +1472,10 @@
"type": "string",
"const": "--color-text-inverse"
},
{
"type": "string",
"const": "--color-text-ghost"
},
{
"type": "string",
"const": "--color-text-info"
@ -2113,6 +2165,10 @@
"type": "string",
"const": "--color-text-inverse"
},
{
"type": "string",
"const": "--color-text-ghost"
},
{
"type": "string",
"const": "--color-text-info"
@ -2417,19 +2473,39 @@
"properties": {
"width": {
"description": "Viewport width in pixels (if fixed). Only pass width or maxWidth, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"height": {
"description": "Viewport height in pixels (if fixed). Only pass height or maxHeight, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"maxWidth": {
"description": "Maximum available viewport width in pixels (if constrained). Only pass width or maxWidth, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
},
"maxHeight": {
"description": "Maximum available viewport height in pixels (if constrained). Only pass height or maxHeight, not both.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{}
]
}
},
"additionalProperties": false
@ -3207,6 +3283,10 @@
"type": "string",
"const": "--color-text-inverse"
},
{
"type": "string",
"const": "--color-text-ghost"
},
{
"type": "string",
"const": "--color-text-info"
@ -3520,6 +3600,10 @@
"type": "string",
"const": "--color-text-inverse"
},
{
"type": "string",
"const": "--color-text-ghost"
},
{
"type": "string",
"const": "--color-text-info"

View file

@ -43,6 +43,7 @@ export const McpUiStyleVariableKeySchema = z
z.literal("--color-text-secondary"),
z.literal("--color-text-tertiary"),
z.literal("--color-text-inverse"),
z.literal("--color-text-ghost"),
z.literal("--color-text-info"),
z.literal("--color-text-danger"),
z.literal("--color-text-success"),
@ -567,28 +568,28 @@ export const McpUiHostContextSchema = z.looseObject({
.object({
/** @description Viewport width in pixels (if fixed). Only pass width or maxWidth, not both. */
width: z
.number()
.union([z.number(), z.undefined()])
.optional()
.describe(
"Viewport width in pixels (if fixed). Only pass width or maxWidth, not both.",
),
/** @description Viewport height in pixels (if fixed). Only pass height or maxHeight, not both. */
height: z
.number()
.union([z.number(), z.undefined()])
.optional()
.describe(
"Viewport height in pixels (if fixed). Only pass height or maxHeight, not both.",
),
/** @description Maximum available viewport width in pixels (if constrained). Only pass width or maxWidth, not both.*/
maxWidth: z
.number()
.union([z.number(), z.undefined()])
.optional()
.describe(
"Maximum available viewport width in pixels (if constrained). Only pass width or maxWidth, not both.",
),
/** @description Maximum available viewport height in pixels (if constrained). Only pass height or maxHeight, not both. */
maxHeight: z
.number()
.union([z.number(), z.undefined()])
.optional()
.describe(
"Maximum available viewport height in pixels (if constrained). Only pass height or maxHeight, not both.",

View file

@ -56,6 +56,7 @@ export type McpUiStyleVariableKey =
| "--color-text-secondary"
| "--color-text-tertiary"
| "--color-text-inverse"
| "--color-text-ghost"
| "--color-text-info"
| "--color-text-danger"
| "--color-text-success"
@ -327,13 +328,13 @@ export interface McpUiHostContext {
/** @description Current and maximum dimensions available to the UI. */
viewport?: {
/** @description Viewport width in pixels (if fixed). Only pass width or maxWidth, not both. */
width?: number;
width?: number | undefined;
/** @description Viewport height in pixels (if fixed). Only pass height or maxHeight, not both. */
height?: number;
height?: number | undefined;
/** @description Maximum available viewport width in pixels (if constrained). Only pass width or maxWidth, not both.*/
maxWidth?: number;
maxWidth?: number | undefined;
/** @description Maximum available viewport height in pixels (if constrained). Only pass height or maxHeight, not both. */
maxHeight?: number;
maxHeight?: number | undefined;
};
/** @description User's language and region preference in BCP 47 format. */
locale?: string;