mirror of
				https://gitea.com/gitea/gitea-mcp.git
				synced 2025-11-04 04:11:50 +00:00 
			
		
		
		
	Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/6 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: hiifong <i@hiif.ong> Co-committed-by: hiifong <i@hiif.ong>
		
			
				
	
	
		
			29 lines
		
	
	
		
			572 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			572 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package to
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
	"fmt"
 | 
						|
 | 
						|
	"gitea.com/gitea/gitea-mcp/pkg/log"
 | 
						|
	"github.com/mark3labs/mcp-go/mcp"
 | 
						|
)
 | 
						|
 | 
						|
type textResult struct {
 | 
						|
	Result any
 | 
						|
}
 | 
						|
 | 
						|
func TextResult(v any) (*mcp.CallToolResult, error) {
 | 
						|
	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(resultBytes))
 | 
						|
	return mcp.NewToolResultText(string(resultBytes)), nil
 | 
						|
}
 | 
						|
 | 
						|
func ErrorResult(err error) (*mcp.CallToolResult, error) {
 | 
						|
	log.Errorf(err.Error())
 | 
						|
	return nil, err
 | 
						|
}
 |