File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ const newServer = async ({
6969 }
7070 }
7171
72+ const mcpClientInfo =
73+ typeof req . body ?. params ?. clientInfo ?. name === 'string' ?
74+ { name : req . body . params . clientInfo . name , version : String ( req . body . params . clientInfo . version ?? '' ) }
75+ : undefined ;
76+
7277 await initMcpServer ( {
7378 server : server ,
7479 mcpOptions : effectiveMcpOptions ,
@@ -79,12 +84,13 @@ const newServer = async ({
7984 stainlessApiKey : stainlessApiKey ,
8085 upstreamClientEnvs,
8186 mcpSessionId : ( req as any ) . mcpSessionId ,
82- mcpClientInfo :
83- typeof req . body ?. params ?. clientInfo ?. name === 'string' ?
84- { name : req . body . params . clientInfo . name , version : String ( req . body . params . clientInfo . version ?? '' ) }
85- : undefined ,
87+ mcpClientInfo,
8688 } ) ;
8789
90+ if ( mcpClientInfo ) {
91+ getLogger ( ) . info ( { mcpSessionId : ( req as any ) . mcpSessionId , mcpClientInfo } , 'MCP client connected' ) ;
92+ }
93+
8894 return server ;
8995} ;
9096
@@ -154,6 +160,9 @@ export const streamableHTTPApp = ({
154160 app . use (
155161 pinoHttp ( {
156162 logger : getLogger ( ) ,
163+ customProps : ( req ) => ( {
164+ mcpSessionId : ( req as any ) . mcpSessionId ,
165+ } ) ,
157166 customLogLevel : ( req , res ) => {
158167 if ( res . statusCode >= 500 ) {
159168 return 'error' ;
You can’t perform that action at this time.
0 commit comments