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)
36
36
37
37
def ensure_capability! ( method , capabilities )
38
38
case method
39
- when PROMPTS_GET , PROMPTS_LIST , COMPLETION_COMPLETE
39
+ when PROMPTS_GET , PROMPTS_LIST
40
40
unless capabilities [ :prompts ]
41
41
raise MissingRequiredCapabilityError . new ( method , :prompts )
42
42
end
@@ -56,6 +56,10 @@ def ensure_capability!(method, capabilities)
56
56
unless capabilities [ :sampling ]
57
57
raise MissingRequiredCapabilityError . new ( method , :sampling )
58
58
end
59
+ when COMPLETION_COMPLETE
60
+ unless capabilities [ :completions ]
61
+ raise MissingRequiredCapabilityError . new ( method , :completions )
62
+ end
59
63
when LOGGING_SET_LEVEL
60
64
# Logging is unsupported by the Server
61
65
unless capabilities [ :logging ]
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ def initialize(
60
60
# No op handlers for currently unsupported methods
61
61
Methods ::RESOURCES_SUBSCRIBE => -> ( _ ) { } ,
62
62
Methods ::RESOURCES_UNSUBSCRIBE => -> ( _ ) { } ,
63
+ Methods ::COMPLETION_COMPLETE => -> ( _ ) { } ,
63
64
Methods ::LOGGING_SET_LEVEL => -> ( _ ) { } ,
64
65
}
65
66
end
Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ class MethodsTest < ActiveSupport::TestCase
19
19
assert_equal "Server does not support sampling (required for sampling/createMessage)" , error . message
20
20
end
21
21
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
+
22
29
test "ensure_capability! for logging/setLevel raises an error if logging capability is not present" do
23
30
error = assert_raises ( Methods ::MissingRequiredCapabilityError ) do
24
31
Methods . ensure_capability! ( Methods ::LOGGING_SET_LEVEL , { } )
You can’t perform that action at this time.
0 commit comments