You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Motivation and Context
The MCP specification defines `completion/complete` for providing autocompletion
suggestions for prompt arguments and resource template URIs.
The Ruby SDK previously had only a no-op handler that returned empty results,
with no way for users to define custom completion logic.
This aligns the Ruby SDK with the Python and TypeScript SDKs,
both of which support user-defined completion handlers.
## How Has This Been Tested?
Server tests cover: default handler, custom handler for `ref/prompt` and `ref/resource`,
context argument passing, 100-item truncation, and error responses for nonexistent prompts,
nonexistent resource templates, and invalid ref types.
Client tests cover: request structure, context parameter inclusion,
and fallback when result is missing.
## Breaking Changes
None. The existing default no-op handler behavior is preserved.
The `completion_handler` method is purely additive. The only behavioral change
is that `completion/complete` requests now validate that the referenced prompt
or resource template exists before calling the handler,
returning an `invalid_params` error for unknown references.
The handler must return a hash with a `completion` key containing `values` (array of strings), and optionally `total` and `hasMore`.
229
+
The SDK automatically enforces the 100-item limit per the MCP specification.
230
+
231
+
The server validates that the referenced prompt, resource, or resource template is registered before calling the handler.
232
+
Requests for unknown references return an error.
233
+
186
234
### Logging
187
235
188
236
The MCP Ruby SDK supports structured logging through the `notify_log_message` method, following the [MCP Logging specification](https://modelcontextprotocol.io/specification/latest/server/utilities/logging).
@@ -298,7 +346,6 @@ transport = MCP::Server::Transports::StreamableHTTPTransport.new(server, session
298
346
### Unsupported Features (to be implemented in future versions)
299
347
300
348
- Resource subscriptions
301
-
- Completions
302
349
- Elicitation
303
350
304
351
### Usage
@@ -1056,6 +1103,7 @@ This class supports:
1056
1103
- Resource reading via the `resources/read` method (`MCP::Client#read_resources`)
1057
1104
- Prompt listing via the `prompts/list` method (`MCP::Client#prompts`)
1058
1105
- Prompt retrieval via the `prompts/get` method (`MCP::Client#get_prompt`)
1106
+
- Completion requests via the `completion/complete` method (`MCP::Client#complete`)
0 commit comments