Files
gin-vue-admin/server/mcp/result.go
T
PiexlMax(奇淼 375b21c222 发布2.9.1版本 (#2189)
* feat: mcp能力调整为 streamhttp的独立服务 不再依赖gva本体

* feat: 增加MCP启动能力,增加AI工作流需求整理能力。

* feat: 增加需求梳理能力

* feat: 清理无用日志

* feat: 移除无用的Dify Chatflow文本和代码生成器按钮
2026-03-27 12:14:13 +08:00

30 lines
535 B
Go

package mcpTool
import (
"encoding/json"
"fmt"
"github.com/mark3labs/mcp-go/mcp"
)
func textResultWithJSON(title string, payload any) (*mcp.CallToolResult, error) {
resultJSON, err := json.MarshalIndent(payload, "", " ")
if err != nil {
return nil, fmt.Errorf("序列化结果失败: %w", err)
}
text := string(resultJSON)
if title != "" {
text = fmt.Sprintf("%s\n\n%s", title, text)
}
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.TextContent{
Type: "text",
Text: text,
},
},
}, nil
}