Call a server tool
UseuseCallTool() when a button, form, or other control should call an MCP tool. The hook provides the last successful result, the latest error, and the current pending state.
Export the tool reference returned by server.tool() so TypeScript can infer its input and output types in the View.
callTool() rejects when the tool returns an error or the request fails. The hook also places that failure in error so the View can render it.
Ask the model to continue
UseuseSendFollowUp() when an action requires a new model turn. The prompt appears as a user-authored message in the conversation.
useCallTool() instead when the View already knows which server operation to perform.
Open an external link
Views run in a sandbox. UseuseOpenExternal() to ask the host to open a URL outside the View.
Change the display mode
UseuseDisplayMode() when a View needs more or less space. Only offer modes included in availableDisplayModes.
displayMode for the mode the host actually applies.
Let the model act on the View
UseuseViewTool() to expose an action that operates on the mounted UI. The tool exists while the component is mounted and its handler receives the latest React state.
useCallTool() lets the View call the server. useViewTool() lets the host or model call the mounted View.
Next steps
- Use Model context to share View state and visible UI information with the model.
- Configure Content Security Policy before connecting to external APIs or loading external assets.