mcp-use TypeScript API
    Preparing search index...

    Function McpClientProvider

    • Provider for managing multiple MCP server connections

      Provides a context for adding/removing servers and accessing their state. Each server maintains its own connection, notification history, and pending sampling/elicitation requests.

      Supports:

      • Initial server configuration via mcpServers prop
      • Persistence via pluggable storageProvider
      • RPC logging for debugging
      • Lifecycle callbacks for state changes

      Parameters

      Returns Element

      // With initial servers
      <McpClientProvider
      mcpServers={{
      linear: { url: "https://mcp.linear.app/sse" },
      github: { url: "https://mcp.github.com/mcp" }
      }}
      >
      <MyApp />
      </McpClientProvider>

      // With persistence
      <McpClientProvider
      storageProvider={new LocalStorageProvider("my-servers")}
      enableRpcLogging={true}
      >
      <MyApp />
      </McpClientProvider>