@@ -17,6 +17,7 @@ import type {
1717 Resource ,
1818 ResourceTemplateReference ,
1919 Result ,
20+ SdkLogger ,
2021 ServerContext ,
2122 StandardSchemaWithJSON ,
2223 Tool ,
@@ -68,8 +69,10 @@ export class McpServer {
6869 } = { } ;
6970 private _registeredTools : { [ name : string ] : RegisteredTool } = { } ;
7071 private _registeredPrompts : { [ name : string ] : RegisteredPrompt } = { } ;
72+ private readonly _logger : SdkLogger ;
7173
7274 constructor ( serverInfo : Implementation , options ?: ServerOptions ) {
75+ this . _logger = options ?. logger ?? console ;
7376 this . server = new Server ( serverInfo , options ) ;
7477
7578 // Per the MCP spec, a server that declares a primitive capability MUST respond to its
@@ -141,7 +144,7 @@ export class McpServer {
141144 title : tool . title ,
142145 description : tool . description ,
143146 inputSchema : tool . inputSchema
144- ? ( standardSchemaToJsonSchema ( tool . inputSchema , 'input' ) as Tool [ 'inputSchema' ] )
147+ ? ( standardSchemaToJsonSchema ( tool . inputSchema , 'input' , this . _logger ) as Tool [ 'inputSchema' ] )
145148 : EMPTY_OBJECT_JSON_SCHEMA ,
146149 annotations : tool . annotations ,
147150 icons : tool . icons ,
@@ -150,7 +153,11 @@ export class McpServer {
150153 } ;
151154
152155 if ( tool . outputSchema ) {
153- toolDefinition . outputSchema = standardSchemaToJsonSchema ( tool . outputSchema , 'output' ) as Tool [ 'outputSchema' ] ;
156+ toolDefinition . outputSchema = standardSchemaToJsonSchema (
157+ tool . outputSchema ,
158+ 'output' ,
159+ this . _logger
160+ ) as Tool [ 'outputSchema' ] ;
154161 }
155162
156163 return toolDefinition ;
@@ -709,7 +716,7 @@ export class McpServer {
709716 handler : AnyToolHandler < StandardSchemaWithJSON | undefined >
710717 ) : RegisteredTool {
711718 // Validate tool name according to SEP specification
712- validateAndWarnToolName ( name ) ;
719+ validateAndWarnToolName ( name , this . _logger ) ;
713720
714721 // Track current handler for executor regeneration
715722 let currentHandler = handler ;
@@ -732,7 +739,7 @@ export class McpServer {
732739 update : updates => {
733740 if ( updates . name !== undefined && updates . name !== name ) {
734741 if ( typeof updates . name === 'string' ) {
735- validateAndWarnToolName ( updates . name ) ;
742+ validateAndWarnToolName ( updates . name , this . _logger ) ;
736743 }
737744 delete this . _registeredTools [ name ] ;
738745 if ( updates . name ) this . _registeredTools [ updates . name ] = registeredTool ;
0 commit comments