pub struct UIResource {
pub uri: String,
pub name: String,
pub description: Option<String>,
pub mime_type: String,
}Expand description
UI Resource declaration
UI resources are pre-declared interface templates that can be rendered by MCP hosts.
They use the ui:// URI scheme and are typically associated with tools via metadata.
§Example
use pmcp::types::ui::UIResource;
let resource = UIResource {
uri: "ui://settings/form".to_string(),
name: "Settings Form".to_string(),
description: Some("Configure application settings".to_string()),
mime_type: "text/html;profile=mcp-app".to_string(),
};Fields§
§uri: StringURI with ui:// scheme
Must start with “ui://” followed by a path-like identifier. Example: ui://charts/bar-chart
name: StringHuman-readable name for the UI resource
description: Option<String>Optional description of what this UI resource provides
mime_type: StringMIME type of the UI resource
Standard: "text/html;profile=mcp-app" (recommended for all hosts)
Legacy: "text/html+mcp" (still accepted by some hosts)
Implementations§
Source§impl UIResource
impl UIResource
Sourcepub fn new(
uri: impl Into<String>,
name: impl Into<String>,
mime_type: UIMimeType,
) -> Self
pub fn new( uri: impl Into<String>, name: impl Into<String>, mime_type: UIMimeType, ) -> Self
Create a new UI resource
Sourcepub fn html_mcp_app(uri: impl Into<String>, name: impl Into<String>) -> Self
pub fn html_mcp_app(uri: impl Into<String>, name: impl Into<String>) -> Self
Create a new HTML UI resource with the standard MCP Apps MIME type
(text/html;profile=mcp-app).
This is the recommended constructor for widget resources that work
across Claude Desktop, ChatGPT, and other MCP hosts.
§Example
use pmcp::types::ui::UIResource;
let resource = UIResource::html_mcp_app(
"ui://settings/form",
"Settings Form",
);
assert_eq!(resource.mime_type, "text/html;profile=mcp-app");Sourcepub fn html_mcp(uri: impl Into<String>, name: impl Into<String>) -> Self
👎Deprecated since 1.16.1: Use html_mcp_app() which produces text/html;profile=mcp-app recognized by Claude Desktop
pub fn html_mcp(uri: impl Into<String>, name: impl Into<String>) -> Self
Use html_mcp_app() which produces text/html;profile=mcp-app recognized by Claude Desktop
Create a new HTML UI resource with legacy MCP mime type (text/html+mcp).
Deprecated: Prefer html_mcp_app() which uses
text/html;profile=mcp-app — the standard MIME type recognized by
Claude Desktop and other MCP hosts.
§Example
#[allow(deprecated)]
let resource = pmcp::types::ui::UIResource::html_mcp(
"ui://settings/form",
"Settings Form",
);Sourcepub fn html_skybridge(uri: impl Into<String>, name: impl Into<String>) -> Self
pub fn html_skybridge(uri: impl Into<String>, name: impl Into<String>) -> Self
Create a new HTML UI resource with ChatGPT Skybridge mime type.
§Example
use pmcp::types::ui::UIResource;
let resource = UIResource::html_skybridge(
"ui://chess/board",
"Chess Board",
);Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the description
Sourcepub fn validate_uri(&self) -> Result<()>
pub fn validate_uri(&self) -> Result<()>
Validate that the URI starts with “ui://”
Trait Implementations§
Source§impl Clone for UIResource
impl Clone for UIResource
Source§fn clone(&self) -> UIResource
fn clone(&self) -> UIResource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UIResource
impl Debug for UIResource
Source§impl<'de> Deserialize<'de> for UIResource
impl<'de> Deserialize<'de> for UIResource
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for UIResource
Source§impl JsonSchema for UIResource
Available on crate feature schema-generation only.
impl JsonSchema for UIResource
schema-generation only.Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for UIResource
impl PartialEq for UIResource
Source§impl Serialize for UIResource
impl Serialize for UIResource
impl StructuralPartialEq for UIResource
Auto Trait Implementations§
impl Freeze for UIResource
impl RefUnwindSafe for UIResource
impl Send for UIResource
impl Sync for UIResource
impl Unpin for UIResource
impl UnsafeUnpin for UIResource
impl UnwindSafe for UIResource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.