MCP completion lets a server offer autocompletion suggestions for the arguments of prompts and resource templates. When a user fills in an argument value, the client sends a completion/complete request naming the prompt or resource template, the argument name and its current value, and the server returns values ranked by relevance. It works like IDE code completion, and it makes long argument lists usable.
What you need
- A prompt or resource template with arguments worth completing
- The server completions capability declared
- A list of the values each argument can take
Step 1: Declare the completions capability
Confirm the server declares the completions capability. Without it, a client will not send completion requests, and users type every argument value by hand.
Step 2: Answer with ranked values
For each completion/complete request, return suggestions sorted by relevance, with an optional total and a flag saying whether more results exist. Include the already-resolved arguments in context.arguments when a prompt has several arguments, so later suggestions fit earlier choices.
Step 3: Keep replies small and fast
Return at most 100 values per response, and rate-limit completion requests. Clients should debounce rapid requests and cache results, so a slow server does not freeze the input box.
Worked example: synthetic completion check for one argument
The table below is a synthetic example. It shows the expected result of a completion request; no server was queried.
| Argument | Typed so far | Suggestions |
|---|---|---|
| city | Par | Paris, Parma, Paramaribo |
| project | web | website-redesign, web-api |
| owner | al | alice, alex |
| status | op | open, in progress |
Expected result (UNTESTED). each argument returns a short ranked list of matching values, with at most 100 items. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Completion supports two reference types only: a prompt by name, or a resource URI or URI template.
- Servers should return suggestions sorted by relevance and implement fuzzy matching where appropriate.
- Completion suggestions can leak sensitive values, so control access to them and validate all inputs.
- Clients should handle missing or partial results gracefully instead of failing the input.
