Skip to content

Commit 4e01a6c

Browse files
committed
Make height/width optional as well
1 parent 87f6f3f commit 4e01a6c

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

specification/draft/apps.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ interface HostContext {
464464
/** Current and maximum dimensions available to the UI. */
465465
viewport?: {
466466
/** Current viewport width in pixels. */
467-
width: number;
467+
width?: number;
468468
/** Current viewport height in pixels. */
469-
height: number;
469+
height?: number;
470470
/** Maximum available height in pixels (if constrained). */
471471
maxHeight?: number;
472472
/** Maximum available width in pixels (if constrained). */
@@ -552,20 +552,20 @@ if (viewport) {
552552
// Handle height
553553
if ("height" in viewport) {
554554
// Fixed height: fill the container
555-
document.body.style.height = "100%";
555+
document.documentElement.style.height = "100vh";
556556
} else if (viewport.maxHeight) {
557557
// Flexible with max: let content determine size, up to max
558-
document.body.style.maxHeight = `${viewport.maxHeight}px`;
558+
document.documentElement.style.maxHeight = `${viewport.maxHeight}px`;
559559
}
560560
// If neither, height is unbounded
561561

562562
// Handle width
563563
if ("width" in viewport) {
564564
// Fixed width: fill the container
565-
document.body.style.width = "100%";
565+
document.documentElement.style.width = "100vw";
566566
} else if (viewport.maxWidth) {
567567
// Flexible with max: let content determine size, up to max
568-
document.body.style.maxWidth = `${viewport.maxWidth}px`;
568+
document.documentElement.style.maxWidth = `${viewport.maxWidth}px`;
569569
}
570570
// If neither, width is unbounded
571571
}

src/generated/schema.json

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generated/schema.ts

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/spec.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ export interface McpUiHostContext {
327327
/** @description Current and maximum dimensions available to the UI. */
328328
viewport?: {
329329
/** @description Current viewport width in pixels. */
330-
width: number;
330+
width?: number;
331331
/** @description Current viewport height in pixels. */
332-
height: number;
332+
height?: number;
333333
/** @description Maximum available height in pixels (if constrained). */
334334
maxHeight?: number;
335335
/** @description Maximum available width in pixels (if constrained). */

0 commit comments

Comments
 (0)