feat: Implement completion handling for prompts and resources #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Complete Issue #19
This pull request adds support for parameter auto-completion for prompts and resources to the MCP client/server framework. It introduces new completion handlers and updates both the server and client example applications to demonstrate and utilize these features. The changes are grouped into API extensions, server-side handler implementations, and client-side demonstration updates.
API Extensions
CompleteCompletion
method to theConnector
interface and implemented it in the client, enabling parameter auto-completion for prompts and resource URIs.Server-side Handler Implementations
When registering prompt and resource, add the
option
parameter to inject parameters such asCompletionCompleteHandler
Registered new completion handlers for resources and prompts, including resource completion, resource template completion, and prompt argument completion (e.g., language suggestions for code review).
Updated the handler dispatch logic to route completion requests based on reference type (prompt or resource).
Added
errors.ErrMethodNotFound
for indicating that a method has not been registered.Added handling of panic situations in
handleReadResource
inmanager_resource
when the handler isnil
during registration.Client-side Demonstration Updates
These changes provide a foundation for interactive auto-completion in the MCP framework, improving usability for both prompt and resource operations.