Make properties optional
This commit is contained in:
parent
aaedd858bb
commit
db2872643c
4 changed files with 58 additions and 18 deletions
|
|
@ -268,7 +268,7 @@
|
||||||
"description": "CSS variables for theming the app.",
|
"description": "CSS variables for theming the app.",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"propertyNames": {
|
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -417,8 +417,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"type": "string"
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"displayMode": {
|
"displayMode": {
|
||||||
|
|
@ -711,7 +716,7 @@
|
||||||
"description": "CSS variables for theming the app.",
|
"description": "CSS variables for theming the app.",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"propertyNames": {
|
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -860,8 +865,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"type": "string"
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"displayMode": {
|
"displayMode": {
|
||||||
|
|
@ -1336,7 +1346,7 @@
|
||||||
"description": "CSS variables for theming the app.",
|
"description": "CSS variables for theming the app.",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"propertyNames": {
|
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -1485,8 +1495,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"type": "string"
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"displayMode": {
|
"displayMode": {
|
||||||
|
|
@ -2341,10 +2356,10 @@
|
||||||
},
|
},
|
||||||
"McpUiStyles": {
|
"McpUiStyles": {
|
||||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
"$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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"propertyNames": {
|
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -2493,8 +2508,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||||
"type": "string"
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"McpUiTheme": {
|
"McpUiTheme": {
|
||||||
|
|
|
||||||
|
|
@ -70,15 +70,27 @@ export const McpUiStyleVariableKeySchema = z
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Style variables for theming MCP apps.
|
* @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<K, string | undefined>` rather than `Partial<Record<K, string>>`
|
||||||
|
* for compatibility with Zod schema generation. Both are functionally equivalent for validation.
|
||||||
*/
|
*/
|
||||||
export const McpUiStylesSchema = z
|
export const McpUiStylesSchema = z
|
||||||
.record(
|
.record(
|
||||||
McpUiStyleVariableKeySchema.describe(
|
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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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.
|
* @description Request to open an external URL in the host's default browser.
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,14 @@ export type McpUiStyleVariableKey =
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Style variables for theming MCP apps.
|
* @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<K, string | undefined>` rather than `Partial<Record<K, string>>`
|
||||||
|
* for compatibility with Zod schema generation. Both are functionally equivalent for validation.
|
||||||
*/
|
*/
|
||||||
export type McpUiStyles = Record<McpUiStyleVariableKey, string>;
|
export type McpUiStyles = Record<McpUiStyleVariableKey, string | undefined>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Request to open an external URL in the host's default browser.
|
* @description Request to open an external URL in the host's default browser.
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,8 @@ export function applyHostStyles(
|
||||||
root: HTMLElement = document.documentElement,
|
root: HTMLElement = document.documentElement,
|
||||||
): void {
|
): void {
|
||||||
for (const [key, value] of Object.entries(styles)) {
|
for (const [key, value] of Object.entries(styles)) {
|
||||||
root.style.setProperty(key, value);
|
if (value !== undefined) {
|
||||||
|
root.style.setProperty(key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue