Skip to content

Commit 591a196

Browse files
committed
add NewToolResultError
1 parent d3dc35c commit 591a196

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mcp/utils.go

+14
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,20 @@ func NewToolResultResource(
252252
}
253253
}
254254

255+
// NewToolResultError creates a new CallToolResult with an error message.
256+
// Any errors that originate from the tool SHOULD be reported inside the result object.
257+
func NewToolResultError(text string) *CallToolResult {
258+
return &CallToolResult{
259+
Content: []Content{
260+
TextContent{
261+
Type: "text",
262+
Text: text,
263+
},
264+
},
265+
IsError: true,
266+
}
267+
}
268+
255269
// NewListResourcesResult creates a new ListResourcesResult
256270
func NewListResourcesResult(
257271
resources []Resource,

0 commit comments

Comments
 (0)