mcp-use TypeScript API
    Preparing search index...

    Interface MCPClientOptions

    Options for configuring MCPClient behavior.

    interface MCPClientOptions {
        codeMode?: boolean | CodeModeConfig;
        onElicitation?: (params: {} | {}) => Promise<{ [key: string]: unknown }>;
        onNotification?: (notification: {}) => void | Promise<void>;
        onSampling?: (
            params: {},
        ) => Promise<{ [key: string]: unknown } | { [key: string]: unknown }>;
    }
    Index
    codeMode?: boolean | CodeModeConfig

    Enable code execution mode (simple boolean or advanced configuration)

    onElicitation?: (params: {} | {}) => Promise<{ [key: string]: unknown }>

    Optional callback function to handle elicitation requests from servers. When provided, the client will declare elicitation capability and handle elicitation/create requests by calling this callback.

    Elicitation allows servers to request additional information from users:

    • Form mode: Collect structured data with JSON schema validation
    • URL mode: Direct users to external URLs for sensitive interactions
    onNotification?: (notification: {}) => void | Promise<void>

    Optional callback function for server notifications. Applied as default when per-server config does not specify one.

    onSampling?: (
        params: {},
    ) => Promise<{ [key: string]: unknown } | { [key: string]: unknown }>

    Optional callback function to handle sampling requests from servers. When provided, the client will declare sampling capability and handle sampling/createMessage requests by calling this callback.

    Sampling is deprecated by the 2026 protocol. Retained for v1 push requests and v2 multi-round-trip compatibility.