Skip to content

[plan] Add comprehensive documentation to GenerateOutputSchema #6834

@github-actions

Description

@github-actions

Objective

Add detailed documentation to GenerateOutputSchema explaining schema generation rules and MCP requirements.

Context

The function currently has minimal documentation. Users need to understand how schema generation works and what MCP tool outputs require.

Implementation

Add comprehensive godoc comment to GenerateOutputSchema function:

// GenerateOutputSchema generates a JSON schema from a Go struct type for MCP tool outputs.
// The schema conforms to JSON Schema draft 2020-12 and draft-07.
//
// Schema generation rules:
//   - json tags define property names
//   - jsonschema tags define descriptions
//   - omitempty/omitzero mark optional fields
//   - Pointer types include null in their type array
//   - Slices allow null values (jsonschema-go v0.4.0+)
//   - PropertyOrder maintains deterministic field ordering (v0.4.0+)
//
// MCP Requirements:
//   - Tool output schemas must be objects (not arrays or primitives)
//   - All properties should have descriptions for better LLM understanding
//   - Required vs optional fields must be correctly specified
//
// Example:
//
//     type Output struct {
//         Name string `json:"name" jsonschema:"Name of the user"`
//         Age  int    `json:"age,omitempty" jsonschema:"Age in years"`
//     }
//     schema, err := GenerateOutputSchema[Output]()
func GenerateOutputSchema[T any]() (*jsonschema.Schema, error) {
    return jsonschema.For[T](nil)
}

Files to Modify

  • pkg/cli/mcp_schema.go - Add documentation to GenerateOutputSchema

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