MCPcopy Create free account
hub / github.com/modelcontextprotocol/typescript-sdk / cleanup

Function cleanup

src/examples/client/elicitationUrlExample.ts:710–735  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

708}
709
710async function cleanup(): Promise<void> {
711 if (client && transport) {
712 try {
713 // First try to terminate the session gracefully
714 if (transport.sessionId) {
715 try {
716 console.log('Terminating session before exit...');
717 await transport.terminateSession();
718 console.log('Session terminated successfully');
719 } catch (error) {
720 console.error('Error terminating session:', error);
721 }
722 }
723
724 // Then close the transport
725 await transport.close();
726 } catch (error) {
727 console.error('Error closing transport:', error);
728 }
729 }
730
731 process.stdin.setRawMode(false);
732 readline.close();
733 console.log('\nGoodbye!');
734 process.exit(0);
735}
736
737async function callPaymentConfirmTool(): Promise<void> {
738 console.log('Calling payment-confirm tool...');

Callers 2

commandLoopFunction · 0.70

Calls 2

terminateSessionMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…