@@ -14,7 +14,7 @@ const JSON_RPC_ERROR_CODE_SESSION_ID_INVALID = -32002;
1414const JSON_RPC_ERROR_CODE_SESSION_NOT_FOUND = - 32003 ;
1515const JSON_RPC_ERROR_CODE_INVALID_REQUEST = - 32004 ;
1616
17- function promiseHandler (
17+ function withErrorHandling (
1818 fn : ( req : express . Request , res : express . Response , next : express . NextFunction ) => Promise < void >
1919) {
2020 return ( req : express . Request , res : express . Response , next : express . NextFunction ) => {
@@ -88,7 +88,7 @@ export class StreamableHttpRunner extends TransportRunnerBase {
8888
8989 app . post (
9090 "/mcp" ,
91- promiseHandler ( async ( req : express . Request , res : express . Response ) => {
91+ withErrorHandling ( async ( req : express . Request , res : express . Response ) => {
9292 const sessionId = req . headers [ "mcp-session-id" ] ;
9393 if ( sessionId ) {
9494 await handleSessionRequest ( req , res ) ;
@@ -141,8 +141,8 @@ export class StreamableHttpRunner extends TransportRunnerBase {
141141 } )
142142 ) ;
143143
144- app . get ( "/mcp" , promiseHandler ( handleSessionRequest ) ) ;
145- app . delete ( "/mcp" , promiseHandler ( handleSessionRequest ) ) ;
144+ app . get ( "/mcp" , withErrorHandling ( handleSessionRequest ) ) ;
145+ app . delete ( "/mcp" , withErrorHandling ( handleSessionRequest ) ) ;
146146
147147 this . httpServer = await new Promise < http . Server > ( ( resolve , reject ) => {
148148 const result = app . listen ( this . userConfig . httpPort , this . userConfig . httpHost , ( err ?: Error ) => {
0 commit comments