internal/mcp: simplify prompt API
Remove NewServerPrompt. Schema inference is irrelevant for prompts. All arguments are strings. So using a struct is not as valuable as with tools. The only advantage is catching misspellings at compile time. It's not worth it. Change-Id: I45aaa5d55c8940cc9e32dc277bd543f79d932519 Reviewed-on: https://go-review.googlesource.com/c/tools/+/682797 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
e228d78d19
commit
a6ec3f5f4e
1 changed files with 37 additions and 177 deletions
|
|
@ -32,11 +32,11 @@ func SayHi(ctx context.Context, ss *mcp.ServerSession, params *mcp.CallToolParam
|
|||
|
||||
// TODO(jba): it should be OK for args to be a pointer, but this fails in
|
||||
// jsonschema. Needs investigation.
|
||||
func PromptHi(ctx context.Context, ss *mcp.ServerSession, args HiArgs, _ *mcp.GetPromptParams) (*mcp.GetPromptResult, error) {
|
||||
func PromptHi(ctx context.Context, ss *mcp.ServerSession, params *mcp.GetPromptParams) (*mcp.GetPromptResult, error) {
|
||||
return &mcp.GetPromptResult{
|
||||
Description: "Code review prompt",
|
||||
Messages: []*mcp.PromptMessage{
|
||||
{Role: "user", Content: mcp.NewTextContent("Say hi to " + args.Name)},
|
||||
{Role: "user", Content: mcp.NewTextContent("Say hi to " + params.Arguments["name"])},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -48,7 +48,10 @@ func main() {
|
|||
server.AddTools(mcp.NewServerTool("greet", "say hi", SayHi, mcp.Input(
|
||||
mcp.Property("name", mcp.Description("the name to say hi to")),
|
||||
)))
|
||||
server.AddPrompts(mcp.NewServerPrompt("greet", "", PromptHi))
|
||||
server.AddPrompts(&mcp.ServerPrompt{
|
||||
Prompt: &mcp.Prompt{Name: "greet"},
|
||||
Handler: PromptHi,
|
||||
})
|
||||
server.AddResources(&mcp.ServerResource{
|
||||
Resource: &mcp.Resource{
|
||||
Name: "info",
|
||||
|
|
|
|||
Loading…
Reference in a new issue