@@ -166,6 +166,73 @@ Please provide a comprehensive analysis including:
166166
167167## Prompt Arguments
168168
169+ ### Basic Argument Completion
170+
171+ ```go
172+ import (
173+ " context"
174+ " fmt"
175+ " strings"
176+
177+ " github.com /mark3labs/mcp-go /mcp"
178+ " github.com /mark3labs/mcp-go /server"
179+ )
180+
181+ var dictionary = map[string][]string{
182+ " adjective" : {" funny" , " silly" , " clever" , " witty" , " absurd" },
183+ " subject" : {" cats" , " dogs" , " programmers" , " aliens" , " politicians" },
184+ }
185+
186+ func main() {
187+ s := server.NewMCPServer(" Personal Assistant" , " 1.0.0 " ,
188+ server.WithPromptCapabilities(true),
189+ )
190+
191+ // Tell joke prompt
192+ tellJokePrompt := mcp.NewPrompt(" tell_joke" ,
193+ mcp.WithArgument(" adjective" , mcp.ArgumentCompletion(handleCompleteFromDictionary)),
194+ mcp.WithArgument(" subject" , mcp.RequiredArgument(), mcp.ArgumentCompletion(handleCompleteFromDictionary)),
195+ )
196+
197+ s.AddPrompt(tellJokePrompt, handleTellJoke)
198+ server.ServeStdio(s)
199+ }
200+
201+ func handleCompleteFromDictionary(ctx context.Context, req mcp.CompleteRequest) (*mcp.CompleteResult, error) {
202+ input := strings.ToLower(req.Params.Argument.Value)
203+ options := dictionary[req.Params.Argument.Name] // Get options for argument
204+
205+ // Initialize results container
206+ result := &mcp.CompleteResult{}
207+ result.Completion.Values = make([]string, 0, len(options))
208+
209+ // Simple match logic
210+ for _, option := range options {
211+ if strings.Contains(strings.ToLower(option), input) {
212+ result.Completion.Values = append(result.Completion.Values, option)
213+ }
214+ }
215+ return result, nil
216+ }
217+
218+ func handleTellJoke(ctx context.Context, req mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
219+ adjective := req.Params.Arguments[" adjective" ]
220+ subject, ok := req.Params.Arguments[" subject" ]
221+ if !ok || strings.TrimSpace(subject) == " " {
222+ return nil, fmt.Errorf(" subject argument is required and cannot be empty" )
223+ }
224+
225+ return &mcp.GetPromptResult{
226+ Messages: []mcp.PromptMessage{
227+ {
228+ Role: " user" ,
229+ Content: mcp.NewTextContent(fmt.Sprintf(" Tell a %s joke about %s." , adjective, subject)),
230+ },
231+ },
232+ }, nil
233+ }
234+ ```
235+
169236### Flexible Parameter Handling
170237
171238```go
0 commit comments