Skip to main content
The 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 happens
  • finishAuth(state, code) completes the authorization code exchange
The popup helpers are optional convenience utilities on top of that. You can:
  • 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

Use this when you want branded popup visuals without rebuilding the postMessage / finishAuth coordination yourself.

Full-page redirect flow

Use this when you do not want popups at all and prefer a normal callback route.

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