Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/model_context_protocol/methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def initialize(method, capability)

def ensure_capability!(method, capabilities)
case method
when PROMPTS_GET, PROMPTS_LIST, COMPLETION_COMPLETE
when PROMPTS_GET, PROMPTS_LIST
unless capabilities[:prompts]
raise MissingRequiredCapabilityError.new(method, :prompts)
end
Expand All @@ -56,6 +56,10 @@ def ensure_capability!(method, capabilities)
unless capabilities[:sampling]
raise MissingRequiredCapabilityError.new(method, :sampling)
end
when COMPLETION_COMPLETE
unless capabilities[:completions]
raise MissingRequiredCapabilityError.new(method, :completions)
end
when LOGGING_SET_LEVEL
# Logging is unsupported by the Server
unless capabilities[:logging]
Expand Down
1 change: 1 addition & 0 deletions lib/model_context_protocol/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def initialize(
# No op handlers for currently unsupported methods
Methods::RESOURCES_SUBSCRIBE => ->(_) {},
Methods::RESOURCES_UNSUBSCRIBE => ->(_) {},
Methods::COMPLETION_COMPLETE => ->(_) {},
Methods::LOGGING_SET_LEVEL => ->(_) {},
}
end
Expand Down
7 changes: 7 additions & 0 deletions test/model_context_protocol/methods_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class MethodsTest < ActiveSupport::TestCase
assert_equal "Server does not support sampling (required for sampling/createMessage)", error.message
end

test "ensure_capability! for completion/complete raises an error if completions capability is not present" do
error = assert_raises(Methods::MissingRequiredCapabilityError) do
Methods.ensure_capability!(Methods::COMPLETION_COMPLETE, {})
end
assert_equal "Server does not support completions (required for completion/complete)", error.message
end

test "ensure_capability! for logging/setLevel raises an error if logging capability is not present" do
error = assert_raises(Methods::MissingRequiredCapabilityError) do
Methods.ensure_capability!(Methods::LOGGING_SET_LEVEL, {})
Expand Down
Loading