fix: preserve explicit tool response content
This commit is contained in:
parent
f6ab1e2366
commit
43a0ba6266
1 changed files with 109 additions and 20 deletions
|
|
@ -7,18 +7,24 @@ module MCP
|
|||
|
||||
attr_reader :content, :structured_content, :meta
|
||||
|
||||
def initialize(content = nil, deprecated_error = NOT_GIVEN, error: false, structured_content: nil, meta: nil)
|
||||
def initialize(content = NOT_GIVEN, deprecated_error = NOT_GIVEN, error: false, structured_content: nil, meta: nil)
|
||||
if deprecated_error != NOT_GIVEN
|
||||
warn("Passing `error` with the 2nd argument of `Response.new` is deprecated. Use keyword argument like `Response.new(content, error: error)` instead.", uplevel: 1)
|
||||
error = deprecated_error
|
||||
end
|
||||
|
||||
@content = content || []
|
||||
content_given = !content.equal?(NOT_GIVEN)
|
||||
@content_provided = content_given && !content.nil?
|
||||
@content = content_given ? (content || []) : []
|
||||
@error = error
|
||||
@structured_content = structured_content
|
||||
@meta = meta
|
||||
end
|
||||
|
||||
def content_provided?
|
||||
@content_provided
|
||||
end
|
||||
|
||||
def error?
|
||||
!!@error
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue