forked from modelcontextprotocol/ruby-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse.rb
More file actions
29 lines (23 loc) · 671 Bytes
/
response.rb
File metadata and controls
29 lines (23 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true
module MCP
class Tool
class Response
NOT_GIVEN = Object.new.freeze
attr_reader :content
def initialize(content, deprecated_error = NOT_GIVEN, error: false)
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
@error = error
end
def error?
!!@error
end
def to_h
{ content:, isError: error? }.compact
end
end
end
end