internal/mcp: rename NewXXX->NewServerXXX
The NewTool and NewPrompt constructors were unidiomatic, because they returned a ServerTool and ServerPrompt, respectively, rather than a Tool and Prompt. Rename to be consistent with the constructed object name. Change-Id: Ife3f16f783368401f792660c4272e1bb5ae61638 Reviewed-on: https://go-review.googlesource.com/c/tools/+/682375 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
parent
d2f2f87bbe
commit
9453d6bf6c
1 changed files with 76 additions and 74 deletions
|
|
@ -12,26 +12,26 @@ import (
|
|||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
)
|
||||
|
||||
// testPromptHandler is used for type inference in TestNewPrompt.
|
||||
// testPromptHandler is used for type inference in TestNewServerPrompt.
|
||||
func testPromptHandler[T any](context.Context, *mcp.ServerSession, T, *mcp.GetPromptParams) (*mcp.GetPromptResult, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func TestNewPrompt(t *testing.T) {
|
||||
func TestNewServerPrompt(t *testing.T) {
|
||||
tests := []struct {
|
||||
prompt *mcp.ServerPrompt
|
||||
want []*mcp.PromptArgument
|
||||
}{
|
||||
{
|
||||
mcp.NewPrompt("empty", "", testPromptHandler[struct{}]),
|
||||
mcp.NewServerPrompt("empty", "", testPromptHandler[struct{}]),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
mcp.NewPrompt("add_arg", "", testPromptHandler[struct{}], mcp.Argument("x")),
|
||||
mcp.NewServerPrompt("add_arg", "", testPromptHandler[struct{}], mcp.Argument("x")),
|
||||
[]*mcp.PromptArgument{{Name: "x"}},
|
||||
},
|
||||
{
|
||||
mcp.NewPrompt("combo", "", testPromptHandler[struct {
|
||||
mcp.NewServerPrompt("combo", "", testPromptHandler[struct {
|
||||
Name string `json:"name"`
|
||||
Country string `json:"country,omitempty"`
|
||||
State string
|
||||
|
|
@ -47,7 +47,7 @@ func TestNewPrompt(t *testing.T) {
|
|||
}
|
||||
for _, test := range tests {
|
||||
if diff := cmp.Diff(test.want, test.prompt.Prompt.Arguments); diff != "" {
|
||||
t.Errorf("NewPrompt(%v) mismatch (-want +got):\n%s", test.prompt.Prompt.Name, diff)
|
||||
t.Errorf("NewServerPrompt(%v) mismatch (-want +got):\n%s", test.prompt.Prompt.Name, diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue