Skip to content

Commit ddfe50e

Browse files
committed
args
1 parent 870e39e commit ddfe50e

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

docs/server.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
**Server-side**:
1515
MCP 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.
1719
Use [`Server.AddPrompt`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddPrompt)
1820
to add a prompt along with its handler.
1921
If `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)

internal/docs/server.src.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
**Server-side**:
88
MCP 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.
1012
Use [`Server.AddPrompt`](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk/mcp#Server.AddPrompt)
1113
to add a prompt along with its handler.
1214
If `AddPrompt` is called before a server is connected, the server will have the `prompts` capability.

mcp/server_example_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)