@@ -955,6 +955,39 @@ export class McpServer {
955
955
) ;
956
956
}
957
957
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
+
958
991
/**
959
992
* Removes a tool from the server by name.
960
993
* Does nothing if the tool is not registered.
@@ -1184,6 +1217,18 @@ export type ToolCallback<Args extends undefined | ZodRawShape = undefined> =
1184
1217
) => CallToolResult | Promise < CallToolResult >
1185
1218
: ( extra : RequestHandlerExtra < ServerRequest , ServerNotification > ) => CallToolResult | Promise < CallToolResult > ;
1186
1219
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
+
1187
1232
export type RegisteredTool = {
1188
1233
title ?: string ;
1189
1234
description ?: string ;
@@ -1196,17 +1241,8 @@ export type RegisteredTool = {
1196
1241
enable ( ) : void ;
1197
1242
disable ( ) : void ;
1198
1243
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
1210
1246
remove ( ) : void
1211
1247
} ;
1212
1248
0 commit comments