alepha@docs:~/framework/docs/reference/react-hooks$
cat useMcpApp.md | pretty
1 min read
Last commit:

#useMcpApp

#Import

typescript
1import { useMcpApp } from "alepha/mcp/view";

#Overview

The MCP Apps call this view shows: the tool's input and result as the host sends them, its theme, and the requests a view may make back.

tsx
 1const SalesChart = () => { 2  const app = useMcpApp(); 3  const total = app.result?.structuredContent?.total; 4  return ( 5    <button onClick={() => app.callTool("refresh_sales")}> 6      {total ?? "Loading"} 7    </button> 8  ); 9};10export default SalesChart;

Only inside a view mounted by McpView.mount, which alepha build and alepha dev do for a $tool({ ui: { view } }), or under an explicit bridge.