Merge pull request #22 from koic/fix_incorrect_capabilities_handling_for_completion_complete
Fix incorrect capabilities handling for `completion/complete`
This commit is contained in:
commit
6b49222edb
3 changed files with 13 additions and 1 deletions
|
|
@ -36,7 +36,7 @@ module ModelContextProtocol
|
||||||
|
|
||||||
def ensure_capability!(method, capabilities)
|
def ensure_capability!(method, capabilities)
|
||||||
case method
|
case method
|
||||||
when PROMPTS_GET, PROMPTS_LIST, COMPLETION_COMPLETE
|
when PROMPTS_GET, PROMPTS_LIST
|
||||||
unless capabilities[:prompts]
|
unless capabilities[:prompts]
|
||||||
raise MissingRequiredCapabilityError.new(method, :prompts)
|
raise MissingRequiredCapabilityError.new(method, :prompts)
|
||||||
end
|
end
|
||||||
|
|
@ -56,6 +56,10 @@ module ModelContextProtocol
|
||||||
unless capabilities[:sampling]
|
unless capabilities[:sampling]
|
||||||
raise MissingRequiredCapabilityError.new(method, :sampling)
|
raise MissingRequiredCapabilityError.new(method, :sampling)
|
||||||
end
|
end
|
||||||
|
when COMPLETION_COMPLETE
|
||||||
|
unless capabilities[:completions]
|
||||||
|
raise MissingRequiredCapabilityError.new(method, :completions)
|
||||||
|
end
|
||||||
when LOGGING_SET_LEVEL
|
when LOGGING_SET_LEVEL
|
||||||
# Logging is unsupported by the Server
|
# Logging is unsupported by the Server
|
||||||
unless capabilities[:logging]
|
unless capabilities[:logging]
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ module ModelContextProtocol
|
||||||
# No op handlers for currently unsupported methods
|
# No op handlers for currently unsupported methods
|
||||||
Methods::RESOURCES_SUBSCRIBE => ->(_) {},
|
Methods::RESOURCES_SUBSCRIBE => ->(_) {},
|
||||||
Methods::RESOURCES_UNSUBSCRIBE => ->(_) {},
|
Methods::RESOURCES_UNSUBSCRIBE => ->(_) {},
|
||||||
|
Methods::COMPLETION_COMPLETE => ->(_) {},
|
||||||
Methods::LOGGING_SET_LEVEL => ->(_) {},
|
Methods::LOGGING_SET_LEVEL => ->(_) {},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@ module ModelContextProtocol
|
||||||
assert_equal "Server does not support sampling (required for sampling/createMessage)", error.message
|
assert_equal "Server does not support sampling (required for sampling/createMessage)", error.message
|
||||||
end
|
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
|
test "ensure_capability! for logging/setLevel raises an error if logging capability is not present" do
|
||||||
error = assert_raises(Methods::MissingRequiredCapabilityError) do
|
error = assert_raises(Methods::MissingRequiredCapabilityError) do
|
||||||
Methods.ensure_capability!(Methods::LOGGING_SET_LEVEL, {})
|
Methods.ensure_capability!(Methods::LOGGING_SET_LEVEL, {})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue