@@ -13,10 +13,12 @@ import {
1313 Implementation ,
1414 ListToolsRequest ,
1515 ListToolsRequestSchema ,
16+ ListToolsResult ,
1617 LoggingMessageNotification ,
1718 PingRequestSchema ,
1819 Request ,
1920 Result ,
21+ Tool ,
2022 ToolAnnotations ,
2123 ToolListChangedNotification ,
2224} from "@modelcontextprotocol/sdk/types.js" ;
@@ -57,7 +59,7 @@ import {
5759 RegisteredTool ,
5860 ToolCallback ,
5961} from "@modelcontextprotocol/sdk/server/mcp.js" ;
60- import { ZodSchema } from "zod" ;
62+ import { z , ZodSchema } from "zod/v4 " ;
6163import { zodToJsonSchema } from "zod-to-json-schema" ;
6264
6365export { PostMessageTransport } from "./message-transport" ;
@@ -349,17 +351,24 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
349351 }
350352 return tool . callback ( params . arguments as any , extra ) ;
351353 } ;
352- this . onlisttools = async ( ) => {
353- const tools = Object . entries ( this . _registeredTools ) . map (
354- ( [ name , tool ] ) => ( {
355- name,
356- description : tool . description ,
357- inputSchema :
358- tool . inputSchema && "shape" in tool . inputSchema
359- ? zodToJsonSchema ( tool . inputSchema as any )
360- : tool . inputSchema || { type : "object" as const , properties : { } } ,
361- } ) ,
362- ) ;
354+ this . onlisttools = async ( _params , _extra ) => {
355+ const tools : Tool [ ] = Object . entries ( this . _registeredTools )
356+ . filter ( ( [ _ , tool ] ) => tool . enabled )
357+ . map (
358+ ( [ name , tool ] ) =>
359+ < Tool > {
360+ name,
361+ description : tool . description ,
362+ inputSchema : tool . inputSchema
363+ ? z . toJSONSchema ( tool . inputSchema as ZodSchema )
364+ : undefined ,
365+ outputSchema : tool . outputSchema
366+ ? z . toJSONSchema ( tool . outputSchema as ZodSchema )
367+ : undefined ,
368+ annotations : tool . annotations ,
369+ _meta : tool . _meta ,
370+ } ,
371+ ) ;
363372 return { tools } ;
364373 } ;
365374 }
@@ -779,7 +788,7 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
779788 callback : (
780789 params : ListToolsRequest [ "params" ] ,
781790 extra : RequestHandlerExtra ,
782- ) => Promise < any > ,
791+ ) => Promise < ListToolsResult > ,
783792 ) {
784793 this . setRequestHandler ( ListToolsRequestSchema , ( request , extra ) =>
785794 callback ( request . params , extra ) ,
0 commit comments