React hooks and providers for MCP integration in browser applications
@mcp-b/mcp-react-hooks
package provides React hooks for integrating the Model Context Protocol (MCP) into React applications. The primary hook useMcpClient
is used extensively in production for connecting to MCP servers, listing tools, and managing connections. The package also provides useMcpServer
for creating MCP servers within React components.
Property | Type | Description |
---|---|---|
client | Client | MCP client instance |
tools | McpTool[] | Available tools from server |
resources | Resource[] | Available resources |
isConnected | boolean | Connection status |
isLoading | boolean | Loading state |
error | Error | null | Connection error if any |
capabilities | ServerCapabilities | null | Server capabilities |
reconnect | () => Promise<void> | Manual reconnection function |
Property | Type | Description |
---|---|---|
server | McpServer | MCP server instance |
isConnected | boolean | Connection status |
isConnecting | boolean | Connection in progress |
error | Error | null | Connection error if any |
registerTool | Function | Register a tool dynamically |
elicitInput | Function | Request input from client |