useMcp(options)
React hook for managing MCP connections.
url- MCP endpoint URLuserId- User identifierauthToken- Authentication tokenautoConnect- Auto-connect on mountautoInitialize- Auto-load sessions on mountonRedirect- Override the default OAuth redirect behavioronConnectionEvent- Connection event handleronLog- Debug log handlerrequestTimeout- Reserved for future request-timeout controldebug- Enable client debug logs
useMcpApps(mcpClient) (Deprecated)
Prefer the standaloneReact helper for MCP Apps (interactive tool UIs in a sandboxed iframe via AppBridge).McpAppRenderercomponent andgetMcpAppMetadata()utility from@mcp-ts/sdk/client/reactfor new code.
mcpClient- Object shaped likeuseMcp()’s return.nullis allowed when disconnected.
getAppMetadata(toolName: string)- Resolves UI metadata for a tool.McpAppRenderer- Stable component for rendering a tool UI.
getMcpAppMetadata(mcpClient, toolName, input?)
Returns: McpAppMetadata | undefined
McpAppRenderer Component
The standalone <McpAppRenderer> component renders inline MCP Apps inside a sandboxed iframe. For ui:// and mcp-app:// HTML, pass a sandbox configuration pointing at your proxy page.
useAppHost(client, iframeRef, options?)
Lower-level React helper that constructs an AppHost for a given iframe ref.
AppHost
Core MCP App host: AppBridge setup, sandbox proxy launch, resource fetch/cache, and tool I/O.
Constructor
Selected methods
start(): Promise<void>preload(tools): voidlaunch(source, sessionId?): Promise<void>sendToolInput(args): voidsendToolResult(result): voidsendToolCancelled(reason): voidsendToolInputPartial(params): voidsetHostContext(context): void
SSEClient
Lower-level MCP transport client for custom implementations. It uses streamed POST requests and emits connection and observability events from the response stream.
Methods
connect(): voiddisconnect(): voidlistSessions(): Promise<SessionListResult>connectToServer(config): Promise<{ sessionId: string }>disconnectFromServer(sessionId): Promise<{ success: true }>getSession(sessionId): Promise<GetSessionResult>finishAuth(state, code): Promise<FinishAuthResult>callTool(sessionId, name, args): Promise<unknown>listTools(sessionId): Promise<ListToolsRpcResult>listPrompts(sessionId): Promise<ListPromptsResult>getPrompt(sessionId, name, args?): Promise<unknown>listResources(sessionId): Promise<ListResourcesResult>readResource(sessionId, uri): Promise<unknown>

