Skip to content

[plan] Simplify GenerateOutputSchema to use idiomatic For[T]() pattern #6832

@github-actions

Description

@github-actions

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

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions