Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/app-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
McpUiSizeChangedNotificationSchema,
} from "./types";
export * from "./types";
export { RESOURCE_URI_META_KEY } from "./app";
export { PostMessageTransport } from "./message-transport";

/**
Expand Down Expand Up @@ -153,8 +154,8 @@ type RequestHandlerExtra = Parameters<
*/
export class AppBridge extends Protocol<Request, Notification, Result> {
private _appCapabilities?: McpUiAppCapabilities;
private _hostContext: McpUiHostContext = {};
private _appInfo?: Implementation;
private _hostContext: McpUiHostContext;

/**
* Create a new AppBridge instance.
Expand Down Expand Up @@ -625,13 +626,23 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
}
if (hasChanges) {
this._hostContext = hostContext;
this.notification((<McpUiHostContextChangedNotification>{
method: "ui/notifications/host-context-changed",
params: changes,
}) as Notification); // Cast needed because McpUiHostContext is a params type that doesn't allow arbitrary keys.
this.sendHostContextChange(changes);
}
}

/**
* Send a host context change notification to the app.
* Only sends the fields that have changed (partial update).
*/
sendHostContextChange(
params: McpUiHostContextChangedNotification["params"],
): Promise<void> | void {
return this.notification((<McpUiHostContextChangedNotification>{
method: "ui/notifications/host-context-changed",
params,
}) as Notification);
}

/**
* Send complete tool arguments to the Guest UI.
*
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
} from "./types";
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";

export { PostMessageTransport } from "./message-transport.js";
export { PostMessageTransport } from "./message-transport";
export * from "./types";

/**
Expand Down
Loading