internal/mcp: simplify content

Now that the protocol package is merged into the mcp package, clean up
the higher level 'Content' union types, in favor of types constructors.

Change-Id: I37bedb0ff0a296eef799ba65c37ca7f94ee1dbbe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/672415
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
Rob Findley 2025-05-13 21:51:26 +00:00 • committed by Jonathan Amsterdam
commit dac5be2c50

View file

@ -22,7 +22,7 @@ type HiParams struct {
func SayHi(ctx context.Context, cc *mcp.ServerConnection, params *HiParams) ([]mcp.Content, error) {
return []mcp.Content{
mcp.TextContent{Text: "Hi " + params.Name},
mcp.NewTextContent("Hi " + params.Name),
}, nil
}
@ -30,7 +30,7 @@ func PromptHi(ctx context.Context, cc *mcp.ServerConnection, params *HiParams) (
return &mcp.GetPromptResult{
Description: "Code review prompt",
Messages: []mcp.PromptMessage{
{Role: "user", Content: mcp.TextContent{Text: "Say hi to " + params.Name}.ToWire()},
{Role: "user", Content: mcp.NewTextContent("Say hi to " + params.Name)},
},
}, nil
}