File tree Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 1313
1414** Server-side** :
1515MCP servers can provide LLM prompt templates (called simply _ prompts_ ) to clients.
16- Associated with each prompt is a handler that expands the template given a set of key-value pairs.
16+ Every prompt has a required name which identifies it, and a set of named arguments, which are strings.
17+ Construct a prompt with a name and descriptions of its arguments.
18+ Associated with each prompt is a handler that expands the template given values for its arguments.
1719Use [ ` Server.AddPrompt ` ] ( https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddPrompt )
1820to add a prompt along with its handler.
1921If ` AddPrompt ` is called before a server is connected, the server will have the ` prompts ` capability.
@@ -47,8 +49,17 @@ func Example_prompts() {
4749
4850 // Create a server with a single prompt.
4951 s := mcp.NewServer (&mcp.Implementation {Name: " server" , Version: " v0.0.1" }, nil )
50- // The name is required: it uniquely identifies the prompt.
51- s.AddPrompt (&mcp.Prompt {Name: " greet" }, promptHandler)
52+ prompt := &mcp.Prompt {
53+ Name: " greet" ,
54+ Arguments: []*mcp.PromptArgument {
55+ {
56+ Name: " name" ,
57+ Description: " the name of the person to greet" ,
58+ Required: true ,
59+ },
60+ },
61+ }
62+ s.AddPrompt (prompt, promptHandler)
5263
5364 // Create a client.
5465 c := mcp.NewClient (&mcp.Implementation {Name: " client" , Version: " v0.0.1" }, nil )
Original file line number Diff line number Diff line change 66
77** Server-side** :
88MCP servers can provide LLM prompt templates (called simply _ prompts_ ) to clients.
9- Associated with each prompt is a handler that expands the template given a set of key-value pairs.
9+ Every prompt has a required name which identifies it, and a set of named arguments, which are strings.
10+ Construct a prompt with a name and descriptions of its arguments.
11+ Associated with each prompt is a handler that expands the template given values for its arguments.
1012Use [ ` Server.AddPrompt ` ] ( https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddPrompt )
1113to add a prompt along with its handler.
1214If ` AddPrompt ` is called before a server is connected, the server will have the ` prompts ` capability.
Original file line number Diff line number Diff line change @@ -31,8 +31,17 @@ func Example_prompts() {
3131
3232 // Create a server with a single prompt.
3333 s := mcp .NewServer (& mcp.Implementation {Name : "server" , Version : "v0.0.1" }, nil )
34- // The name is required: it uniquely identifies the prompt.
35- s .AddPrompt (& mcp.Prompt {Name : "greet" }, promptHandler )
34+ prompt := & mcp.Prompt {
35+ Name : "greet" ,
36+ Arguments : []* mcp.PromptArgument {
37+ {
38+ Name : "name" ,
39+ Description : "the name of the person to greet" ,
40+ Required : true ,
41+ },
42+ },
43+ }
44+ s .AddPrompt (prompt , promptHandler )
3645
3746 // Create a client.
3847 c := mcp .NewClient (& mcp.Implementation {Name : "client" , Version : "v0.0.1" }, nil )
You can’t perform that action at this time.
0 commit comments