Approves a pending elicitation request with a result.
Approves a pending sampling request with a result.
Manually triggers the authentication process. Useful if the initial attempt failed due to a blocked popup, allowing the user to initiate it via a button click.
A promise that resolves with the authorization URL opened (or intended to be opened), or undefined if auth cannot be started.
OptionalauthOAuth tokens if authentication was completed Available when state is 'ready' and OAuth was used
OAuth access token.
Optionalclient_id?: stringOAuth client id (from Dynamic Client Registration or a static client). Most token endpoints require it on refresh, so consumers can persist it for server-side proactive refresh.
Optionalclient_secret?: stringOAuth client secret, when the provider issued a confidential client.
Optionalexpires_at?: numberUnix timestamp in seconds when the access token expires.
Optionalrefresh_token?: stringOAuth refresh token, when issued.
Optionalresource?: stringCanonical protected-resource URL required by some token refresh flows.
Optionalscope?: stringSpace-delimited OAuth scopes granted to the token.
Optionaltoken_endpoint?: stringOAuth token endpoint resolved during discovery (when available). Lets consumers persist it so a backend can proactively refresh the token.
OAuth token type, commonly "Bearer".
OptionalauthIf authentication requires user interaction (e.g., popup was blocked), this URL can be presented to the user to complete authentication manually in a new tab.
OptionalautoEnable automatic proxy fallback when direct connection fails When enabled, if a direct connection fails with FastMCP or CORS errors, automatically retries using the proxy configuration
Can be:
true: Enable with proxyConfig.proxyAddressfalse: Disable automatic fallback (default){ enabled: boolean, proxyAddress?: string }: Custom configurationOptionalenabled?: booleanWhether fallback is enabled.
OptionalproxyAddress?: stringProxy endpoint used after a qualifying direct failure.
OptionalautoAuto reconnect if an established connection is lost.
Can be:
boolean: Enable/disable with default 3000ms delay and 10s health checknumber: Reconnect delay in ms (enables health checks with defaults)object: Full configuration for reconnection and health checksOptionalenabled?: booleanWhether to enable automatic reconnection (default: true)
OptionalhealthCheckInterval?: number | falseInterval in ms for health check polling via HEAD requests.
Set to false to disable health checks entirely.
OptionalhealthCheckTimeout?: numberTime in ms without a successful health check before triggering reconnect.
OptionalinitialDelay?: numberDelay in ms before reconnection attempt (default: 3000)
OptionalautoAuto retry connection if initial connection fails, with delay in ms (default: false)
OptionalcallbackCustom callback URL for OAuth redirect (defaults to /oauth/callback on the current origin)
Function to call a tool on the MCP server.
The name of the tool to call.
Optionalargs: Record<string, unknown>
Optional arguments for the tool.
Optionaloptions: {Optional request options including timeout configuration.
OptionalmaxTotalTimeout?: numberMaximum total timeout in milliseconds, even with progress resets
OptionalresetTimeoutOnProgress?: booleanReset the timeout when progress notifications are received (default: false)
Optionalsignal?: AbortSignalAbortSignal to cancel the request
Optionaltimeout?: numberTimeout in milliseconds for this tool call (default: 60000 / 60 seconds)
A promise that resolves with the tool's result.
// Simple tool call
const result = await mcp.callTool('my-tool', { arg: 'value' })
// Tool call with extended timeout (e.g., for tools that trigger sampling)
const result = await mcp.callTool('analyze-sentiment', { text: 'Hello' }, {
timeout: 300000, // 5 minutes
resetTimeoutOnProgress: true // Reset timeout when progress notifications are received
})
OptionalcapabilitiesServer capabilities normalized for the active connection.
Removes every notification from local state.
Clears all stored authentication data (tokens, client info, etc.) for this server URL from localStorage.
The underlying runtime-neutral MCP client instance. Use this to create an MCPAgent for AI chat functionality.
import { MCPAgent } from "@mcp-use/agent"
import { ChatOpenAI } from '@langchain/openai'
const mcp = useMcp({ url: 'http://localhost:3000/mcp' })
const llm = new ChatOpenAI({ model: 'gpt-4' })
const agent = new MCPAgent({ llm, client: mcp.client })
await agent.initialize()
for await (const event of agent.streamEvents('Hello')) {
console.log(event)
}
OptionalclientClient information advertised while establishing the MCP connection.
Optionaldescription?: stringOptional human-readable client description.
Optionalicons?: { mimeType?: string; sizes?: string[]; src: string }[]Icons representing the client.
Stable programmatic client name.
Optionaltitle?: stringOptional human-readable client title.
Client version.
OptionalwebsiteUrl?: stringPublic website describing the client.
OptionalclientSDK client options used by the active connection.
Optionalcapabilities?: {} & { views?: boolean }MCP capabilities advertised by the underlying SDK client.
Request completion suggestions for a prompt or resource template argument.
Completion request parameters specifying the ref and argument to complete.
A promise that resolves with completion suggestions from the server.
OptionalconnectionConnection policy for proxy routing.
auto: start direct and use autoProxyFallback after a qualifying failuredirect: never use proxyConfig and never fall backproxy: use proxyConfig immediately and never fall backWhen omitted, proxyConfig retains its legacy immediate-proxy behavior,
except when autoProxyFallback explicitly requests a direct-first attempt.
Disconnects the client from the MCP server.
OptionaldisplayOptional user-facing alias. server.name always comes from MCP server metadata.
OptionalenabledEnable/disable the connection (similar to TanStack Query). When false, no connection will be attempted (default: true)
Ensure the server icon is loaded and available in serverInfo Returns a promise that resolves when the icon is ready Use this before server creation to guarantee the icon is available
Promise that resolves with the base64 icon or null if not available
OptionalerrorIf the state is 'failed', this provides the error message
Protocol extension metadata normalized from the server capabilities.
Function to get a specific prompt from the MCP server.
The name of the prompt to get.
Optionalargs: Record<string, string>
Optional arguments for the prompt.
A promise that resolves with the prompt messages.
OptionalheadersRuntime HTTP headers. These values are never persisted.
Stable provider-managed server identifier.
OptionalinstructionsOptional server instructions advertised for the active connection.
Function to list prompts from the MCP server.
A promise that resolves when prompts are refreshed.
Function to list resources from the MCP server.
A promise that resolves when resources are refreshed.
Array of internal log messages (useful for debugging)
Log severity.
Human-readable log message.
Unix timestamp in milliseconds when the entry was created.
OptionallogLog level for console output.
Set to 'silent' to suppress ALL console logging (the mcp.log state array is still populated).
Marks every notification as read.
Marks one notification as read.
Name advertised by the connected MCP server.
Notifications received from this server.
OptionaloauthPublic OAuth registration settings only.
OptionalclientId?: stringPre-registered public OAuth client identifier.
OptionalclientMetadataUrl?: stringPublic OAuth Client ID Metadata Document URL.
Optionalscope?: stringSpace-delimited OAuth scopes.
OptionaloauthOAuth proxy base URL (e.g. https://inspector.example.com/inspector/api/oauth)
used to route OAuth requests (.well-known discovery, DCR, token exchange)
through a transparent server-side proxy — bypassing browser CORS against
third-party identity providers — WITHOUT proxying MCP traffic itself.
The proxy is transparent: it forwards requests and responses unmodified, so
the SDK's authorization-server issuer validation (RFC 8414 §3.3) still
passes. When omitted, the OAuth proxy URL is derived from
proxyConfig.proxyAddress (replacing a trailing /proxy with /oauth),
preserving the existing behavior for fully-proxied connections.
Elicitation requests awaiting an application decision.
Sampling requests awaiting an application decision.
OptionalpopupPopup window features string (dimensions and behavior) for OAuth
OptionalpreventPrevent automatic authentication popup/redirect on initial connection (default: true) When true, the connection will enter 'pending_auth' state and wait for user to call authenticate() Set to true to show a modal/button before triggering OAuth instead of auto-redirecting
List of prompts available from the connected MCP server
OptionalprotocolNegotiated MCP protocol era for the active connection:
undefined until a connection has negotiated.OptionalprotocolProtocol version negotiation mode passed to the underlying SDK Client.
"auto" (default): probe with server/discover to detect modern (2026-07-28)
servers, falling back to the 2025 handshake against legacy servers."legacy": classic 2025 initialize handshake, no probe.{ pin: "2026-07-28" }: modern era only, no fallback.OptionalprotocolNegotiated MCP protocol version string (e.g. '2025-06-18', '2026-07-28').
OptionalproxyLive proxy configuration, including runtime-only headers.
Function to read a resource from the MCP server.
The URI of the resource to read.
A promise that resolves with the resource contents.
Disconnect and reconnect with the current config.
OptionalreconnectionSDK-level reconnection options for the streamable HTTP transport
Refresh all lists (tools, resources, resource templates, prompts) from the server. Useful after reconnection or for manual refresh.
Refresh the prompts list from the server. Called automatically when notifications/prompts/list_changed is received. Can also be called manually for explicit refresh.
Refresh the resources list from the server. Called automatically when notifications/resources/list_changed is received. Can also be called manually for explicit refresh.
Refresh the resource templates list from the server. Can be called manually for explicit refresh.
Refresh the tools list from the server. Called automatically when notifications/tools/list_changed is received. Can also be called manually for explicit refresh.
Rejects a pending elicitation request.
Rejects a pending sampling request.
List of resources available from the connected MCP server
List of resource templates available from the connected MCP server
Manually attempts to reconnect if the state is 'failed'.
OptionalserverServer information normalized for the active connection.
Optionaldescription?: stringOptional human-readable server description.
Optionalicon?: stringBase64-encoded favicon auto-detected from server domain
Optionalicons?: { mimeType?: string; sizes?: string[]; src: string }[]Icons advertised by the server.
Stable server name.
Optionaltitle?: stringOptional human-readable server title.
Optionalversion?: stringServer version.
OptionalwebsiteUrl?: stringPublic website describing the server.
Rename the server without disconnecting.
Set HTTP headers on the connection config and reconnect.
The current state of the MCP connection:
error property.OptionalstorageStorage key prefix for OAuth data in localStorage (defaults to "mcp:auth")
OptionaltimeoutConnection timeout in milliseconds for establishing initial connection (default: 30000 / 30 seconds)
List of tools available from the connected MCP server
Number of notifications not yet marked as read.
Merge connection-affecting config and reconnect when it changed.
Prefer this over context updateServer(id, …) when you already hold the server.
OptionalurlThe /sse URL of your remote MCP server
OptionaluseUse full-page redirect for OAuth instead of popup window (default: false) Redirect flow avoids popup blockers and provides better UX on mobile. Set to true to use redirect flow instead of popup.
React entry point for the MCP connection console.
Provides the
useMcphook, the multi-serverMcpClientProvider, and the supporting storage / logging utilities for connecting to MCP servers from a React app. MCP Apps host rendering lives in ViewRenderer.