You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tool annotations provide additional metadata about a tool's behavior, helping clients understand how to present and manage tools. These annotations are hints that describe the nature and impact of a tool.
284
+
285
+
```ruby
286
+
classWebSearchTool < FastMcp::Tool
287
+
description 'Search the web for information'
288
+
289
+
annotations(
290
+
title:'Web Search', # Human-readable title for the tool
291
+
read_only_hint:true, # Indicates the tool doesn't modify its environment
292
+
open_world_hint:true# The tool interacts with external entities
|`title`| string | - | A human-readable title for the tool, useful for UI display |
310
+
|`read_only_hint`| boolean | false | If true, indicates the tool does not modify its environment |
311
+
|`destructive_hint`| boolean | true | If true, the tool may perform destructive updates (only meaningful when `read_only_hint` is false) |
312
+
|`idempotent_hint`| boolean | false | If true, calling the tool repeatedly with the same arguments has no additional effect |
313
+
|`open_world_hint`| boolean | true | If true, the tool may interact with an "open world" of external entities |
314
+
315
+
Example with all annotations:
316
+
317
+
```ruby
318
+
classDeleteFileTool < FastMcp::Tool
319
+
description 'Delete a file from the filesystem'
320
+
321
+
annotations(
322
+
title:'Delete File',
323
+
read_only_hint:false, # This tool modifies the filesystem
324
+
destructive_hint:true, # Deleting files is destructive
325
+
idempotent_hint:true, # Deleting the same file twice has no additional effect
326
+
open_world_hint:false# Only interacts with the local filesystem
327
+
)
328
+
329
+
arguments do
330
+
required(:path).filled(:string).description('File path to delete')
331
+
end
332
+
333
+
defcall(path:)
334
+
File.delete(path) ifFile.exist?(path)
335
+
"File deleted: #{path}"
336
+
end
337
+
end
338
+
```
339
+
340
+
**Important**: Annotations are hints and not guaranteed to provide a faithful description of tool behavior. Clients should never make security-critical decisions based solely on annotations.
341
+
280
342
### Tool hidden arguments
281
343
If need be, we can register arguments that won't show up in the tools/list call but can still be used in the tool when provided.
282
344
This might be useful when calling from another tool, or when the client is made aware of this argument from the context.
0 commit comments