MCPcopy
hub / github.com/github/github-mcp-server / wrapHandlerWithCSVOutput

Function wrapHandlerWithCSVOutput

pkg/github/csv_output.go:71–86  ·  view source on GitHub ↗
(next inventory.HandlerFunc)

Source from the content-addressed store, hash-verified

69}
70
71func wrapHandlerWithCSVOutput(next inventory.HandlerFunc) inventory.HandlerFunc {
72 return func(deps any) mcp.ToolHandler {
73 handler := next(deps)
74 csvDeps, _ := deps.(ToolDependencies)
75 return func(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
76 result, err := handler(ctx, req)
77 if err != nil || result == nil || result.IsError {
78 return result, err
79 }
80 if csvDeps == nil || !csvDeps.IsFeatureEnabled(ctx, FeatureFlagCSVOutput) {
81 return result, nil
82 }
83 return convertJSONTextResultToCSV(result), nil
84 }
85 }
86}
87
88func convertJSONTextResultToCSV(result *mcp.CallToolResult) *mcp.CallToolResult {
89 if len(result.Content) != 1 {

Callers 1

withCSVOutputFunction · 0.85

Calls 2

IsFeatureEnabledMethod · 0.65

Tested by

no test coverage detected