wrapAsApplication method

Map<String, dynamic> wrapAsApplication(
  1. Map<String, dynamic> definition, {
  2. required String appUri,
})

Promote a served UI definition to AppPlayer's standard app-execution structure: a type:"application" document with a single route pointing at appUri. A definition that is already an application passes through unchanged.

Every app — even a one-page server board — must run as an application so the runtime mounts the routing pipeline: each route renders through MCPPageWidget, which frames the page in a Scaffold and lifts the page's own title into an AppBar (a bare page rendered directly gets neither). The application structure is also what makes the dashboard slot and navigation available. The visible name comes from the page title here, so a board that serves no ui://app/info metadata still shows its name — the app structure carries it, no separate metadata fetch required.

Implementation

Map<String, dynamic> wrapAsApplication(
  Map<String, dynamic> definition, {
  required String appUri,
}) {
  if (definition['type'] == 'application') return definition;
  final title = definition['title'];
  return <String, dynamic>{
    'type': 'application',
    if (title is String && title.isNotEmpty) 'title': title,
    'routes': <String, dynamic>{'/': appUri},
    'initialRoute': '/',
  };
}