Const// Preferred: Use registerAppTool with nested ui.resourceUri
registerAppTool(
server,
"weather",
{
description: "Get weather forecast",
_meta: {
ui: { resourceUri: "ui://weather/forecast" },
},
},
handler,
);
// Deprecated: Direct use of RESOURCE_URI_META_KEY
server.registerTool(
"weather",
{
description: "Get weather forecast",
_meta: {
[RESOURCE_URI_META_KEY]: "ui://weather/forecast",
},
},
handler,
);
// Hosts should check both modern and legacy formats
const meta = tool._meta;
const uiMeta = meta?.ui as McpUiToolMeta | undefined;
const legacyUri = meta?.[RESOURCE_URI_META_KEY] as string | undefined;
const uiUri = uiMeta?.resourceUri ?? legacyUri;
if (typeof uiUri === "string" && uiUri.startsWith("ui://")) {
// Fetch the resource and display the UI
}
Metadata key for associating a UI resource URI with a tool.
MCP servers include this key in tool definition metadata (via
tools/list) to indicate which UI resource should be displayed when the tool is called. When hosts see a tool with this metadata, they fetch and render the correspondingApp.Note: This constant is provided for reference and backwards compatibility. Server developers should use
registerAppToolwith the_meta.ui.resourceUriformat instead. Host developers must check both formats for compatibility.