@@ -27,17 +27,30 @@ export abstract class ToolBase {
27
27
28
28
protected abstract argsShape : ZodRawShape ;
29
29
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
+ }
31
46
32
47
protected abstract execute ( ...args : Parameters < ToolCallback < typeof this . argsShape > > ) : Promise < CallToolResult > ;
33
48
34
49
constructor (
35
50
protected readonly session : Session ,
36
51
protected readonly config : UserConfig ,
37
52
protected readonly telemetry : Telemetry
38
- ) {
39
- this . updateAnnotations ( ) ;
40
- }
53
+ ) { }
41
54
42
55
public register ( server : McpServer ) : void {
43
56
if ( ! this . verifyAllowed ( ) ) {
@@ -136,19 +149,6 @@ export abstract class ToolBase {
136
149
} ;
137
150
}
138
151
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
-
152
152
protected abstract resolveTelemetryMetadata (
153
153
...args : Parameters < ToolCallback < typeof this . argsShape > >
154
154
) : TelemetryToolMetadata ;
0 commit comments