File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -327,6 +327,21 @@ func NewToolResultErrorFromErr(text string, err error) *CallToolResult {
327327 }
328328}
329329
330+ // NewToolResultErrorf creates a new CallToolResult with an error message.
331+ // The error message is formatted using the fmt package.
332+ // Any errors that originate from the tool SHOULD be reported inside the result object.
333+ func NewToolResultErrorf (format string , a ... any ) * CallToolResult {
334+ return & CallToolResult {
335+ Content : []Content {
336+ TextContent {
337+ Type : "text" ,
338+ Text : fmt .Sprintf (format , a ... ),
339+ },
340+ },
341+ IsError : true ,
342+ }
343+ }
344+
330345// NewListResourcesResult creates a new ListResourcesResult
331346func NewListResourcesResult (
332347 resources []Resource ,
You can’t perform that action at this time.
0 commit comments