Skip to content

Commit a885b6f

Browse files
committed
docs: use registerAppTool helper in MDX example
1 parent bea0ae2 commit a885b6f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

specification/draft/apps.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,24 +1123,25 @@ Future versions may add additional settings:
11231123
Servers SHOULD check client (host would-be) capabilities before registering UI-enabled tools:
11241124

11251125
```typescript
1126+
import { registerAppTool, RESOURCE_URI_META_KEY } from "@modelcontextprotocol/ext-apps/server";
1127+
11261128
const hasUISupport =
11271129
clientCapabilities?.extensions?.["io.modelcontextprotocol/ui"]?.mimeTypes?.includes("text/html;profile=mcp-app");
11281130

11291131
if (hasUISupport) {
1130-
// Register tools with UI templates
1131-
server.registerTool("get_weather", {
1132+
// Register tools with UI templates using the helper
1133+
registerAppTool(server, "get_weather", {
11321134
description: "Get weather with interactive dashboard",
11331135
inputSchema: { /* ... */ },
11341136
_meta: {
1135-
"ui/resourceUri": "ui://weather-server/dashboard"
1137+
[RESOURCE_URI_META_KEY]: "ui://weather-server/dashboard"
11361138
}
1137-
});
1139+
}, async (args) => { /* ... */ });
11381140
} else {
1139-
// Register text-only version
1141+
// Register text-only version (no helper needed)
11401142
server.registerTool("get_weather", {
11411143
description: "Get weather as text",
11421144
inputSchema: { /* ... */ }
1143-
// No UI metadata
11441145
});
11451146
}
11461147
```

0 commit comments

Comments
 (0)