Support structuredContent in tool response (#147)
This commit is contained in:
parent
99b57a3cc2
commit
f7cf080cc0
1 changed files with 75 additions and 3 deletions
|
|
@ -5,9 +5,9 @@ module MCP
|
|||
class Response
|
||||
NOT_GIVEN = Object.new.freeze
|
||||
|
||||
attr_reader :content
|
||||
attr_reader :content, :structured_content
|
||||
|
||||
def initialize(content, deprecated_error = NOT_GIVEN, error: false)
|
||||
def initialize(content = nil, deprecated_error = NOT_GIVEN, error: false, structured_content: 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
|
||||
|
|
@ -15,6 +15,7 @@ module MCP
|
|||
|
||||
@content = content
|
||||
@error = error
|
||||
@structured_content = structured_content
|
||||
end
|
||||
|
||||
def error?
|
||||
|
|
@ -22,7 +23,7 @@ module MCP
|
|||
end
|
||||
|
||||
def to_h
|
||||
{ content:, isError: error? }.compact
|
||||
{ content:, isError: error?, structuredContent: @structured_content }.compact
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue