Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ namespace WebMCP {
* @default false
*/
untrustedContentHint?: boolean;
/**
* If `true`, indicates that executing the tool will result in consequential actions that are significant, real-world, or non-reversible, ex: booking a flight, transferring money.
* @default false
*/
consequentialHint?: boolean;
}

/**
Expand Down
21 changes: 21 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,24 @@ test('rejects a callback that disagrees with its schema', () => {
execute: (input: { query: number }) => input.query,
});
});

test('supports tool annotations', () => {
void document.modelContext?.registerTool({
name: 'annotated-tool',
description: 'Defines all tool annotations.',
annotations: {
readOnlyHint: true,
untrustedContentHint: false,
consequentialHint: false,
},
execute: () => {},
});

expectTypeOf<WebMCP.ToolAnnotations>().toEqualTypeOf<{
readOnlyHint?: boolean;
untrustedContentHint?: boolean;
consequentialHint?: boolean;
}>();
expectTypeOf<WebMCP.ModelContextTool['annotations']>().toEqualTypeOf<WebMCP.ToolAnnotations | undefined>();
expectTypeOf<WebMCP.RegisteredTool['annotations']>().toEqualTypeOf<WebMCP.ToolAnnotations | undefined>();
});