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:
parent
4f6510b9ae
commit
dac5be2c50
1 changed files with 107 additions and 207 deletions
|
|
@ -9,7 +9,6 @@ import (
|
|||
"encoding/json"
|
||||
"slices"
|
||||
|
||||
"github.com/modelcontextprotocol/go-sdk/internal/util"
|
||||
"github.com/modelcontextprotocol/go-sdk/jsonschema"
|
||||
)
|
||||
|
||||
|
|
@ -56,12 +55,12 @@ func NewTool[TReq any](name, description string, handler func(context.Context, *
|
|||
// rather than returned as jsonrpc2 server errors.
|
||||
if err != nil {
|
||||
return &CallToolResult{
|
||||
Content: []WireContent{TextContent{Text: err.Error()}.ToWire()},
|
||||
Content: []Content{NewTextContent(err.Error())},
|
||||
IsError: true,
|
||||
}, nil
|
||||
}
|
||||
res := &CallToolResult{
|
||||
Content: util.Apply(content, Content.ToWire),
|
||||
Content: content,
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue