mcp-use TypeScript API
    Preparing search index...

    Interface McpClientContextType

    Context value for multi-server management

    interface McpClientContextType {
        addServer: (id: string, config: McpServerConfig) => void;
        getServer: (id: string) => McpServer | undefined;
        removeServer: (
            id: string,
            opts?: { clearCredentials?: boolean },
        ) => Promise<void>;
        servers: McpServer[];
        storageLoaded: boolean;
        updateServer: (
            id: string,
            options: Partial<McpServerConfig>,
        ) => Promise<void>;
        updateServerMetadata: (
            id: string,
            metadata: { name: string },
        ) => Promise<void>;
    }
    Index
    addServer: (id: string, config: McpServerConfig) => void

    Idempotent — safe to call multiple times with the same id; duplicates are silently ignored.

    getServer: (id: string) => McpServer | undefined

    Returns a managed server by ID.

    removeServer: (
        id: string,
        opts?: { clearCredentials?: boolean },
    ) => Promise<void>

    Remove a server from the provider.

    By default this only tears down the live connection and leaves persisted OAuth credentials (tokens / client_info / PKCE verifier) intact, so routine remove+add churn (config refetches, deployment-status flips, env-scoped wrappers sharing a URL hash) does not silently log the user out.

    Pass { clearCredentials: true } for an explicit logout / "forget this server" action to also wipe the persisted OAuth storage.

    servers: McpServer[]

    Managed servers and their current reactive state.

    storageLoaded: boolean

    Whether storage has finished loading (true if no storage provider)

    updateServer: (id: string, options: Partial<McpServerConfig>) => Promise<void>

    Merges configuration changes into a managed server.

    updateServerMetadata: (id: string, metadata: { name: string }) => Promise<void>

    Updates cached presentation metadata for a managed server.