Skip to content

Support completion/complete per MCP specification#289

Merged
koic merged 1 commit intomodelcontextprotocol:mainfrom
koic:feature_completion_complete
Apr 3, 2026
Merged

Support completion/complete per MCP specification#289
koic merged 1 commit intomodelcontextprotocol:mainfrom
koic:feature_completion_complete

Conversation

@koic
Copy link
Copy Markdown
Member

@koic koic commented Apr 2, 2026

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.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## 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.
Copy link
Copy Markdown
Contributor

@atesgoral atesgoral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

@koic koic merged commit c563036 into modelcontextprotocol:main Apr 3, 2026
11 checks passed
@koic koic deleted the feature_completion_complete branch April 3, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants