internal/mcp/design: further clean-up

Do a pass through the design doc, adding a bit more clean-up and
commentary.

Additionally, update ServerTool and ServerPrompt to be consistent with
the design.

Change-Id: I1b75c4690d86fe8946d512cb36a1fc2938b3c883
Reviewed-on: https://go-review.googlesource.com/c/tools/+/672576
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Rob Findley 2025-05-14 18:28:24 +00:00 • committed by Gopher Robot
commit 7eadde0a23

View file

@ -17,8 +17,8 @@ type ToolHandler func(context.Context, *ServerSession, *CallToolParams) (*CallTo
// A Tool is a tool definition that is bound to a tool handler.
type ServerTool struct {
Definition *Tool
Handler ToolHandler
Tool *Tool
Handler ToolHandler
}
// NewTool is a helper to make a tool using reflection on the given handler.
@ -59,7 +59,7 @@ func NewTool[TReq any](name, description string, handler func(context.Context, *
return res, nil
}
t := &ServerTool{
Definition: &Tool{
Tool: &Tool{
Name: name,
Description: description,
InputSchema: schema,
@ -94,7 +94,7 @@ func (s toolSetter) set(t *ServerTool) { s(t) }
func Input(opts ...SchemaOption) ToolOption {
return toolSetter(func(t *ServerTool) {
for _, opt := range opts {
opt.set(t.Definition.InputSchema)
opt.set(t.Tool.InputSchema)
}
})
}