File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed
lib/model_context_protocol
test/model_context_protocol Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def initialize(method, capability)
3636
3737 def ensure_capability! ( method , capabilities )
3838 case method
39- when PROMPTS_GET , PROMPTS_LIST , COMPLETION_COMPLETE
39+ when PROMPTS_GET , PROMPTS_LIST
4040 unless capabilities [ :prompts ]
4141 raise MissingRequiredCapabilityError . new ( method , :prompts )
4242 end
@@ -56,6 +56,10 @@ def ensure_capability!(method, capabilities)
5656 unless capabilities [ :sampling ]
5757 raise MissingRequiredCapabilityError . new ( method , :sampling )
5858 end
59+ when COMPLETION_COMPLETE
60+ unless capabilities [ :completions ]
61+ raise MissingRequiredCapabilityError . new ( method , :completions )
62+ end
5963 when LOGGING_SET_LEVEL
6064 # Logging is unsupported by the Server
6165 unless capabilities [ :logging ]
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ def initialize(
6060 # No op handlers for currently unsupported methods
6161 Methods ::RESOURCES_SUBSCRIBE => -> ( _ ) { } ,
6262 Methods ::RESOURCES_UNSUBSCRIBE => -> ( _ ) { } ,
63+ Methods ::COMPLETION_COMPLETE => -> ( _ ) { } ,
6364 Methods ::LOGGING_SET_LEVEL => -> ( _ ) { } ,
6465 }
6566 end
Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ class MethodsTest < ActiveSupport::TestCase
1919 assert_equal "Server does not support sampling (required for sampling/createMessage)" , error . message
2020 end
2121
22+ test "ensure_capability! for completion/complete raises an error if completions capability is not present" do
23+ error = assert_raises ( Methods ::MissingRequiredCapabilityError ) do
24+ Methods . ensure_capability! ( Methods ::COMPLETION_COMPLETE , { } )
25+ end
26+ assert_equal "Server does not support completions (required for completion/complete)" , error . message
27+ end
28+
2229 test "ensure_capability! for logging/setLevel raises an error if logging capability is not present" do
2330 error = assert_raises ( Methods ::MissingRequiredCapabilityError ) do
2431 Methods . ensure_capability! ( Methods ::LOGGING_SET_LEVEL , { } )
You can’t perform that action at this time.
0 commit comments