mcp.api.attributes

Undocumented in source.

Members

Enums

destructive
enum destructive

Marker UDA declaring the destructiveHint behavioral hint (ToolAnnotations.destructiveHint). Presence = true; absence = unset.

idempotent
enum idempotent

Marker UDA declaring the idempotentHint behavioral hint (ToolAnnotations.idempotentHint). Presence = true; absence = unset.

openWorld
enum openWorld

Marker UDA declaring the openWorldHint behavioral hint (ToolAnnotations.openWorldHint). Presence = true; absence = unset.

readOnly
enum readOnly

Marker UDA declaring the readOnlyHint behavioral hint (the MCP spec's ToolAnnotations.readOnlyHint). Attach alongside @tool; presence sets the hint to true, absence leaves it unset (omitted from the wire form).

Functions

schemaDefault
SchemaDefault!T schemaDefault(T value)

Factory producing the @schemaDefault UDA so the element type is inferred from the supplied value (@schemaDefault(false) rather than @schemaDefault!bool(false)).

Structs

SchemaDefault
struct SchemaDefault(T)

Field-level UDA declaring a default value (the JSON Schema default keyword) for a struct field. Named @schemaDefault to avoid clashing with D's default keyword. When jsonSchemaOf!T reflects over a struct, a field annotated with @schemaDefault(v) emits "default": v on its property schema, serializing the value (an enum value is emitted as its wire string, a bool as a JSON boolean, etc.).

audience
struct audience

Positional value UDA declaring the intended audience for a @resource- or @resourceTemplate-annotated method (the MCP Annotations.audience field). Pass one or more roles, e.g. @audience("user") or @audience("user", "assistant"). Absence leaves the audience unset.

cache
struct cache

UDA declaring a per-resource / per-template draft CacheableResult freshness hint for a @resource- or @resourceTemplate-annotated method. The reflection layer plumbs it through to the matching low-level registration so a draft resources/read carries ttlMs / cacheScope. Has no effect on pre-draft protocol versions (the server only emits cache fields when negotiated to draft).

describe
struct describe

Optional per-parameter description, attached to a function parameter or used alongside @tool to document a named argument.

format
struct format

Field-level UDA declaring the JSON Schema string format keyword (e.g. "email", "uri", "date-time") for a struct/elicitation field. Emitted verbatim onto the property schema by jsonSchemaOf.

hintTitle
struct hintTitle

Positional value UDA setting the annotation-level display title (ToolAnnotations.title), distinct from @tool's 3rd argument (Tool.title). Attach alongside @tool.

icon
struct icon

UDA declaring a display icon for a @tool, @resource, or @resourceTemplate-annotated method (the MCP Icons mixin: Tool.icons, Resource.icons). Attach one or more @icon UDAs to the same method; each becomes an entry in the descriptor's icons array. src is required; mimeType, sizes, and theme are optional.

lastModified
struct lastModified

Positional value UDA declaring the ISO 8601 lastModified timestamp for a @resource- or @resourceTemplate-annotated method (the MCP Annotations.lastModified field). Absence leaves it unset.

maxItems
struct maxItems

Field-level UDA declaring the JSON Schema maxItems keyword (maximum array length) for a struct/elicitation array field.

maxLength
struct maxLength

Field-level UDA declaring the JSON Schema maxLength keyword (maximum string length) for a struct/elicitation string field.

maximum
struct maximum

Field-level UDA declaring a numeric upper bound (the JSON Schema maximum keyword) for a struct field. See @minimum for usage; a field annotated with @maximum(v) emits "maximum": v on its property schema.

mcpHeader
struct mcpHeader

UDA marking a @tool parameter as mirrored into an HTTP request header.

meta
struct meta

UDA attaching a descriptor-level _meta object to a @tool, @resource, or @resourceTemplate-annotated method (the MCP _meta field on Tool, Resource, ResourceTemplate). The supplied JSON must be an object; it is emitted verbatim as the descriptor's _meta.

minItems
struct minItems

Field-level UDA declaring the JSON Schema minItems keyword (minimum array length) for a struct/elicitation array field.

minLength
struct minLength

Field-level UDA declaring the JSON Schema minLength keyword (minimum string length) for a struct/elicitation string field.

minimum
struct minimum

Field-level UDA declaring a numeric lower bound (the JSON Schema minimum keyword) for a struct field. When jsonSchemaOf!T reflects over a struct, a field annotated with @minimum(v) emits "minimum": v on its property schema. Intended for numeric / integer fields (e.g. tool input or elicitation form schemas); applying it to a non-numeric field has no defined meaning but the bound is still emitted verbatim.

pattern
struct pattern

Field-level UDA declaring the JSON Schema pattern keyword (an ECMA-262 regular expression a string must match) for a struct/elicitation field.

priority
struct priority

Positional value UDA declaring the importance priority (0.0..1.0) for a @resource- or @resourceTemplate-annotated method (the MCP Annotations.priority field). Absence leaves the priority unset.

prompt
struct prompt

UDA marking a method as an MCP prompt. The method returns the prompt's messages (a PromptMessage[], a GetPromptResult, or a string).

resource
struct resource

UDA marking a method as a static MCP resource. The method takes no arguments and returns the resource contents (string, or a ResourceContents).

resourceTemplate
struct resourceTemplate

UDA marking a method as a resource template (URI contains {var} placeholders). The method receives the captured parameters as its arguments.

title
struct title

Field-level UDA declaring a human-readable display title (the JSON Schema title keyword) for a struct field. When jsonSchemaOf!T reflects over a struct, a field annotated with @title("…") emits "title": "…" on its property schema.

tool
struct tool

UDA marking a method as an MCP tool. Apply to a member function; the input schema is derived from the parameter types, and the return value is wrapped into a tool result.

toolExecution
struct toolExecution

UDA declaring a @tool-annotated method's per-tool task-augmented execution support (the MCP 2025-11-25 Tool.execution descriptor). Attach alongside @tool; taskSupport must be "optional" or "required". Using "forbidden" (or omitting this UDA entirely) leaves the execution field absent from the wire form — both are equivalent to the spec default.