Add ui/notifications/request-teardown notification for view-initiated termination (#215)

* Add ui/close-resource request for UI to initiate termination

* Add missing METHOD export

* Fix typo in remaining ui/request-close

* Align spec terminology to teardown/termination instead of close/clearnup

* Implement final comments

* Removing view behavior on initiation of request termination
This commit is contained in:
Frédéric Barthelet 2026-03-19 21:01:59 +01:00 • committed by GitHub
commit c026b398a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 195 additions and 5 deletions

View file

@ -4074,6 +4074,23 @@
"required": ["mode"],
"additionalProperties": {}
},
"McpUiRequestTeardownNotification": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"method": {
"type": "string",
"const": "ui/notifications/request-teardown"
},
"params": {
"type": "object",
"properties": {},
"additionalProperties": false
}
},
"required": ["method"],
"additionalProperties": false
},
"McpUiResourceCsp": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",

View file

@ -91,6 +91,10 @@ export type McpUiSupportedContentBlockModalitiesSchemaInferredType = z.infer<
typeof generated.McpUiSupportedContentBlockModalitiesSchema
>;
export type McpUiRequestTeardownNotificationSchemaInferredType = z.infer<
typeof generated.McpUiRequestTeardownNotificationSchema
>;
export type McpUiHostCapabilitiesSchemaInferredType = z.infer<
typeof generated.McpUiHostCapabilitiesSchema
>;
@ -255,6 +259,12 @@ expectType<spec.McpUiSupportedContentBlockModalities>(
expectType<McpUiSupportedContentBlockModalitiesSchemaInferredType>(
{} as spec.McpUiSupportedContentBlockModalities,
);
expectType<spec.McpUiRequestTeardownNotification>(
{} as McpUiRequestTeardownNotificationSchemaInferredType,
);
expectType<McpUiRequestTeardownNotificationSchemaInferredType>(
{} as spec.McpUiRequestTeardownNotification,
);
expectType<spec.McpUiHostCapabilities>(
{} as McpUiHostCapabilitiesSchemaInferredType,
);

View file

@ -478,6 +478,19 @@ export const McpUiSupportedContentBlockModalitiesSchema = z.object({
.describe("Host supports structured content."),
});
/**
* @description Notification for app-initiated teardown request (View -> Host).
* Views send this to request that the host tear them down. The host decides
* whether to proceed - if approved, the host will send
* `ui/resource-teardown` to allow the view to perform cleanup before being
* unmounted.
* @see {@link app.App.requestTeardown} for the app method that sends this
*/
export const McpUiRequestTeardownNotificationSchema = z.object({
method: z.literal("ui/notifications/request-teardown"),
params: z.object({}).optional(),
});
/**
* @description Capabilities supported by the host application.
* @see {@link McpUiInitializeResult `McpUiInitializeResult`} for the initialization result that includes these capabilities