@@ -206,9 +206,7 @@ export function validateToolMetadata(
206
206
expectDefined ( tool ) ;
207
207
expect ( tool . description ) . toBe ( description ) ;
208
208
209
- expectDefined ( tool . annotations ) ;
210
- expect ( tool . annotations . title ) . toBe ( name ) ;
211
- expect ( tool . annotations . description ) . toBe ( description ) ;
209
+ validateToolAnnotations ( tool , name , description ) ;
212
210
const toolParameters = getParameters ( tool ) ;
213
211
expect ( toolParameters ) . toHaveLength ( parameters . length ) ;
214
212
expect ( toolParameters ) . toIncludeAllMembers ( parameters ) ;
@@ -243,3 +241,25 @@ export function expectDefined<T>(arg: T): asserts arg is Exclude<T, undefined |
243
241
expect ( arg ) . toBeDefined ( ) ;
244
242
expect ( arg ) . not . toBeNull ( ) ;
245
243
}
244
+
245
+ function validateToolAnnotations ( tool : ToolInfo , name : string , description : string ) : void {
246
+ expectDefined ( tool . annotations ) ;
247
+ expect ( tool . annotations . title ) . toBe ( name ) ;
248
+ expect ( tool . annotations . description ) . toBe ( description ) ;
249
+
250
+ switch ( tool . operationType ) {
251
+ case "read" :
252
+ case "metadata" :
253
+ expect ( tool . annotations . readOnlyHint ) . toBe ( true ) ;
254
+ expect ( tool . annotations . destructiveHint ) . toBe ( false ) ;
255
+ break ;
256
+ case "delete" :
257
+ expect ( tool . annotations . readOnlyHint ) . toBe ( false ) ;
258
+ expect ( tool . annotations . destructiveHint ) . toBe ( true ) ;
259
+ break ;
260
+ case "create" :
261
+ case "update" :
262
+ expect ( tool . annotations . readOnlyHint ) . toBe ( false ) ;
263
+ expect ( tool . annotations . destructiveHint ) . toBe ( false ) ;
264
+ }
265
+ }
0 commit comments