Objective
Refactor GenerateOutputSchema function to use the more idiomatic For[T]() pattern instead of manual reflection.
Context
The current implementation uses reflect.TypeOf() indirection, but the library provides a cleaner generic For[T]() function.
Current Implementation
func GenerateOutputSchema[T any]() (*jsonschema.Schema, error) {
var zero T
typ := reflect.TypeOf(zero)
return jsonschema.ForType(typ, &jsonschema.ForOptions{})
}
Proposed Implementation
func GenerateOutputSchema[T any]() (*jsonschema.Schema, error) {
return jsonschema.For[T](nil)
}
Benefits
- Cleaner code (3 lines → 1 line)
- No reflect.TypeOf indirection
- More idiomatic library usage
- Better error messages with type names
Files to Modify
pkg/cli/mcp_schema.go - Update GenerateOutputSchema function
Acceptance Criteria
AI generated by Plan Command for discussion #6818
Objective
Refactor
GenerateOutputSchemafunction to use the more idiomaticFor[T]()pattern instead of manual reflection.Context
The current implementation uses
reflect.TypeOf()indirection, but the library provides a cleaner genericFor[T]()function.Current Implementation
Proposed Implementation
Benefits
Files to Modify
pkg/cli/mcp_schema.go- Update GenerateOutputSchema functionAcceptance Criteria
jsonschema.For[T](nil)patternRelated to [plan] Upgrade and enhance google/jsonschema-go integration #6830