class RubyLLM::MCP::InputRequest
A serverโs request for input from the user while it works on a call, received by MCP.before_input_request callbacks. A form request asks for values; a URL request asks the user to visit a page, such as to connect an account.
before_input_request do |request| if request.url? system "open", request.url request.answer else request.answer(environment: "staging") end end
In a chat, a request no callback answers pauses the tool call until Chat#answer or Chat#decline settles it; see Chat#pending_inputs.
Constants
- Field
-
A value a form request asks for.
Attributes
The values a form request asks for, as Field objects.
Why the server needs the input.
The ToolCall paused on this request, when it came from a chat.
The page a URL request asks the user to visit, or nil.
Public Instance Methods
Source
# File lib/ruby_llm/mcp/input_request.rb, line 72 def answer(**values) @response = { action: 'accept', content: (values.transform_keys(&:to_s) unless url?) }.compact end
Accepts the request. A form request takes the values as keywords; a URL request takes none, meaning the user agreed to visit the page.
Source
# File lib/ruby_llm/mcp/input_request.rb, line 82 def answered? !response.nil? end
Returns whether the request has been answered or declined.
Source
# File lib/ruby_llm/mcp/input_request.rb, line 77 def decline @response = { action: 'decline' } end
Declines the request.
Source
# File lib/ruby_llm/mcp/input_request.rb, line 66 def form? !url? end
Returns whether the server asks for fields.