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.",
|
||||
"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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\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<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{}
|
||||
]
|
||||
}
|
||||
},
|
||||
"McpUiTheme": {
|
||||
|
|
|
|||
|
|
@ -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<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
|
||||
.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<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.
|
||||
|
|
|
|||
|
|
@ -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<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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue