@@ -58,17 +58,16 @@ export interface MCPServerConfig {
58
58
59
59
export type ServerCapabilities = {
60
60
tools ?: {
61
- enabled : true ;
62
- } ;
63
- schemas ?: {
64
- enabled : true ;
61
+ listChanged ?: true ; // Optional: Indicates support for list change notifications
65
62
} ;
66
63
prompts ?: {
67
- enabled : true ;
64
+ listChanged ? : true ; // Optional: Indicates support for list change notifications
68
65
} ;
69
66
resources ?: {
70
- enabled : true ;
67
+ listChanged ?: true ; // Optional: Indicates support for list change notifications
68
+ subscribe ?: true ; // Optional: Indicates support for resource subscriptions
71
69
} ;
70
+ // Other standard capabilities like 'logging' or 'completion' could be added here if supported
72
71
} ;
73
72
74
73
export class MCPServer {
@@ -83,9 +82,7 @@ export class MCPServer {
83
82
private serverVersion : string ;
84
83
private basePath : string ;
85
84
private transportConfig : TransportConfig ;
86
- private capabilities : ServerCapabilities = {
87
- tools : { enabled : true }
88
- } ;
85
+ private capabilities : ServerCapabilities = { } ; // Initialize as empty
89
86
private isRunning : boolean = false ;
90
87
private transport ?: BaseTransport ;
91
88
private shutdownPromise ?: Promise < void > ;
@@ -188,11 +185,11 @@ export class MCPServer {
188
185
} ) ;
189
186
}
190
187
} ;
188
+ // Removed misplaced semicolon from previous line
191
189
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
+ } ;
196
193
return transport ;
197
194
}
198
195
@@ -236,26 +233,28 @@ export class MCPServer {
236
233
}
237
234
238
235
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 ) => {
240
238
logger . debug ( `Received ListTools request: ${ JSON . stringify ( request ) } ` ) ;
241
-
239
+
242
240
const tools = Array . from ( this . toolsMap . values ( ) ) . map (
243
241
( tool ) => tool . toolDefinition
244
242
) ;
245
-
243
+
246
244
logger . debug ( `Found ${ tools . length } tools to return` ) ;
247
245
logger . debug ( `Tool definitions: ${ JSON . stringify ( tools ) } ` ) ;
248
-
246
+
249
247
const response = {
250
248
tools : tools ,
251
249
nextCursor : undefined
252
250
} ;
253
-
251
+
254
252
logger . debug ( `Sending ListTools response: ${ JSON . stringify ( response ) } ` ) ;
255
253
return response ;
256
254
} ) ;
257
255
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 ) => {
259
258
logger . debug ( `Tool call request received for: ${ request . params . name } ` ) ;
260
259
logger . debug ( `Tool call arguments: ${ JSON . stringify ( request . params . arguments ) } ` ) ;
261
260
@@ -285,6 +284,7 @@ export class MCPServer {
285
284
} ) ;
286
285
287
286
if ( this . capabilities . prompts ) {
287
+ // No request parameter for ListPrompts
288
288
this . server . setRequestHandler ( ListPromptsRequestSchema , async ( ) => {
289
289
return {
290
290
prompts : Array . from ( this . promptsMap . values ( ) ) . map (
@@ -293,7 +293,8 @@ export class MCPServer {
293
293
} ;
294
294
} ) ;
295
295
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 ) => {
297
298
const prompt = this . promptsMap . get ( request . params . name ) ;
298
299
if ( ! prompt ) {
299
300
throw new Error (
@@ -312,6 +313,7 @@ export class MCPServer {
312
313
}
313
314
314
315
if ( this . capabilities . resources ) {
316
+ // No request parameter for ListResources
315
317
this . server . setRequestHandler ( ListResourcesRequestSchema , async ( ) => {
316
318
return {
317
319
resources : Array . from ( this . resourcesMap . values ( ) ) . map (
@@ -320,9 +322,10 @@ export class MCPServer {
320
322
} ;
321
323
} ) ;
322
324
325
+ // TODO: Replace 'any' with the specific inferred request type from the SDK schema if available
323
326
this . server . setRequestHandler (
324
327
ReadResourceRequestSchema ,
325
- async ( request ) => {
328
+ async ( request : any ) => {
326
329
const resource = this . resourcesMap . get ( request . params . uri ) ;
327
330
if ( ! resource ) {
328
331
throw new Error (
@@ -340,7 +343,8 @@ export class MCPServer {
340
343
}
341
344
) ;
342
345
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 ) => {
344
348
const resource = this . resourcesMap . get ( request . params . uri ) ;
345
349
if ( ! resource ) {
346
350
throw new Error ( `Unknown resource: ${ request . params . uri } ` ) ;
@@ -356,7 +360,8 @@ export class MCPServer {
356
360
return { } ;
357
361
} ) ;
358
362
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 ) => {
360
365
const resource = this . resourcesMap . get ( request . params . uri ) ;
361
366
if ( ! resource ) {
362
367
throw new Error ( `Unknown resource: ${ request . params . uri } ` ) ;
@@ -376,12 +381,12 @@ export class MCPServer {
376
381
377
382
private async detectCapabilities ( ) : Promise < ServerCapabilities > {
378
383
if ( await this . promptLoader . hasPrompts ( ) ) {
379
- this . capabilities . prompts = { enabled : true } ;
384
+ this . capabilities . prompts = { } ; // Indicate capability exists, but don't claim listChanged
380
385
logger . debug ( "Prompts capability enabled" ) ;
381
386
}
382
387
383
388
if ( await this . resourceLoader . hasResources ( ) ) {
384
- this . capabilities . resources = { enabled : true } ;
389
+ this . capabilities . resources = { } ; // Indicate capability exists, but don't claim listChanged/subscribe
385
390
logger . debug ( "Resources capability enabled" ) ;
386
391
}
387
392
0 commit comments