The Model Context Protocol (MCP) provides a standardized way for servers to offer argument autocompletion suggestions for prompts and resource URIs. This enables rich, IDE-like experiences where users receive contextual suggestions while entering argument values.
Completion in MCP is designed to support interactive user experiences similar to IDE code completion.
For example, applications may show completion suggestions in a dropdown or popup menu as users type, with the ability to filter and select from available options.
However, implementations are free to expose completion through any interface pattern that suits their needs—the protocol itself does not mandate any specific user interaction model.
Servers that support completions MUST declare the completions
capability:
To get completion suggestions, clients send a completion/complete
request specifying
what is being completed through a reference type:
Request:
Response:
For prompts or URI templates with multiple arguments, clients should include previous completions in the context.arguments
object to provide context for subsequent requests.
Request:
Response:
The protocol supports two types of completion references:
Type | Description | Example |
---|---|---|
ref/prompt | References a prompt by name | {"type": "ref/prompt", "name": "code_review"} |
ref/resource | References a resource URI | {"type": "ref/resource", "uri": "file:///{path}"} |
Servers return an array of completion values ranked by relevance, with:
ref
: A PromptReference
or ResourceReference
argument
: Object containing:
name
: Argument namevalue
: Current valuecontext
: Object containing:
arguments
: A mapping of already-resolved argument names to their values.completion
: Object containing:
values
: Array of suggestions (max 100)total
: Optional total matcheshasMore
: Additional results flagServers SHOULD return standard JSON-RPC errors for common failure cases:
-32601
(Capability not supported)-32602
(Invalid params)-32602
(Invalid params)-32603
(Internal error)Servers SHOULD:
Clients SHOULD:
Implementations MUST: