Connecting...
;
+
+ return (
+
+
Theme: {hostContext?.theme}
+
Locale: {hostContext?.locale}
+
Viewport: {hostContext?.containerDimensions?.width} x {hostContext?.containerDimensions?.height}
+
Platform: {hostContext?.platform}
+
+ );
+}
+```
+
+:::tip
+If you're using the `useApp` hook in your MCP App, the hook provides a `onhostcontextchanged` listener. You can then use a React `useState` to update your app context. The host will provide their context, it's up to you as the app developer to decide what you want to do with that. For example, you can use theme to render light mode vs dark mode, locale to show a different language, or containerDimensions to adjust the app's sizing.
+:::
+
+## Tip 2: Control What the Model Sees and What the View Sees
+
+There are cases where you may want to have granular control over what data the LLM has access to, and what data the view can show. The MCP Apps spec specifies three different tool return values that lets you control data flow, each are handled differently by the app host.
+
+- `content`: Content is the info that you want to expose to the model. Gives model context.
+- `structuredContent`: This data is hidden from the model context. It is used to send data over the View for hydration.
+- `_meta`: This data is hidden from the model context. Used to provide additional info such as timestamps, version info.
+
+Let's look at a practical example of how we can use these three tool return types effectively:
+
+```ts
+server.registerTool(
+ "view-cocktail",
+ {
+ title: "Get Cocktail",
+ description: "Fetch a cocktail by id with ingredients and images...",
+ inputSchema: z.object({ id: z.string().describe("The id of the cocktail to fetch.") }),
+ _meta: {
+ ui: { resourceUri: "ui://cocktail/cocktail-recipe-widget.html" },
+ },
+ },
+ async ({ id }: { id: string }): Promise