Skip to content

Commit 7cfdbb3

Browse files
committed
fix: change the tool result from NewToolResultStructured to NewToolResultText since there are a number of ai agents like opencode that does not support structured response
1 parent ee272bf commit 7cfdbb3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

tools/parseable_get_schema.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tools
22

33
import (
44
"context"
5+
"strings"
56

67
"github.com/mark3labs/mcp-go/mcp"
78
"github.com/mark3labs/mcp-go/server"
@@ -21,6 +22,13 @@ func RegisterGetDataStreamSchemaTool(mcpServer *server.MCPServer) {
2122
if err != nil {
2223
return mcp.NewToolResultError(err.Error()), nil
2324
}
24-
return mcp.NewToolResultStructured(map[string]interface{}{"schema": schema}, "Schema returned"), nil
25+
// Default: return as text
26+
var lines []string
27+
for field, typ := range schema {
28+
lines = append(lines, field+": "+typ)
29+
}
30+
return mcp.NewToolResultText(strings.Join(lines, "\n")), nil
31+
// Optionally, for structured output:
32+
// return mcp.NewToolResultStructured(map[string]interface{}{"schema": schema}, "Schema returned"), nil
2533
})
2634
}

0 commit comments

Comments
 (0)