@@ -27,17 +27,30 @@ export abstract class ToolBase {
2727
2828 protected abstract argsShape : ZodRawShape ;
2929
30- protected abstract annotations : ToolAnnotations ;
30+ protected get annotations ( ) : ToolAnnotations {
31+ const annotations : ToolAnnotations = {
32+ title : this . name ,
33+ description : this . description ,
34+ } ;
35+
36+ if ( this . operationType === "read" || this . operationType === "metadata" ) {
37+ annotations . readOnlyHint = true ;
38+ }
39+
40+ if ( this . operationType === "delete" ) {
41+ annotations . destructiveHint = true ;
42+ }
43+
44+ return annotations ;
45+ }
3146
3247 protected abstract execute ( ...args : Parameters < ToolCallback < typeof this . argsShape > > ) : Promise < CallToolResult > ;
3348
3449 constructor (
3550 protected readonly session : Session ,
3651 protected readonly config : UserConfig ,
3752 protected readonly telemetry : Telemetry
38- ) {
39- this . updateAnnotations ( ) ;
40- }
53+ ) { }
4154
4255 public register ( server : McpServer ) : void {
4356 if ( ! this . verifyAllowed ( ) ) {
@@ -136,19 +149,6 @@ export abstract class ToolBase {
136149 } ;
137150 }
138151
139- protected updateAnnotations ( ) {
140- this . annotations : ToolAnnotationsSchema = {
141- description : this . description ,
142- } ;
143- if ( this . operationType === "read" ) {
144- this . annotations . readOnlyHint = true ;
145- }
146-
147- if ( this . operationType == "delete" ) {
148- this . annotations . destructiveHint = true ;
149- }
150- }
151-
152152 protected abstract resolveTelemetryMetadata (
153153 ...args : Parameters < ToolCallback < typeof this . argsShape > >
154154 ) : TelemetryToolMetadata ;
0 commit comments