pub struct ResourceDef { /* private fields */ }Expand description
A registered resource or resource template.
Implementations§
Source§impl ResourceDef
impl ResourceDef
Sourcepub fn app(self, ui: AppUi) -> Self
pub fn app(self, ui: AppUi) -> Self
Makes this an MCP Apps interface: an HTML5 page served with the
text/html;profile=mcp-app MIME type at a ui:// URI, sandboxed as
ui describes. Tools show it with ToolDef::ui.
Sourcepub fn scopes<I, S>(self, scopes: I) -> Self
pub fn scopes<I, S>(self, scopes: I) -> Self
Declares the OAuth scopes a caller needs (all of them). Enforced when
the HTTP transport requires OAuth; the client gets 403 with an
insufficient_scope challenge listing these scopes.
Sourcepub fn required_scopes(&self) -> &[String]
pub fn required_scopes(&self) -> &[String]
The OAuth scopes declared with scopes.
Sourcepub fn new(resource: Resource, read: ReadFn) -> Self
pub fn new(resource: Resource, read: ReadFn) -> Self
A resource with a fixed URI (listed by resources/list).
Sourcepub fn template(template: ResourceTemplate, read: ReadFn) -> Self
pub fn template(template: ResourceTemplate, read: ReadFn) -> Self
A resource template (listed by resources/templates/list). The
uriTemplate must use the supported RFC 6570 subset (see
UriTemplate).
Sourcepub fn require_state<T: Send + Sync + 'static>(self) -> Self
pub fn require_state<T: Send + Sync + 'static>(self) -> Self
Declares that the resource needs shared state of type T.
Sourcepub fn ttl(self, ttl: Duration) -> Self
pub fn ttl(self, ttl: Duration) -> Self
Freshness hint (ttlMs) of read results. Default: zero (always
re-fetch).
Sourcepub fn cache_scope(self, scope: CacheScope) -> Self
pub fn cache_scope(self, scope: CacheScope) -> Self
cacheScope of read results. Default: private, since contents often
depend on the caller. Use public for data identical for everyone.
Sourcepub fn complete(self, variable: impl Into<String>, complete: CompleteFn) -> Self
pub fn complete(self, variable: impl Into<String>, complete: CompleteFn) -> Self
Attaches a completion provider to a template variable.
Sourcepub fn is_template(&self) -> bool
pub fn is_template(&self) -> bool
Whether this is a resource template.