File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
basic-server-vanillajs/src Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 11/**
22 * @file App that demonstrates a few features using MCP Apps SDK + React.
33 */
4- import type { App } from "@modelcontextprotocol/ext-apps" ;
4+ import type { App , McpUiResourceTeardownResult } from "@modelcontextprotocol/ext-apps" ;
55import { useApp } from "@modelcontextprotocol/ext-apps/react" ;
66import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
77import { StrictMode , useCallback , useEffect , useState } from "react" ;
@@ -35,6 +35,12 @@ function GetTimeApp() {
3535 appInfo : IMPLEMENTATION ,
3636 capabilities : { } ,
3737 onAppCreated : ( app ) => {
38+ app . onteardown = async ( ) => {
39+ log . info ( "App is being torn down" ) ;
40+ await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ; // Simulate cleanup work
41+ log . info ( "App teardown complete" ) ;
42+ return { } ;
43+ } ;
3844 app . ontoolinput = async ( input ) => {
3945 log . info ( "Received tool call input:" , input ) ;
4046 } ;
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ const openLinkBtn = document.getElementById("open-link-btn")!;
3838// Create app instance
3939const app = new App ( { name : "Get Time App" , version : "1.0.0" } ) ;
4040
41+ app . onteardown = async ( ) => {
42+ log . info ( "App is being torn down" ) ;
43+ await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ; // Simulate cleanup work
44+ log . info ( "App teardown complete" ) ;
45+ return { } ;
46+ } ;
4147
4248// Register handlers BEFORE connecting
4349app . ontoolinput = ( params ) => {
You can’t perform that action at this time.
0 commit comments