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
|
|
@ -433,7 +433,7 @@ var (
|
|||
errTestFailure = errors.New("mcp failure")
|
||||
|
||||
tools = map[string]*ServerTool{
|
||||
"greet": NewTool("greet", "say hi", sayHi),
|
||||
"greet": NewServerTool("greet", "say hi", sayHi),
|
||||
"fail": {
|
||||
Tool: &Tool{Name: "fail"},
|
||||
Handler: func(context.Context, *ServerSession, *CallToolParamsFor[map[string]any]) (*CallToolResult, error) {
|
||||
|
|
@ -443,7 +443,7 @@ var (
|
|||
}
|
||||
|
||||
prompts = map[string]*ServerPrompt{
|
||||
"code_review": NewPrompt("code_review", "do a code review",
|
||||
"code_review": NewServerPrompt("code_review", "do a code review",
|
||||
func(_ context.Context, _ *ServerSession, params struct{ Code string }, _ *GetPromptParams) (*GetPromptResult, error) {
|
||||
return &GetPromptResult{
|
||||
Description: "Code review prompt",
|
||||
|
|
@ -452,7 +452,7 @@ var (
|
|||
},
|
||||
}, nil
|
||||
}),
|
||||
"fail": NewPrompt("fail", "", func(_ context.Context, _ *ServerSession, args struct{}, _ *GetPromptParams) (*GetPromptResult, error) {
|
||||
"fail": NewServerPrompt("fail", "", func(_ context.Context, _ *ServerSession, args struct{}, _ *GetPromptParams) (*GetPromptResult, error) {
|
||||
return nil, errTestFailure
|
||||
}),
|
||||
}
|
||||
|
|
@ -556,7 +556,7 @@ func basicConnection(t *testing.T, tools ...*ServerTool) (*ServerSession, *Clien
|
|||
}
|
||||
|
||||
func TestServerClosing(t *testing.T) {
|
||||
cc, cs := basicConnection(t, NewTool("greet", "say hi", sayHi))
|
||||
cc, cs := basicConnection(t, NewServerTool("greet", "say hi", sayHi))
|
||||
defer cs.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
|
|
|
|||
Loading…
Reference in a new issue