Skip to main content

MCP Hooks

React hooks for interacting with MCP servers from within your App components. All hooks work within an AppProvider or GPTAppProvider context.

useTool

The primary hook for calling MCP tools with full state management, retries, and result transformation.

Basic Usage

With Arguments

With Options

Return Value

Options


useResource

Read MCP server resources with auto-refresh and subscription support.

Basic Usage

With Auto-Refresh

Return Value

Options


useMessage

Send messages to the host chat interface.

Return Value


useHostContext

Access host environment information like theme, viewport, and display mode.

Return Value


useToolResult

Access the tool result passed from the host when rendering a tool-linked UI.

useToolInput

Access the tool input arguments when the host is streaming input to your app.

useToolStream

Handle streaming tool responses with partial updates.

useMcpApp

Low-level hook to access the full MCP App context. Most use cases are covered by the specialized hooks above.