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
|
|
@ -88,9 +88,9 @@ func TestList(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("prompts", func(t *testing.T) {
|
||||
promptA := mcp.NewServerPrompt("apple", "apple prompt", testPromptHandler[struct{}])
|
||||
promptB := mcp.NewServerPrompt("banana", "banana prompt", testPromptHandler[struct{}])
|
||||
promptC := mcp.NewServerPrompt("cherry", "cherry prompt", testPromptHandler[struct{}])
|
||||
promptA := newServerPrompt("apple", "apple prompt")
|
||||
promptB := newServerPrompt("banana", "banana prompt")
|
||||
promptC := newServerPrompt("cherry", "cherry prompt")
|
||||
wantPrompts := []*mcp.Prompt{promptA.Prompt, promptB.Prompt, promptC.Prompt}
|
||||
prompts := []*mcp.ServerPrompt{promptA, promptB, promptC}
|
||||
server.AddPrompts(prompts...)
|
||||
|
|
@ -122,3 +122,15 @@ func testIterator[T any](ctx context.Context, t *testing.T, seq iter.Seq2[*T, er
|
|||
t.Fatalf("mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
// testPromptHandler is used for type inference newServerPrompt.
|
||||
func testPromptHandler(context.Context, *mcp.ServerSession, *mcp.GetPromptParams) (*mcp.GetPromptResult, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func newServerPrompt(name, desc string) *mcp.ServerPrompt {
|
||||
return &mcp.ServerPrompt{
|
||||
Prompt: &mcp.Prompt{Name: name, Description: desc},
|
||||
Handler: testPromptHandler,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue