Skip to content

Commit f759cd3

Browse files
committed
validate annotations
1 parent 21c0fa3 commit f759cd3

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

tests/integration/helpers.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ export function validateToolMetadata(
206206
expectDefined(tool);
207207
expect(tool.description).toBe(description);
208208

209-
expectDefined(tool.annotations);
210-
expect(tool.annotations.title).toBe(name);
211-
expect(tool.annotations.description).toBe(description);
209+
validateToolAnnotations(tool, name, description);
212210
const toolParameters = getParameters(tool);
213211
expect(toolParameters).toHaveLength(parameters.length);
214212
expect(toolParameters).toIncludeAllMembers(parameters);
@@ -243,3 +241,25 @@ export function expectDefined<T>(arg: T): asserts arg is Exclude<T, undefined |
243241
expect(arg).toBeDefined();
244242
expect(arg).not.toBeNull();
245243
}
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

Comments
 (0)