UNPKG

mcp-use

Version:

Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.

34 lines 1.11 kB
import type { UseMcpOptions, UseMcpResult } from "./types.js"; /** * React hook for connecting to and interacting with MCP servers * * Provides a complete interface for MCP server connections including: * - Automatic connection management with reconnection * - OAuth authentication with automatic token refresh * - Tool, resource, and prompt access * - AI chat functionality with conversation memory * - Multi-transport support (HTTP, SSE) with automatic fallback * * @param options - Configuration options for the MCP connection * @returns MCP connection state and methods * * @example * ```typescript * const mcp = useMcp({ * url: 'http://localhost:3000/mcp', * headers: { Authorization: 'Bearer YOUR_API_KEY' } * }) * * // Wait for connection * useEffect(() => { * if (mcp.state === 'ready') { * console.log('Connected!', mcp.tools) * } * }, [mcp.state]) * * // Call a tool * const result = await mcp.callTool('send-email', { to: 'user@example.com' }) * ``` */ export declare function useMcp(options: UseMcpOptions): UseMcpResult; //# sourceMappingURL=useMcp.d.ts.map