55 CallToolRequestSchema ,
66 CallToolResult ,
77 CallToolResultSchema ,
8+ EmptyResult ,
89 Implementation ,
910 ListPromptsRequest ,
1011 ListPromptsRequestSchema ,
@@ -18,9 +19,10 @@ import {
1819 ListResourceTemplatesRequestSchema ,
1920 ListResourceTemplatesResult ,
2021 ListResourceTemplatesResultSchema ,
22+ ListToolsRequest ,
23+ ListToolsResult ,
2124 LoggingMessageNotification ,
2225 LoggingMessageNotificationSchema ,
23- Notification ,
2426 PingRequest ,
2527 PingRequestSchema ,
2628 PromptListChangedNotification ,
@@ -29,10 +31,8 @@ import {
2931 ReadResourceRequestSchema ,
3032 ReadResourceResult ,
3133 ReadResourceResultSchema ,
32- Request ,
3334 ResourceListChangedNotification ,
3435 ResourceListChangedNotificationSchema ,
35- Result ,
3636 ToolListChangedNotification ,
3737 ToolListChangedNotificationSchema ,
3838} from "@modelcontextprotocol/sdk/types.js" ;
@@ -66,6 +66,7 @@ import {
6666 McpUiOpenLinkRequestSchema ,
6767 McpUiOpenLinkResult ,
6868 McpUiResourceTeardownRequest ,
69+ McpUiResourceTeardownResult ,
6970 McpUiResourceTeardownResultSchema ,
7071 McpUiSandboxProxyReadyNotification ,
7172 McpUiSandboxProxyReadyNotificationSchema ,
@@ -75,6 +76,73 @@ export * from "./types";
7576export { RESOURCE_URI_META_KEY , RESOURCE_MIME_TYPE } from "./app" ;
7677export { PostMessageTransport } from "./message-transport" ;
7778
79+ /**
80+ * All request types in the MCP Apps protocol.
81+ *
82+ * Includes:
83+ * - MCP UI requests (initialize, open-link, message, resource-teardown)
84+ * - MCP server requests forwarded from the app (tools/call, resources/*, prompts/list)
85+ * - Protocol requests (ping)
86+ */
87+ export type AppRequest =
88+ | McpUiInitializeRequest
89+ | McpUiOpenLinkRequest
90+ | McpUiMessageRequest
91+ | McpUiResourceTeardownRequest
92+ | CallToolRequest
93+ | ListToolsRequest
94+ | ListResourcesRequest
95+ | ListResourceTemplatesRequest
96+ | ReadResourceRequest
97+ | ListPromptsRequest
98+ | PingRequest ;
99+
100+ /**
101+ * All notification types in the MCP Apps protocol.
102+ *
103+ * Host to app:
104+ * - Tool lifecycle (input, input-partial, result, cancelled)
105+ * - Host context changes
106+ * - MCP list changes (tools, resources, prompts)
107+ * - Sandbox resource ready
108+ *
109+ * App to host:
110+ * - Initialized, size-changed, sandbox-proxy-ready
111+ * - Logging messages
112+ */
113+ export type AppNotification =
114+ // Sent to app
115+ | McpUiHostContextChangedNotification
116+ | McpUiToolInputNotification
117+ | McpUiToolInputPartialNotification
118+ | McpUiToolResultNotification
119+ | McpUiToolCancelledNotification
120+ | McpUiSandboxResourceReadyNotification
121+ | ToolListChangedNotification
122+ | ResourceListChangedNotification
123+ | PromptListChangedNotification
124+ // Received from app
125+ | McpUiInitializedNotification
126+ | McpUiSizeChangedNotification
127+ | McpUiSandboxProxyReadyNotification
128+ | LoggingMessageNotification ;
129+
130+ /**
131+ * All result types in the MCP Apps protocol.
132+ */
133+ export type AppResult =
134+ | McpUiInitializeResult
135+ | McpUiOpenLinkResult
136+ | McpUiMessageResult
137+ | McpUiResourceTeardownResult
138+ | CallToolResult
139+ | ListToolsResult
140+ | ListResourcesResult
141+ | ListResourceTemplatesResult
142+ | ReadResourceResult
143+ | ListPromptsResult
144+ | EmptyResult ;
145+
78146/**
79147 * Options for configuring AppBridge behavior.
80148 *
@@ -164,7 +232,11 @@ type RequestHandlerExtra = Parameters<
164232 * await bridge.connect(transport);
165233 * ```
166234 */
167- export class AppBridge extends Protocol < Request , Notification , Result > {
235+ export class AppBridge extends Protocol <
236+ AppRequest ,
237+ AppNotification ,
238+ AppResult
239+ > {
168240 private _appCapabilities ?: McpUiAppCapabilities ;
169241 private _hostContext : McpUiHostContext = { } ;
170242 private _appInfo ?: Implementation ;
@@ -805,23 +877,23 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
805877 * Verify that the guest supports the capability required for the given request method.
806878 * @internal
807879 */
808- assertCapabilityForMethod ( method : Request [ "method" ] ) : void {
880+ assertCapabilityForMethod ( method : AppRequest [ "method" ] ) : void {
809881 // TODO
810882 }
811883
812884 /**
813885 * Verify that a request handler is registered and supported for the given method.
814886 * @internal
815887 */
816- assertRequestHandlerCapability ( method : Request [ "method" ] ) : void {
888+ assertRequestHandlerCapability ( method : AppRequest [ "method" ] ) : void {
817889 // TODO
818890 }
819891
820892 /**
821893 * Verify that the host supports the capability required for the given notification method.
822894 * @internal
823895 */
824- assertNotificationCapability ( method : Notification [ "method" ] ) : void {
896+ assertNotificationCapability ( method : AppNotification [ "method" ] ) : void {
825897 // TODO
826898 }
827899
@@ -939,7 +1011,7 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
9391011 return this . notification ( {
9401012 method : "ui/notifications/host-context-changed" as const ,
9411013 params,
942- } as Notification ) ;
1014+ } ) ;
9431015 }
9441016
9451017 /**
@@ -965,8 +1037,8 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
9651037 * @see {@link sendToolResult } for sending results after execution
9661038 */
9671039 sendToolInput ( params : McpUiToolInputNotification [ "params" ] ) {
968- return this . notification ( < McpUiToolInputNotification > {
969- method : "ui/notifications/tool-input" ,
1040+ return this . notification ( {
1041+ method : "ui/notifications/tool-input" as const ,
9701042 params,
9711043 } ) ;
9721044 }
@@ -999,8 +1071,8 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
9991071 * @see {@link sendToolInput } for sending complete arguments
10001072 */
10011073 sendToolInputPartial ( params : McpUiToolInputPartialNotification [ "params" ] ) {
1002- return this . notification ( < McpUiToolInputPartialNotification > {
1003- method : "ui/notifications/tool-input-partial" ,
1074+ return this . notification ( {
1075+ method : "ui/notifications/tool-input-partial" as const ,
10041076 params,
10051077 } ) ;
10061078 }
@@ -1030,8 +1102,8 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
10301102 * @see {@link sendToolInput } for sending tool arguments before results
10311103 */
10321104 sendToolResult ( params : McpUiToolResultNotification [ "params" ] ) {
1033- return this . notification ( < McpUiToolResultNotification > {
1034- method : "ui/notifications/tool-result" ,
1105+ return this . notification ( {
1106+ method : "ui/notifications/tool-result" as const ,
10351107 params,
10361108 } ) ;
10371109 }
@@ -1067,8 +1139,8 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
10671139 * @see {@link sendToolInput } for sending tool arguments
10681140 */
10691141 sendToolCancelled ( params : McpUiToolCancelledNotification [ "params" ] ) {
1070- return this . notification ( < McpUiToolCancelledNotification > {
1071- method : "ui/notifications/tool-cancelled" ,
1142+ return this . notification ( {
1143+ method : "ui/notifications/tool-cancelled" as const ,
10721144 params,
10731145 } ) ;
10741146 }
@@ -1091,8 +1163,8 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
10911163 sendSandboxResourceReady (
10921164 params : McpUiSandboxResourceReadyNotification [ "params" ] ,
10931165 ) {
1094- return this . notification ( < McpUiSandboxResourceReadyNotification > {
1095- method : "ui/notifications/sandbox-resource-ready" ,
1166+ return this . notification ( {
1167+ method : "ui/notifications/sandbox-resource-ready" as const ,
10961168 params,
10971169 } ) ;
10981170 }
@@ -1126,8 +1198,8 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
11261198 options ?: RequestOptions ,
11271199 ) {
11281200 return this . request (
1129- < McpUiResourceTeardownRequest > {
1130- method : "ui/resource-teardown" ,
1201+ {
1202+ method : "ui/resource-teardown" as const ,
11311203 params,
11321204 } ,
11331205 McpUiResourceTeardownResultSchema ,
0 commit comments