completable utility marks prompt arguments as supporting autocomplete, allowing AI clients to provide suggestions to users.
Import
This utility is re-exported from
@modelcontextprotocol/sdk/server/completable for convenience.Usage
Usecompletable() to wrap argument definitions in your prompt schemas to indicate that the client should provide autocomplete suggestions:
API
The argument definition object to mark as completable. Typically contains:
name(string): Argument namedescription(string): Argument descriptionrequired(boolean): Whether the argument is required
completable: true property.
How it works
When an argument is marked as completable:- The MCP protocol signals to the client that autocomplete is available
- The client can request completion suggestions as the user types
- Your server can implement a completion handler to provide dynamic suggestions
- The client displays suggestions to the user in real-time
Implementing completion handlers
To provide actual completion suggestions, implement a completion handler in your MCP server:Examples
Basic completable argument
Multiple completable arguments
Mixed completable and non-completable arguments
Use cases
- File paths: Suggest available files or directories
- Resource URIs: Provide completions for resource identifiers
- Environment names: Suggest configured environments
- Branch names: Complete Git branch names
- Tag names: Suggest available tags or labels
- User names: Complete user identifiers from your system
- Configuration keys: Suggest valid configuration options
Client support
Completion support depends on the MCP client implementation. Clients that support the completion protocol will:- Request completions as users type
- Display suggestions in a dropdown or inline
- Allow users to select from suggestions or continue typing
completable marker and treat the argument as a normal text input.
Best practices
-
Mark appropriate arguments: Use
completable()for arguments where autocomplete provides value (paths, identifiers, etc.) - Provide good descriptions: Since clients may show these in autocomplete UI, ensure descriptions are clear
- Implement performant handlers: Completion requests should return quickly (< 100ms)
- Limit suggestion counts: Return a reasonable number of suggestions (typically 10-50)
- Support partial matching: Match suggestions based on partial input
-
Use hasMore flag: Set
hasMore: truewhen there are more suggestions available
Related
Prompts
Learn about creating prompts
MCP Protocol
Completion protocol specification