Skip to content

Commit 445a583

Browse files
committed
Make it styles.variables instead of styles
1 parent 2fa243a commit 445a583

File tree

9 files changed

+717
-496
lines changed

9 files changed

+717
-496
lines changed

examples/customer-segmentation-server/src/mcp-app.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,11 @@ app.onhostcontextchanged = (params) => {
453453
if (params.theme) {
454454
applyDocumentTheme(params.theme);
455455
}
456-
if (params.styles) {
457-
applyHostStyles(params.styles);
456+
if (params.styles?.variables) {
457+
applyHostStyles(params.styles.variables);
458458
}
459459
// Recreate chart to pick up new colors
460-
if (state.chart && (params.theme || params.styles)) {
460+
if (state.chart && (params.theme || params.styles?.variables)) {
461461
state.chart.destroy();
462462
state.chart = initChart();
463463
}
@@ -469,8 +469,8 @@ app.connect(new PostMessageTransport(window.parent)).then(() => {
469469
if (ctx?.theme) {
470470
applyDocumentTheme(ctx.theme);
471471
}
472-
if (ctx?.styles) {
473-
applyHostStyles(ctx.styles);
472+
if (ctx?.styles?.variables) {
473+
applyHostStyles(ctx.styles.variables);
474474
}
475475
});
476476

specification/draft/apps.mdx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,11 @@ interface HostContext {
404404
};
405405
/** Current color theme preference */
406406
theme?: "light" | "dark";
407-
/** CSS variables for theming. See Theming section for standardized variable names. */
408-
styles?: Record<McpUiStyleVariableKey, string | undefined>;
407+
/** Style configuration for theming. See Theming section for standardized variable names. */
408+
styles?: {
409+
/** CSS variables for theming */
410+
variables?: Record<McpUiStyleVariableKey, string | undefined>;
411+
};
409412
/** How the UI is currently displayed */
410413
displayMode?: "inline" | "fullscreen" | "pip";
411414
/** Display modes the host supports */
@@ -454,10 +457,12 @@ Example:
454457
"hostContext": {
455458
"theme": "dark",
456459
"styles": {
457-
"--color-background-primary": "light-dark(#ffffff, #171717)",
458-
"--color-text-primary": "light-dark(#171717, #fafafa)",
459-
"--font-family-sans": "system-ui, sans-serif",
460-
...
460+
"variables": {
461+
"--color-background-primary": "light-dark(#ffffff, #171717)",
462+
"--color-text-primary": "light-dark(#171717, #fafafa)",
463+
"--font-family-sans": "system-ui, sans-serif",
464+
...
465+
}
461466
},
462467
"displayMode": "inline",
463468
"viewport": { "width": 400, "height": 300 }
@@ -468,7 +473,7 @@ Example:
468473

469474
### Theming
470475

471-
Hosts can optionally pass CSS custom properties via `HostContext.styles` for visual cohesion with the host environment.
476+
Hosts can optionally pass CSS custom properties via `HostContext.styles.variables` for visual cohesion with the host environment.
472477

473478
#### Current Standardized Variables
474479

0 commit comments

Comments
 (0)