Merge pull request #312 from koic/support_elicitation

Support `elicitation/create` per MCP specification
This commit is contained in:
Koichi ITO 2026-04-15 02:22:55 +09:00 • committed by GitHub
commit 3b1777adb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,14 +31,27 @@ module MCP
MAX_COMPLETION_VALUES = 100
class RequestHandlerError < StandardError
attr_reader :error_type
attr_reader :original_error
attr_reader :error_type, :original_error, :error_code, :error_data
def initialize(message, request, error_type: :internal_error, original_error: nil)
def initialize(message, request, error_type: :internal_error, original_error: nil, error_code: nil, error_data: nil)
super(message)
@request = request
@error_type = error_type
@original_error = original_error
@error_code = error_code
@error_data = error_data
end
end
class URLElicitationRequiredError < RequestHandlerError
def initialize(elicitations)
super(
"URL elicitation required",
nil,
error_type: :url_elicitation_required,
error_code: -32042,
error_data: { elicitations: elicitations },
)
end
end
@ -114,7 +127,6 @@ module MCP
# No op handlers for currently unsupported methods
Methods::RESOURCES_SUBSCRIBE => ->(_) { {} },
Methods::RESOURCES_UNSUBSCRIBE => ->(_) { {} },
Methods::ELICITATION_CREATE => ->(_) {},
}
@transport = transport
end