@@ -75,6 +75,8 @@ type Tool struct {
75
75
InputSchema ToolInputSchema `json:"inputSchema"`
76
76
// Alternative to InputSchema - allows arbitrary JSON Schema to be provided
77
77
RawInputSchema json.RawMessage `json:"-"` // Hide this from JSON marshaling
78
+ // Optional properties describing tool behavior
79
+ Annotations ToolAnnotation `json:"annotations"`
78
80
}
79
81
80
82
// MarshalJSON implements the json.Marshaler interface for Tool.
@@ -109,6 +111,19 @@ type ToolInputSchema struct {
109
111
Required []string `json:"required,omitempty"`
110
112
}
111
113
114
+ type ToolAnnotation struct {
115
+ // Human-readable title for the tool
116
+ Title string `json:"title,omitempty"`
117
+ // If true, the tool does not modify its environment
118
+ ReadOnlyHint bool `json:"readOnlyHint,omitempty"`
119
+ // If true, the tool may perform destructive updates
120
+ DestructiveHint bool `json:"destructiveHint,omitempty"`
121
+ // If true, repeated calls with same args have no additional effect
122
+ IdempotentHint bool `json:"idempotentHint,omitempty"`
123
+ // If true, tool interacts with external entities
124
+ OpenWorldHint bool `json:"openWorldHint,omitempty"`
125
+ }
126
+
112
127
// ToolOption is a function that configures a Tool.
113
128
// It provides a flexible way to set various properties of a Tool using the functional options pattern.
114
129
type ToolOption func (* Tool )
@@ -132,6 +147,13 @@ func NewTool(name string, opts ...ToolOption) Tool {
132
147
Properties : make (map [string ]interface {}),
133
148
Required : nil , // Will be omitted from JSON if empty
134
149
},
150
+ Annotations : ToolAnnotation {
151
+ Title : "" ,
152
+ ReadOnlyHint : false ,
153
+ DestructiveHint : true ,
154
+ IdempotentHint : false ,
155
+ OpenWorldHint : true ,
156
+ },
135
157
}
136
158
137
159
for _ , opt := range opts {
@@ -166,6 +188,12 @@ func WithDescription(description string) ToolOption {
166
188
}
167
189
}
168
190
191
+ func WithToolAnnotation (annotation ToolAnnotation ) ToolOption {
192
+ return func (t * Tool ) {
193
+ t .Annotations = annotation
194
+ }
195
+ }
196
+
169
197
//
170
198
// Common Property Options
171
199
//
0 commit comments