@@ -816,15 +816,48 @@ export class McpServer {
816
816
) ;
817
817
}
818
818
819
+ /**
820
+ * Enables a tool from the server by name.
821
+ * Does nothing if the tool is not registered.
822
+ */
823
+ enableTool ( name : string ) {
824
+ const tool = this . _registeredTools [ name ] ;
825
+ if ( tool ) {
826
+ tool . enable ( ) ;
827
+ }
828
+ } ;
829
+
830
+ /**
831
+ * Disables a tool from the server by name.
832
+ * Does nothing if the tool is not registered.
833
+ */
834
+ disableTool ( name : string ) {
835
+ const tool = this . _registeredTools [ name ] ;
836
+ if ( tool ) {
837
+ tool . disable ( ) ;
838
+ }
839
+ } ;
840
+
841
+ /**
842
+ * Updates a tool from the server by name.
843
+ * Does nothing if the tool is not registered.
844
+ */
845
+ updateTool < InputArgs extends ZodRawShape , OutputArgs extends ZodRawShape > ( name : string , updates : ToolUpdates < InputArgs , OutputArgs > ) {
846
+ const tool = this . _registeredTools [ name ] ;
847
+ if ( tool ) {
848
+ tool . update ( updates ) ;
849
+ }
850
+ } ;
851
+
819
852
/**
820
853
* Removes a tool from the server by name.
821
854
* Does nothing if the tool is not registered.
822
855
*/
823
856
removeTool ( name : string ) {
824
- const tool = this . _registeredTools [ name ] ;
825
- if ( tool ) {
857
+ const tool = this . _registeredTools [ name ] ;
858
+ if ( tool ) {
826
859
tool . update ( { name : null } ) ;
827
- }
860
+ }
828
861
} ;
829
862
830
863
/**
@@ -1029,29 +1062,33 @@ export type ToolCallback<Args extends undefined | ZodRawShape = undefined> = Arg
1029
1062
) => CallToolResult | Promise < CallToolResult >
1030
1063
: ( extra : RequestHandlerExtra < ServerRequest , ServerNotification > ) => CallToolResult | Promise < CallToolResult > ;
1031
1064
1065
+ export type ToolUpdates < InputArgs extends ZodRawShape , OutputArgs extends ZodRawShape > = {
1066
+ name ?: string | null ,
1067
+ title ?: string ,
1068
+ description ?: string ,
1069
+ paramsSchema ?: InputArgs ,
1070
+ outputSchema ?: OutputArgs ,
1071
+ annotations ?: ToolAnnotations ,
1072
+ _meta ?: Record < string , unknown > ,
1073
+ callback ?: ToolCallback < InputArgs > ,
1074
+ enabled ?: boolean
1075
+ }
1076
+
1032
1077
export type RegisteredTool = {
1033
- title ?: string ;
1034
- description ?: string ;
1035
- inputSchema ?: AnyZodObject ;
1036
- outputSchema ?: AnyZodObject ;
1037
- annotations ?: ToolAnnotations ;
1038
- _meta ?: Record < string , unknown > ;
1039
- callback : ToolCallback < undefined | ZodRawShape > ;
1040
- enabled : boolean ;
1041
- enable ( ) : void ;
1042
- disable ( ) : void ;
1043
- update < InputArgs extends ZodRawShape , OutputArgs extends ZodRawShape > ( updates : {
1044
- name ?: string | null ;
1045
- title ?: string ;
1046
- description ?: string ;
1047
- paramsSchema ?: InputArgs ;
1048
- outputSchema ?: OutputArgs ;
1049
- annotations ?: ToolAnnotations ;
1050
- _meta ?: Record < string , unknown > ;
1051
- callback ?: ToolCallback < InputArgs > ;
1052
- enabled ?: boolean ;
1053
- } ) : void ;
1054
- remove ( ) : void ;
1078
+ title ?: string ;
1079
+ description ?: string ;
1080
+ inputSchema ?: AnyZodObject ;
1081
+ outputSchema ?: AnyZodObject ;
1082
+ annotations ?: ToolAnnotations ;
1083
+ _meta ?: Record < string , unknown > ;
1084
+ callback : ToolCallback < undefined | ZodRawShape > ;
1085
+ enabled : boolean ;
1086
+ enable ( ) : void ;
1087
+ disable ( ) : void ;
1088
+ update < InputArgs extends ZodRawShape , OutputArgs extends ZodRawShape > (
1089
+ updates : ToolUpdates < InputArgs , OutputArgs >
1090
+ ) : void
1091
+ remove ( ) : void
1055
1092
} ;
1056
1093
1057
1094
const EMPTY_OBJECT_JSON_SCHEMA = {
0 commit comments