mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 22:33:05 +00:00
11
pkg/to/to.go
11
pkg/to/to.go
@@ -8,11 +8,16 @@ import (
|
|||||||
"github.com/mark3labs/mcp-go/mcp"
|
"github.com/mark3labs/mcp-go/mcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type textResult struct {
|
||||||
|
Result any
|
||||||
|
}
|
||||||
|
|
||||||
func TextResult(v any) (*mcp.CallToolResult, error) {
|
func TextResult(v any) (*mcp.CallToolResult, error) {
|
||||||
result, err := json.Marshal(v)
|
result := textResult{v}
|
||||||
|
resultBytes, err := json.Marshal(result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("marshal result err: %v", err)
|
return nil, fmt.Errorf("marshal result err: %v", err)
|
||||||
}
|
}
|
||||||
log.Debugf("Text Result: %s", string(result))
|
log.Debugf("Text Result: %s", string(resultBytes))
|
||||||
return mcp.NewToolResultText(string(result)), nil
|
return mcp.NewToolResultText(string(resultBytes)), nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user