File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -1123,24 +1123,25 @@ Future versions may add additional settings:
11231123Servers 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+
11261128const hasUISupport =
11271129 clientCapabilities ?.extensions ?.[" io.modelcontextprotocol/ui" ]?.mimeTypes ?.includes (" text/html;profile=mcp-app" );
11281130
11291131if (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```
You can’t perform that action at this time.
0 commit comments