useMcp hook provides a simple way to manage MCP connections in React applications.
Basic Usage
Configuration Options
Return Values
State
Connection Methods
Tool Operations
Prompt Operations
Resource Operations
Utility Methods
Connection Object
Each connection has the following structure:Connection States
Connections progress through these states:Event Handling
Handle connection events for custom logic:Examples
Connect and Call Tool
Display Connection Status
Handle OAuth Redirect
OAuth UI Patterns
OAuth handling in the React client is built around two core primitives:useMcp({ onRedirect })decides how auth navigation happensfinishAuth(sessionId, code)completes the authorization code exchange
- use the shared popup helpers as-is
- bring your own popup UI
- skip popups entirely and use a normal callback page
Turnkey popup flow
Custom popup UI with shared callback logic
postMessage / finishAuth coordination yourself.
Full-page redirect flow
TypeScript Types
Import types for better type safety:Next Steps
- MCP Apps — Interactive tool UIs (
McpAppRenderer, sandbox proxy, AppBridge) - API Reference - Complete API documentation
- Examples - More practical examples

