Skip to content

Commit 7bf456c

Browse files
committed
Make it styles.variables instead of styles
1 parent ba395d0 commit 7bf456c

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
@@ -401,8 +401,11 @@ interface HostContext {
401401
};
402402
/** Current color theme preference */
403403
theme?: "light" | "dark";
404-
/** CSS variables for theming. See Theming section for standardized variable names. */
405-
styles?: Record<McpUiStyleVariableKey, string | undefined>;
404+
/** Style configuration for theming. See Theming section for standardized variable names. */
405+
styles?: {
406+
/** CSS variables for theming */
407+
variables?: Record<McpUiStyleVariableKey, string | undefined>;
408+
};
406409
/** How the UI is currently displayed */
407410
displayMode?: "inline" | "fullscreen" | "pip";
408411
/** Display modes the host supports */
@@ -451,10 +454,12 @@ Example:
451454
"hostContext": {
452455
"theme": "dark",
453456
"styles": {
454-
"--color-background-primary": "light-dark(#ffffff, #171717)",
455-
"--color-text-primary": "light-dark(#171717, #fafafa)",
456-
"--font-family-sans": "system-ui, sans-serif",
457-
...
457+
"variables": {
458+
"--color-background-primary": "light-dark(#ffffff, #171717)",
459+
"--color-text-primary": "light-dark(#171717, #fafafa)",
460+
"--font-family-sans": "system-ui, sans-serif",
461+
...
462+
}
458463
},
459464
"displayMode": "inline",
460465
"viewport": { "width": 400, "height": 300 }
@@ -465,7 +470,7 @@ Example:
465470

466471
### Theming
467472

468-
Hosts can optionally pass CSS custom properties via `HostContext.styles` for visual cohesion with the host environment.
473+
Hosts can optionally pass CSS custom properties via `HostContext.styles.variables` for visual cohesion with the host environment.
469474

470475
#### Current Standardized Variables
471476

0 commit comments

Comments
 (0)