Documentation
¶
Overview ¶
Package fieldname resolves explicitly authored MCP field identities. JSON field selection and ordinary decoding remain owned by their existing callers.
Index ¶
- func CustomJSON(t reflect.Type) bool
- func HasNames(t reflect.Type, visibility ...Visibility) (bool, error)
- func Normalize(t reflect.Type, value any, visibility ...Visibility) (any, error)
- func OptionalOwner(field reflect.StructField) bool
- func Required(field reflect.StructField) bool
- func Validate(entries []Entry) error
- type Entry
- type Name
- type Visibility
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CustomJSON ¶
func HasNames ¶
func HasNames(t reflect.Type, visibility ...Visibility) (bool, error)
HasNames checks the selected ordinary subtree without interpreting custom decoder behavior. A custom owner must provide separate decoding authority if any descendant would acquire an MCP spelling.
func Normalize ¶
Normalize only translates explicitly authored MCP names/aliases into existing JSON member names in ordinary typed bodies. JSON decoding still validates all values. Unknown keys, absence, null and empty objects/arrays are retained. Supplying more than one spelling is always an error, even for equal values.
func OptionalOwner ¶
func OptionalOwner(field reflect.StructField) bool
OptionalOwner reports whether a legacy inline embedding suppresses the required members it contributes. Legacy behavior intentionally does not let required tags on the owner override pointer, omitempty, or optional markers.
func Required ¶
func Required(field reflect.StructField) bool
Required reports the legacy MCP schema requiredness of one selected JSON field. It is schema metadata only; runtime validation is owned elsewhere.
Types ¶
type Entry ¶
type Entry struct {
Field reflect.StructField
JSONName string
Name Name
}
Entry maps a selected original JSON field to its public MCP identity.
type Visibility ¶
type Visibility struct {
ExcludeInternal bool
ExcludeField func(reflect.StructField) bool
}
Visibility carries the existing schema owner's selection policy to discovery and invocation. Its zero value preserves ordinary native JSON visibility.
func (Visibility) Excluded ¶
func (v Visibility) Excluded(owner reflect.Type, index []int) bool
Excluded follows the exact native selected index, including promoted owners. Winner selection happens before this check, so excluded winners never expose shadowed fields. Only internal:"true" is hidden by ExcludeInternal.