The theme to apply ("light" or "dark")
import { applyDocumentTheme } from '@modelcontextprotocol/ext-apps';
app.onhostcontextchanged = (params) => {
if (params.theme) {
applyDocumentTheme(params.theme);
}
};
[data-theme="dark"] {
--bg-color: #1a1a1a;
}
[data-theme="light"] {
--bg-color: #ffffff;
}
Apply a theme to the document root element.
Sets the
data-themeattribute and CSScolor-schemeproperty ondocument.documentElement. This enables CSS selectors like[data-theme="dark"]and ensures native elements (scrollbars, form controls) respect the theme.