Skip to content

Commit 868b1fd

Browse files
Merge pull request modelcontextprotocol#185 from modelcontextprotocol/basil/tool-annotation
ToolAnnotations
2 parents 7e2e517 + 8cf6f27 commit 868b1fd

File tree

4 files changed

+103
-6
lines changed

4 files changed

+103
-6
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ 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
187+
tool annotations to be untrusted unless they come from trusted servers. {{< /callout >}}
184188

185189
### Tool Result
186190

schema/draft/schema.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1995,8 +1995,12 @@
19951995
"Tool": {
19961996
"description": "Definition for a tool the client can call.",
19971997
"properties": {
1998+
"annotations": {
1999+
"$ref": "#/definitions/ToolAnnotations",
2000+
"description": "Optional additional tool information."
2001+
},
19982002
"description": {
1999-
"description": "A human-readable description of the tool.",
2003+
"description": "A human-readable description of the tool.\n\nThis can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a \"hint\" to the model.",
20002004
"type": "string"
20012005
},
20022006
"inputSchema": {
@@ -2037,6 +2041,32 @@
20372041
],
20382042
"type": "object"
20392043
},
2044+
"ToolAnnotations": {
2045+
"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.",
2046+
"properties": {
2047+
"destructiveHint": {
2048+
"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",
2049+
"type": "boolean"
2050+
},
2051+
"idempotentHint": {
2052+
"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",
2053+
"type": "boolean"
2054+
},
2055+
"openWorldHint": {
2056+
"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",
2057+
"type": "boolean"
2058+
},
2059+
"readOnlyHint": {
2060+
"description": "If true, the tool does not modify its environment.\n\nDefault: false",
2061+
"type": "boolean"
2062+
},
2063+
"title": {
2064+
"description": "A human-readable title for the tool.",
2065+
"type": "string"
2066+
}
2067+
},
2068+
"type": "object"
2069+
},
20402070
"ToolListChangedNotification": {
20412071
"description": "An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.",
20422072
"properties": {

schema/draft/schema.ts

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,60 @@ export interface ToolListChangedNotification extends Notification {
713713
method: "notifications/tools/list_changed";
714714
}
715715

716+
/**
717+
* Additional properties describing a Tool to clients.
718+
*
719+
* NOTE: all properties in ToolAnnotations are **hints**.
720+
* They are not guaranteed to provide a faithful description of
721+
* tool behavior (including descriptive properties like `title`).
722+
*
723+
* Clients should never make tool use decisions based on ToolAnnotations
724+
* received from untrusted servers.
725+
*/
726+
export interface ToolAnnotations {
727+
/**
728+
* A human-readable title for the tool.
729+
*/
730+
title?: string;
731+
732+
/**
733+
* If true, the tool does not modify its environment.
734+
*
735+
* Default: false
736+
*/
737+
readOnlyHint?: boolean;
738+
739+
/**
740+
* If true, the tool may perform destructive updates to its environment.
741+
* If false, the tool performs only additive updates.
742+
*
743+
* (This property is meaningful only when `readOnlyHint == false`)
744+
*
745+
* Default: true
746+
*/
747+
destructiveHint?: boolean;
748+
749+
/**
750+
* If true, calling the tool repeatedly with the same arguments
751+
* will have no additional effect on the its environment.
752+
*
753+
* (This property is meaningful only when `readOnlyHint == false`)
754+
*
755+
* Default: false
756+
*/
757+
idempotentHint?: boolean;
758+
759+
/**
760+
* If true, this tool may interact with an "open world" of external
761+
* entities. If false, the tool's domain of interaction is closed.
762+
* For example, the world of a web search tool is open, whereas that
763+
* of a memory tool is not.
764+
*
765+
* Default: true
766+
*/
767+
openWorldHint?: boolean;
768+
}
769+
716770
/**
717771
* Definition for a tool the client can call.
718772
*/
@@ -721,10 +775,14 @@ export interface Tool {
721775
* The name of the tool.
722776
*/
723777
name: string;
778+
724779
/**
725780
* A human-readable description of the tool.
781+
*
782+
* This can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a "hint" to the model.
726783
*/
727784
description?: string;
785+
728786
/**
729787
* A JSON Schema object defining the expected parameters for the tool.
730788
*/
@@ -733,6 +791,11 @@ export interface Tool {
733791
properties?: { [key: string]: object };
734792
required?: string[];
735793
};
794+
795+
/**
796+
* Optional additional tool information.
797+
*/
798+
annotations?: ToolAnnotations;
736799
}
737800

738801
/* Logging */
@@ -850,14 +913,14 @@ export interface SamplingMessage {
850913
export interface Annotations {
851914
/**
852915
* Describes who the intended customer of this object or data is.
853-
*
916+
*
854917
* It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`).
855918
*/
856919
audience?: Role[];
857920

858921
/**
859922
* Describes how important this data is for operating the server.
860-
*
923+
*
861924
* A value of 1 means "most important," and indicates that the data is
862925
* effectively required, while 0 means "least important," and indicates that
863926
* the data is entirely optional.
@@ -910,7 +973,6 @@ export interface ImageContent {
910973
annotations?: Annotations;
911974
}
912975

913-
914976
/**
915977
* Audio provided to or from an LLM.
916978
*/
@@ -935,7 +997,6 @@ export interface AudioContent {
935997
annotations?: Annotations;
936998
}
937999

938-
9391000
/**
9401001
* The server's preferences for model selection, requested of the client during sampling.
9411002
*

0 commit comments

Comments
 (0)