pub enum Primitive {
Tool(Tool),
Resource(Resource),
ResourceTemplate(ResourceTemplate),
Prompt(Prompt),
}Expand description
Any primitive, tagged with its kind.
The four payloads stay separate types rather than collapsing into one
struct with fourteen Option fields, because the fields that matter are not
shared: Tool has an input schema and no uri, Resource has a uri and no
input schema, and a single flat struct would let a resource be built with
an input schema and no way to say whether that was a mistake.
Variants§
Tool(Tool)
A tool.
Resource(Resource)
A resource.
ResourceTemplate(ResourceTemplate)
A resource template.
Prompt(Prompt)
A prompt.
Implementations§
Source§impl Primitive
impl Primitive
Sourcepub const fn kind(&self) -> PrimitiveKind
pub const fn kind(&self) -> PrimitiveKind
Which list this belongs to.
Sourcepub const fn id(&self) -> &PrimitiveId
pub const fn id(&self) -> &PrimitiveId
The key this primitive is filed under.
Sourcepub fn meta(&self) -> PrimitiveMeta
pub fn meta(&self) -> PrimitiveMeta
The metadata a visibility decision is made from.
Derived from the payload rather than stored beside it, so the two
cannot disagree — a separate meta field would be a second source of
truth for a thing the payload already determines.
§What derives a requirement, and what does not
A requirement is raised when a session cannot correctly use the primitive without the feature. That is a narrower test than “the primitive has a field the revision does not define”, and the difference decides whether a feature is a gate or a filter.
A tool’s outputSchema is a gate. A tool that declares structured
output answers with a structuredContent member, and a session that
cannot represent it does not get a text fallback from the registry — it
gets a result whose shape it will misread. This is the same
StructuredContentToText decision the lowering path already made, and
the registry has to agree with it or the two disagree about the same
tool on the same session.
Annotations, icons, title and size are not gates. An older peer
ignores a hint it does not recognise and the tool still works, which is
the same reason Annotations does not raise
required_features on a content block. Requiring a feature for
decoration would hide a perfectly callable tool from every session on an
older revision, and the hiding is silent — the peer simply never sees
the tool.