jsonResult marshals v as pretty JSON and returns it as the tool's TextContent payload. Errors during marshalling become tool errors.
(v any)
| 24 | // jsonResult marshals v as pretty JSON and returns it as the tool's |
| 25 | // TextContent payload. Errors during marshalling become tool errors. |
| 26 | func jsonResult(v any) *mcp.CallToolResult { |
| 27 | data, err := json.MarshalIndent(v, "", " ") |
| 28 | if err != nil { |
| 29 | return errorResult(fmt.Errorf("marshal tool result: %w", err)) |
| 30 | } |
| 31 | return &mcp.CallToolResult{ |
| 32 | Content: []mcp.Content{&mcp.TextContent{Text: string(data)}}, |
| 33 | } |
| 34 | } |
no test coverage detected