Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/3
This commit is contained in:
hiifong
2025-03-24 05:23:50 +00:00
parent 4f781f2ddb
commit 7845a84c4e

View File

@@ -8,11 +8,16 @@ import (
"github.com/mark3labs/mcp-go/mcp"
)
type textResult struct {
Result any
}
func TextResult(v any) (*mcp.CallToolResult, error) {
result, err := json.Marshal(v)
result := textResult{v}
resultBytes, err := json.Marshal(result)
if err != nil {
return nil, fmt.Errorf("marshal result err: %v", err)
}
log.Debugf("Text Result: %s", string(result))
return mcp.NewToolResultText(string(result)), nil
log.Debugf("Text Result: %s", string(resultBytes))
return mcp.NewToolResultText(string(resultBytes)), nil
}