SetError sets the error for the tool result and sets IsError to true. If Content has not already been populated, it is set to the error text. If Content has already been populated, it is left unchanged, allowing callers to provide a user-friendly message while still recording the underlying error fo
(err error)
| 130 | // To restore the previous behavior where Content was always overwritten, |
| 131 | // set MCPGODEBUG=seterroroverwrite=1. |
| 132 | func (r *CallToolResult) SetError(err error) { |
| 133 | if len(r.Content) == 0 || seterroroverwrite == "1" { |
| 134 | r.Content = []Content{&TextContent{Text: err.Error()}} |
| 135 | } |
| 136 | r.IsError = true |
| 137 | r.err = err |
| 138 | } |
| 139 | |
| 140 | // GetError returns the error set with SetError, or nil if none. |
| 141 | // This function always returns nil on clients. |