Skip to content

Commit 205a459

Browse files
committed
add NewToolResultError
1 parent d3dc35c commit 205a459

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mcp/utils.go

+13
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,19 @@ 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+
}
266+
}
267+
255268
// NewListResourcesResult creates a new ListResourcesResult
256269
func NewListResourcesResult(
257270
resources []Resource,

0 commit comments

Comments
 (0)