@@ -955,6 +955,39 @@ export class McpServer {
955955 ) ;
956956 }
957957
958+ /**
959+ * Enables a tool from the server by name.
960+ * Does nothing if the tool is not registered.
961+ */
962+ enableTool ( name : string ) {
963+ const tool = this . _registeredTools [ name ] ;
964+ if ( tool ) {
965+ tool . enable ( ) ;
966+ }
967+ } ;
968+
969+ /**
970+ * Disables a tool from the server by name.
971+ * Does nothing if the tool is not registered.
972+ */
973+ disableTool ( name : string ) {
974+ const tool = this . _registeredTools [ name ] ;
975+ if ( tool ) {
976+ tool . disable ( ) ;
977+ }
978+ } ;
979+
980+ /**
981+ * Updates a tool from the server by name.
982+ * Does nothing if the tool is not registered.
983+ */
984+ updateTool < InputArgs extends ZodRawShape , OutputArgs extends ZodRawShape > ( name : string , updates : ToolUpdates < InputArgs , OutputArgs > ) {
985+ const tool = this . _registeredTools [ name ] ;
986+ if ( tool ) {
987+ tool . update ( updates ) ;
988+ }
989+ } ;
990+
958991 /**
959992 * Removes a tool from the server by name.
960993 * Does nothing if the tool is not registered.
@@ -1184,6 +1217,18 @@ export type ToolCallback<Args extends undefined | ZodRawShape = undefined> =
11841217 ) => CallToolResult | Promise < CallToolResult >
11851218 : ( extra : RequestHandlerExtra < ServerRequest , ServerNotification > ) => CallToolResult | Promise < CallToolResult > ;
11861219
1220+ export type ToolUpdates < InputArgs extends ZodRawShape , OutputArgs extends ZodRawShape > = {
1221+ name ?: string | null ,
1222+ title ?: string ,
1223+ description ?: string ,
1224+ paramsSchema ?: InputArgs ,
1225+ outputSchema ?: OutputArgs ,
1226+ annotations ?: ToolAnnotations ,
1227+ _meta ?: Record < string , unknown > ,
1228+ callback ?: ToolCallback < InputArgs > ,
1229+ enabled ?: boolean
1230+ }
1231+
11871232export type RegisteredTool = {
11881233 title ?: string ;
11891234 description ?: string ;
@@ -1196,17 +1241,8 @@ export type RegisteredTool = {
11961241 enable ( ) : void ;
11971242 disable ( ) : void ;
11981243 update < InputArgs extends ZodRawShape , OutputArgs extends ZodRawShape > (
1199- updates : {
1200- name ?: string | null ,
1201- title ?: string ,
1202- description ?: string ,
1203- paramsSchema ?: InputArgs ,
1204- outputSchema ?: OutputArgs ,
1205- annotations ?: ToolAnnotations ,
1206- _meta ?: Record < string , unknown > ,
1207- callback ?: ToolCallback < InputArgs > ,
1208- enabled ?: boolean
1209- } ) : void
1244+ updates : ToolUpdates < InputArgs , OutputArgs >
1245+ ) : void
12101246 remove ( ) : void
12111247} ;
12121248
0 commit comments