Skip to content

Commit c0c78ad

Browse files
committed
add how to use Completions to the readme
1 parent 0e86a6d commit c0c78ad

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,32 @@ server.registerPrompt(
317317
);
318318
```
319319

320+
### Completions
321+
322+
MCP supports argument completions to help users fill in prompt arguments and resource template parameters. See the examples above for [resource completions](#resources) and [prompt completions](#prompts).
323+
324+
#### Client Usage
325+
326+
```typescript
327+
// Request completions for any argument
328+
const result = await client.complete({
329+
ref: {
330+
type: "ref/prompt", // or "ref/resource"
331+
name: "example" // or uri: "template://..."
332+
},
333+
argument: {
334+
name: "argumentName",
335+
value: "partial" // What the user has typed so far
336+
},
337+
context: { // Optional: Include previously resolved arguments
338+
arguments: {
339+
previousArg: "value"
340+
}
341+
}
342+
});
343+
console.log(result.completion.values); // ["suggestion1", "suggestion2", ...]
344+
```
345+
320346
### Display Names and Metadata
321347

322348
All resources, tools, and prompts support an optional `title` field for better UI presentation. The `title` is used as a display name, while `name` remains the unique identifier.
@@ -870,6 +896,18 @@ const result = await client.callTool({
870896
arg1: "value"
871897
}
872898
});
899+
900+
// Request completions
901+
const completions = await client.complete({
902+
ref: {
903+
type: "ref/prompt",
904+
name: "example-prompt"
905+
},
906+
argument: {
907+
name: "arg1",
908+
value: "partial"
909+
}
910+
});
873911
```
874912

875913
### Proxy Authorization Requests Upstream

0 commit comments

Comments
 (0)