Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Envelope ¶
type Envelope struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema *InputSchema `json:"inputSchema"`
OutputSchema *OutputSchema `json:"outputSchema"`
Meta *Meta `json:"_meta"`
}
Envelope is the MCP Tool spec contract for a single API method command.
func EnvelopeOf ¶ added in v1.0.54
func EnvelopeOf(ref apicatalog.MethodRef) Envelope
EnvelopeOf renders the MCP envelope for one method ref — the ref-based entry callers use, since apicatalog.MethodRef is the metadata navigation currency.
func Envelopes ¶ added in v1.0.54
func Envelopes(refs []apicatalog.MethodRef) []Envelope
Envelopes renders the given method refs into envelopes, sorted by name. The caller supplies the refs (from apicatalog navigation), so this package owns only rendering — never metadata source selection or traversal.
type InputSchema ¶
type InputSchema struct {
Type string `json:"type"`
Required []string `json:"required"`
Properties *OrderedProps `json:"properties"`
}
InputSchema is JSON Schema Draft 2020-12 flattened.
Required is intentionally rendered (no omitempty) so the envelope shape stays stable for AI consumers — an empty []string means "no required fields" rather than "schema is missing the field".
type Meta ¶
type Meta struct {
EnvelopeVersion string `json:"envelope_version"`
Scopes []string `json:"scopes"`
RequiredScopes []string `json:"required_scopes"`
AccessTokens []string `json:"access_tokens"`
Danger bool `json:"danger"`
Risk string `json:"risk"`
DocURL string `json:"doc_url,omitempty"`
Affordance *meta.Affordance `json:"affordance,omitempty"`
}
Meta is the Lark-specific extension namespace.
type OrderedProps ¶
OrderedProps is map[string]Property with preserved key order on MarshalJSON. It is used wherever JSON output must reflect meta_data.json's natural field order rather than Go's default alphabetical map encoding.
func (*OrderedProps) MarshalJSON ¶
func (o *OrderedProps) MarshalJSON() ([]byte, error)
MarshalJSON emits keys in Order, not alphabetical. If Order is empty but Map has entries, fall back to alphabetical key order over Map so callers that only populated Map (no explicit ordering) still see their fields.
func (*OrderedProps) Set ¶ added in v1.0.54
func (o *OrderedProps) Set(key string, p Property)
Set adds or replaces a property, recording first-seen keys in Order so JSON output preserves insertion order. Re-setting an existing key updates its value without reordering. Centralizing mutation here keeps Order and Map from drifting out of sync.
func (*OrderedProps) UnmarshalJSON ¶
func (o *OrderedProps) UnmarshalJSON(data []byte) error
UnmarshalJSON parses an object preserving key order via json.Decoder.Token(). Used for round-tripping in tests (and future golden update flows).
type OutputSchema ¶
type OutputSchema struct {
Type string `json:"type"`
Properties *OrderedProps `json:"properties"`
}
OutputSchema wraps responseBody into a JSON Schema object.
type Property ¶
type Property struct {
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
// EnumDescriptions, when present, is parallel to Enum: the human meaning of
// each allowed value, in the same order. Omitted when no value carries a
// description. This is the widely-recognized JSON-Schema extension (VS Code,
// OpenAPI tooling) that lets an AI consumer learn what each enum value means
// without a second lookup.
EnumDescriptions []string `json:"enumDescriptions,omitempty"`
Default interface{} `json:"default,omitempty"`
Example interface{} `json:"example,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
Maximum *float64 `json:"maximum,omitempty"`
Format string `json:"format,omitempty"`
Required []string `json:"required,omitempty"`
Properties *OrderedProps `json:"properties,omitempty"`
Items *Property `json:"items,omitempty"`
}
Property is one field's JSON Schema shape, recursive.
Required is used when Property describes a nested object (e.g. the "params" / "data" sub-objects inside inputSchema): it lists which keys inside that object's Properties are mandatory. Leaf fields ignore it.
func Convert ¶ added in v1.0.54
Convert renders a meta.Field as a JSON-Schema Property. meta owns the value normalization (canonical type, literal coercion, enum ordering); this adds only the JSON-Schema-specific shape: the "file" binary format, numeric bounds, nested object/array properties, and the array-items fallback.