@@ -54,7 +54,7 @@ export type Tool<
5454 Params extends z . ZodObject < any > = z . ZodObject < any > ,
5555 Result = unknown ,
5656> = {
57- description : string ;
57+ description : Prop < string > ;
5858 annotations ?: Annotations ;
5959 parameters : Params ;
6060 execute ( params : z . infer < Params > ) : Promise < Result > ;
@@ -436,24 +436,30 @@ export function createMcpServer(options: McpServerOptions) {
436436 ListToolsRequestSchema ,
437437 async ( ) : Promise < ListToolsResult > => {
438438 const tools = await getTools ( ) ;
439- return {
440- tools : Object . entries ( tools ) . map (
441- ( [ name , { description, annotations, parameters } ] ) => {
442- const inputSchema = zodToJsonSchema ( parameters ) ;
443439
444- if ( ! ( 'properties' in inputSchema ) ) {
445- throw new Error ( 'tool parameters must be a ZodObject' ) ;
440+ return {
441+ tools : await Promise . all (
442+ Object . entries ( tools ) . map (
443+ async ( [ name , { description, annotations, parameters } ] ) => {
444+ const inputSchema = zodToJsonSchema ( parameters ) ;
445+
446+ if ( ! ( 'properties' in inputSchema ) ) {
447+ throw new Error ( 'tool parameters must be a ZodObject' ) ;
448+ }
449+
450+ return {
451+ name,
452+ description :
453+ typeof description === 'function'
454+ ? await description ( )
455+ : description ,
456+ annotations,
457+ inputSchema,
458+ } ;
446459 }
447-
448- return {
449- name,
450- description,
451- annotations,
452- inputSchema,
453- } ;
454- }
460+ )
455461 ) ,
456- } ;
462+ } satisfies ListToolsResult ;
457463 }
458464 ) ;
459465
@@ -471,7 +477,6 @@ export function createMcpServer(options: McpServerOptions) {
471477 if ( ! tool ) {
472478 throw new Error ( 'tool not found' ) ;
473479 }
474-
475480 const args = tool . parameters
476481 . strict ( )
477482 . parse ( request . params . arguments ?? { } ) ;
0 commit comments