useApp

bitmcp/react View runtime and official hook re-exports.

Import from bitmcp/react:

import { useApp } from "bitmcp/react";

const { result, callTool, app, isConnected, error } = useApp();

File-based tools generate .bitmcp/views.d.ts so result is inferred from the sibling tool. Pass a generic only when you need to override that.

Fields

FieldDescription
resultstructuredContent from the host via ontoolresult, or from callTool
callTool(name, args?)Calls a backing tool through the host and updates result
appOfficial Apps client instance
isConnectedConnection state
errorConnection error if any

callTool keeps a stable function identity so poll intervals do not reset every render.

Escape hatches

Re-exported from @modelcontextprotocol/ext-apps/react:

import { useMcpApp, useHostStyles } from "bitmcp/react";

Use these only when you need direct access to the official client. The happy path is useApp().

AppShell

The compiler injects AppShell in the HTML shell. Authors do not render it in view.tsx.