@@ -58,17 +58,16 @@ export interface MCPServerConfig {
5858
5959export type ServerCapabilities = {
6060 tools ?: {
61- enabled : true ;
62- } ;
63- schemas ?: {
64- enabled : true ;
61+ listChanged ?: true ; // Optional: Indicates support for list change notifications
6562 } ;
6663 prompts ?: {
67- enabled : true ;
64+ listChanged ? : true ; // Optional: Indicates support for list change notifications
6865 } ;
6966 resources ?: {
70- enabled : true ;
67+ listChanged ?: true ; // Optional: Indicates support for list change notifications
68+ subscribe ?: true ; // Optional: Indicates support for resource subscriptions
7169 } ;
70+ // Other standard capabilities like 'logging' or 'completion' could be added here if supported
7271} ;
7372
7473export class MCPServer {
@@ -83,9 +82,7 @@ export class MCPServer {
8382 private serverVersion : string ;
8483 private basePath : string ;
8584 private transportConfig : TransportConfig ;
86- private capabilities : ServerCapabilities = {
87- tools : { enabled : true }
88- } ;
85+ private capabilities : ServerCapabilities = { } ; // Initialize as empty
8986 private isRunning : boolean = false ;
9087 private transport ?: BaseTransport ;
9188 private shutdownPromise ?: Promise < void > ;
@@ -188,11 +185,11 @@ export class MCPServer {
188185 } ) ;
189186 }
190187 } ;
188+ // Removed misplaced semicolon from previous line
191189
192- transport . onerror = ( error ) => {
193- logger . error ( `Transport (${ transport . type } ) error: ${ error . message } \n${ error . stack } ` ) ;
194- } ;
195-
190+ transport . onerror = ( error : Error ) => {
191+ logger . error ( `Transport (${ transport . type } ) error: ${ error . message } \n${ error . stack } ` ) ;
192+ } ;
196193 return transport ;
197194 }
198195
@@ -236,26 +233,28 @@ export class MCPServer {
236233 }
237234
238235 private setupHandlers ( ) {
239- this . server . setRequestHandler ( ListToolsRequestSchema , async ( request ) => {
236+ // TODO: Replace 'any' with the specific inferred request type from the SDK schema if available
237+ this . server . setRequestHandler ( ListToolsRequestSchema , async ( request : any ) => {
240238 logger . debug ( `Received ListTools request: ${ JSON . stringify ( request ) } ` ) ;
241-
239+
242240 const tools = Array . from ( this . toolsMap . values ( ) ) . map (
243241 ( tool ) => tool . toolDefinition
244242 ) ;
245-
243+
246244 logger . debug ( `Found ${ tools . length } tools to return` ) ;
247245 logger . debug ( `Tool definitions: ${ JSON . stringify ( tools ) } ` ) ;
248-
246+
249247 const response = {
250248 tools : tools ,
251249 nextCursor : undefined
252250 } ;
253-
251+
254252 logger . debug ( `Sending ListTools response: ${ JSON . stringify ( response ) } ` ) ;
255253 return response ;
256254 } ) ;
257255
258- this . server . setRequestHandler ( CallToolRequestSchema , async ( request ) => {
256+ // TODO: Replace 'any' with the specific inferred request type from the SDK schema if available
257+ this . server . setRequestHandler ( CallToolRequestSchema , async ( request : any ) => {
259258 logger . debug ( `Tool call request received for: ${ request . params . name } ` ) ;
260259 logger . debug ( `Tool call arguments: ${ JSON . stringify ( request . params . arguments ) } ` ) ;
261260
@@ -285,6 +284,7 @@ export class MCPServer {
285284 } ) ;
286285
287286 if ( this . capabilities . prompts ) {
287+ // No request parameter for ListPrompts
288288 this . server . setRequestHandler ( ListPromptsRequestSchema , async ( ) => {
289289 return {
290290 prompts : Array . from ( this . promptsMap . values ( ) ) . map (
@@ -293,7 +293,8 @@ export class MCPServer {
293293 } ;
294294 } ) ;
295295
296- this . server . setRequestHandler ( GetPromptRequestSchema , async ( request ) => {
296+ // TODO: Replace 'any' with the specific inferred request type from the SDK schema if available
297+ this . server . setRequestHandler ( GetPromptRequestSchema , async ( request : any ) => {
297298 const prompt = this . promptsMap . get ( request . params . name ) ;
298299 if ( ! prompt ) {
299300 throw new Error (
@@ -312,6 +313,7 @@ export class MCPServer {
312313 }
313314
314315 if ( this . capabilities . resources ) {
316+ // No request parameter for ListResources
315317 this . server . setRequestHandler ( ListResourcesRequestSchema , async ( ) => {
316318 return {
317319 resources : Array . from ( this . resourcesMap . values ( ) ) . map (
@@ -320,9 +322,10 @@ export class MCPServer {
320322 } ;
321323 } ) ;
322324
325+ // TODO: Replace 'any' with the specific inferred request type from the SDK schema if available
323326 this . server . setRequestHandler (
324327 ReadResourceRequestSchema ,
325- async ( request ) => {
328+ async ( request : any ) => {
326329 const resource = this . resourcesMap . get ( request . params . uri ) ;
327330 if ( ! resource ) {
328331 throw new Error (
@@ -340,7 +343,8 @@ export class MCPServer {
340343 }
341344 ) ;
342345
343- this . server . setRequestHandler ( SubscribeRequestSchema , async ( request ) => {
346+ // TODO: Replace 'any' with the specific inferred request type from the SDK schema if available
347+ this . server . setRequestHandler ( SubscribeRequestSchema , async ( request : any ) => {
344348 const resource = this . resourcesMap . get ( request . params . uri ) ;
345349 if ( ! resource ) {
346350 throw new Error ( `Unknown resource: ${ request . params . uri } ` ) ;
@@ -356,7 +360,8 @@ export class MCPServer {
356360 return { } ;
357361 } ) ;
358362
359- this . server . setRequestHandler ( UnsubscribeRequestSchema , async ( request ) => {
363+ // TODO: Replace 'any' with the specific inferred request type from the SDK schema if available
364+ this . server . setRequestHandler ( UnsubscribeRequestSchema , async ( request : any ) => {
360365 const resource = this . resourcesMap . get ( request . params . uri ) ;
361366 if ( ! resource ) {
362367 throw new Error ( `Unknown resource: ${ request . params . uri } ` ) ;
@@ -376,12 +381,12 @@ export class MCPServer {
376381
377382 private async detectCapabilities ( ) : Promise < ServerCapabilities > {
378383 if ( await this . promptLoader . hasPrompts ( ) ) {
379- this . capabilities . prompts = { enabled : true } ;
384+ this . capabilities . prompts = { } ; // Indicate capability exists, but don't claim listChanged
380385 logger . debug ( "Prompts capability enabled" ) ;
381386 }
382387
383388 if ( await this . resourceLoader . hasResources ( ) ) {
384- this . capabilities . resources = { enabled : true } ;
389+ this . capabilities . resources = { } ; // Indicate capability exists, but don't claim listChanged/subscribe
385390 logger . debug ( "Resources capability enabled" ) ;
386391 }
387392
0 commit comments