Fix incorrect capabilities handling for completion/complete
This PR fixes incorrect capabilities handling for `completion/complete`. As specified, the capability of `completion/complete` is `completions`, not `prompts`: https://modelcontextprotocol.io/specification/2025-03-26/server/utilities/completion#capabilities Note that in the Ruby SDK, `completion/complete`, like `logging/setLevel`, is not yet implemented. Therefore, an empty implementation has been added to server.rb.
This commit is contained in:
parent
89ef9d89e5
commit
d3dcde2460
3 changed files with 13 additions and 1 deletions
|
|
@ -36,7 +36,7 @@ module ModelContextProtocol
|
|||
|
||||
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
|
||||
|
|
@ -56,6 +56,10 @@ module ModelContextProtocol
|
|||
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]
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ module ModelContextProtocol
|
|||
# No op handlers for currently unsupported methods
|
||||
Methods::RESOURCES_SUBSCRIBE => ->(_) {},
|
||||
Methods::RESOURCES_UNSUBSCRIBE => ->(_) {},
|
||||
Methods::COMPLETION_COMPLETE => ->(_) {},
|
||||
Methods::LOGGING_SET_LEVEL => ->(_) {},
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ module ModelContextProtocol
|
|||
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, {})
|
||||
|
|
|
|||
Loading…
Reference in a new issue