Skip to content

Commit db28726

Browse files
committed
Make properties optional
1 parent aaedd85 commit db28726

File tree

4 files changed

+58
-18
lines changed

4 files changed

+58
-18
lines changed

src/generated/schema.json

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
"description": "CSS variables for theming the app.",
269269
"type": "object",
270270
"propertyNames": {
271-
"description": "Style variables for theming MCP apps.",
271+
"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.",
272272
"anyOf": [
273273
{
274274
"type": "string",
@@ -417,8 +417,13 @@
417417
]
418418
},
419419
"additionalProperties": {
420-
"description": "Style variables for theming MCP apps.",
421-
"type": "string"
420+
"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.",
421+
"anyOf": [
422+
{
423+
"type": "string"
424+
},
425+
{}
426+
]
422427
}
423428
},
424429
"displayMode": {
@@ -711,7 +716,7 @@
711716
"description": "CSS variables for theming the app.",
712717
"type": "object",
713718
"propertyNames": {
714-
"description": "Style variables for theming MCP apps.",
719+
"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.",
715720
"anyOf": [
716721
{
717722
"type": "string",
@@ -860,8 +865,13 @@
860865
]
861866
},
862867
"additionalProperties": {
863-
"description": "Style variables for theming MCP apps.",
864-
"type": "string"
868+
"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.",
869+
"anyOf": [
870+
{
871+
"type": "string"
872+
},
873+
{}
874+
]
865875
}
866876
},
867877
"displayMode": {
@@ -1336,7 +1346,7 @@
13361346
"description": "CSS variables for theming the app.",
13371347
"type": "object",
13381348
"propertyNames": {
1339-
"description": "Style variables for theming MCP apps.",
1349+
"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.",
13401350
"anyOf": [
13411351
{
13421352
"type": "string",
@@ -1485,8 +1495,13 @@
14851495
]
14861496
},
14871497
"additionalProperties": {
1488-
"description": "Style variables for theming MCP apps.",
1489-
"type": "string"
1498+
"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.",
1499+
"anyOf": [
1500+
{
1501+
"type": "string"
1502+
},
1503+
{}
1504+
]
14901505
}
14911506
},
14921507
"displayMode": {
@@ -2341,10 +2356,10 @@
23412356
},
23422357
"McpUiStyles": {
23432358
"$schema": "https://json-schema.org/draft/2020-12/schema",
2344-
"description": "Style variables for theming MCP apps.",
2359+
"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.",
23452360
"type": "object",
23462361
"propertyNames": {
2347-
"description": "Style variables for theming MCP apps.",
2362+
"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.",
23482363
"anyOf": [
23492364
{
23502365
"type": "string",
@@ -2493,8 +2508,13 @@
24932508
]
24942509
},
24952510
"additionalProperties": {
2496-
"description": "Style variables for theming MCP apps.",
2497-
"type": "string"
2511+
"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.",
2512+
"anyOf": [
2513+
{
2514+
"type": "string"
2515+
},
2516+
{}
2517+
]
24982518
}
24992519
},
25002520
"McpUiTheme": {

src/generated/schema.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,27 @@ export const McpUiStyleVariableKeySchema = z
7070

7171
/**
7272
* @description Style variables for theming MCP apps.
73+
*
74+
* Individual style keys are optional - hosts may provide any subset of these values.
75+
* Values are strings containing CSS values (colors, sizes, font stacks, etc.).
76+
*
77+
* Note: This type uses `Record<K, string | undefined>` rather than `Partial<Record<K, string>>`
78+
* for compatibility with Zod schema generation. Both are functionally equivalent for validation.
7379
*/
7480
export const McpUiStylesSchema = z
7581
.record(
7682
McpUiStyleVariableKeySchema.describe(
77-
"Style variables for theming MCP apps.",
83+
"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.",
7884
),
79-
z.string().describe("Style variables for theming MCP apps."),
85+
z
86+
.union([z.string(), z.undefined()])
87+
.describe(
88+
"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.",
89+
),
8090
)
81-
.describe("Style variables for theming MCP apps.");
91+
.describe(
92+
"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.",
93+
);
8294

8395
/**
8496
* @description Request to open an external URL in the host's default browser.

src/spec.types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,14 @@ export type McpUiStyleVariableKey =
9191

9292
/**
9393
* @description Style variables for theming MCP apps.
94+
*
95+
* Individual style keys are optional - hosts may provide any subset of these values.
96+
* Values are strings containing CSS values (colors, sizes, font stacks, etc.).
97+
*
98+
* Note: This type uses `Record<K, string | undefined>` rather than `Partial<Record<K, string>>`
99+
* for compatibility with Zod schema generation. Both are functionally equivalent for validation.
94100
*/
95-
export type McpUiStyles = Record<McpUiStyleVariableKey, string>;
101+
export type McpUiStyles = Record<McpUiStyleVariableKey, string | undefined>;
96102

97103
/**
98104
* @description Request to open an external URL in the host's default browser.

src/styles.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ export function applyHostStyles(
109109
root: HTMLElement = document.documentElement,
110110
): void {
111111
for (const [key, value] of Object.entries(styles)) {
112-
root.style.setProperty(key, value);
112+
if (value !== undefined) {
113+
root.style.setProperty(key, value);
114+
}
113115
}
114116
}

0 commit comments

Comments
 (0)