Skip to content

Commit f025054

Browse files
committed
Refactor ToolAnnotations:
- simplify data model for operational properties, to facilitate extensibility (at the cost of correctness by construction) - added documentation for `annotations` property in tool definitions - added language in `Security and Trust & Safety` section re trusting annotations
1 parent 3a96a59 commit f025054

File tree

4 files changed

+51
-59
lines changed

4 files changed

+51
-59
lines changed

docs/specification/draft/_index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ considerations that all implementors must carefully address.
102102
3. **Tool Safety**
103103

104104
- Tools represent arbitrary code execution and must be treated with appropriate
105-
caution
105+
caution.
106+
- In particular, descriptions of tool behavior such as annotations should be
107+
considered untrusted, unless obtained from a trusted server.
106108
- Hosts must obtain explicit user consent before invoking any tool
107109
- Users should understand what each tool does before authorizing its use
108110

docs/specification/draft/server/tools.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ A tool definition includes:
181181
- `name`: Unique identifier for the tool
182182
- `description`: Human-readable description of functionality
183183
- `inputSchema`: JSON Schema defining expected parameters
184+
- `annotations`: optional properties describing tool behavior
185+
186+
{{< callout type="warning" >}} For trust & safety and security, clients **MUST** consider tool annotations to be untrusted unless they come from trusted servers.
184187

185188
### Tool Result
186189

schema/draft/schema.json

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,45 +1985,22 @@
19851985
"type": "object"
19861986
},
19871987
"ToolAnnotations": {
1988-
"description": "Additional properties describing a Tool to clients.",
1988+
"description": "Additional properties describing a Tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**. \nThey are not guaranteed to provide a faithful description of \ntool behavior (including descriptive properties like `title`).\n\nClients should never make tool use decisions based on ToolAnnotations\nreceived from untrusted servers.",
19891989
"properties": {
1990-
"effectHints": {
1991-
"anyOf": [
1992-
{
1993-
"properties": {
1994-
"readOnly": {
1995-
"const": true,
1996-
"type": "boolean"
1997-
}
1998-
},
1999-
"required": [
2000-
"readOnly"
2001-
],
2002-
"type": "object"
2003-
},
2004-
{
2005-
"properties": {
2006-
"destructive": {
2007-
"type": "boolean"
2008-
},
2009-
"idempotent": {
2010-
"type": "boolean"
2011-
},
2012-
"readOnly": {
2013-
"const": false,
2014-
"type": "boolean"
2015-
}
2016-
},
2017-
"required": [
2018-
"readOnly"
2019-
],
2020-
"type": "object"
2021-
}
2022-
],
2023-
"description": "Describes the effects a tool may have on its environment.\n\nNOTE: these properties are **hints**. They do not guarantee tool behavior.\n\nIf not set, this property is assumed to have the value:\n { readOnly: false, destructive: true, idempotent: false }"
1990+
"destructiveHint": {
1991+
"description": "If true, the tool may perform destructive updates to its environment.\nIf false, the tool performs only additive updates.\n\n(This property is meaningful only when `readOnlyHint == false`)\n\nDefault: true",
1992+
"type": "boolean"
1993+
},
1994+
"idempotentHint": {
1995+
"description": "If true, calling the tool repeatedly with the same arguments \nwill have no additional effect on the its environment.\n\n(This property is meaningful only when `readOnlyHint == false`)\n\nDefault: false",
1996+
"type": "boolean"
20241997
},
20251998
"openWorldHint": {
2026-
"description": "If true, this tool may interact with an \"open world\" of external\nentities. If false, the tool's domain of interaction is closed.\nFor example, the world of a web search tool is open, whereas that\nof a memory tool is not.\n\nNOTE: this property is a **hint**. It does not guarantee tool behavior.\n\nIf not set, this is assumed to be true.",
1999+
"description": "If true, this tool may interact with an \"open world\" of external\nentities. If false, the tool's domain of interaction is closed.\nFor example, the world of a web search tool is open, whereas that\nof a memory tool is not.\n\nDefault: true",
2000+
"type": "boolean"
2001+
},
2002+
"readOnlyHint": {
2003+
"description": "If true, the tool does not modify its environment.\n\nDefault: false",
20272004
"type": "boolean"
20282005
},
20292006
"title": {

schema/draft/schema.ts

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,13 @@ export interface ToolListChangedNotification extends Notification {
698698

699699
/**
700700
* Additional properties describing a Tool to clients.
701+
*
702+
* NOTE: all properties in ToolAnnotations are **hints**.
703+
* They are not guaranteed to provide a faithful description of
704+
* tool behavior (including descriptive properties like `title`).
705+
*
706+
* Clients should never make tool use decisions based on ToolAnnotations
707+
* received from untrusted servers.
701708
*/
702709
export interface ToolAnnotations {
703710
/**
@@ -706,36 +713,39 @@ export interface ToolAnnotations {
706713
title?: string;
707714

708715
/**
709-
* Describes the effects a tool may have on its environment.
716+
* If true, the tool does not modify its environment.
710717
*
711-
* NOTE: these properties are **hints**. They do not guarantee tool behavior.
712-
*
713-
* If not set, this property is assumed to have the value:
714-
* { readOnly: false, destructive: true, idempotent: false }
715-
*/
716-
effectHints?:
717-
| {
718-
/* Tool is read-only. */
719-
readOnly: true;
720-
}
721-
| {
722-
/* Tool is read-write. */
723-
readOnly: false;
724-
/* If true, tool may perform destructive updates to its environment, as opposed to only additive updates. Default: true */
725-
destructive?: boolean;
726-
/* If true, repeated calls with the same arguments will have no additional effects. Default: false */
727-
idempotent?: boolean;
728-
};
718+
* Default: false
719+
*/
720+
readOnlyHint?: boolean;
721+
722+
/**
723+
* If true, the tool may perform destructive updates to its environment.
724+
* If false, the tool performs only additive updates.
725+
*
726+
* (This property is meaningful only when `readOnlyHint == false`)
727+
*
728+
* Default: true
729+
*/
730+
destructiveHint?: boolean;
731+
732+
/**
733+
* If true, calling the tool repeatedly with the same arguments
734+
* will have no additional effect on the its environment.
735+
*
736+
* (This property is meaningful only when `readOnlyHint == false`)
737+
*
738+
* Default: false
739+
*/
740+
idempotentHint?: boolean;
729741

730742
/**
731743
* If true, this tool may interact with an "open world" of external
732744
* entities. If false, the tool's domain of interaction is closed.
733745
* For example, the world of a web search tool is open, whereas that
734746
* of a memory tool is not.
735-
*
736-
* NOTE: this property is a **hint**. It does not guarantee tool behavior.
737747
*
738-
* If not set, this is assumed to be true.
748+
* Default: true
739749
*/
740750
openWorldHint?: boolean;
741751
}

0 commit comments

Comments
 (0)