MCPClient API Documentation
MCPClient
class is the core component for managing connections to MCP servers and orchestrating tool access.
config_dict
(dict): Configuration dictionary containing server definitionsdebug
(bool, optional): Enable debug logging. Defaults to False.config_file_path
(str): Path to the JSON configuration filedebug
(bool, optional): Enable debug logging. Defaults to False.MCPClient
: Configured client instanceconfig_dict
(dict): Configuration dictionarydebug
(bool, optional): Enable debug logging. Defaults to False.MCPClient
: Configured client instancename
(str): Name for the serverserver_config
(dict): Server configuration dictionaryNone
name
(str): Name of the server to removeNone
List[str]
: List of server namesfilepath
(str): Path where to save the configuration fileNone
server_name
(str): Name of the server to create a session withauto_initialize
(bool, optional): Whether to automatically initialize the session. Defaults to True.MCPSession
: The created session objectValueError
: If server is not configuredConnectionError
: If session creation failsauto_initialize
(bool, optional): Whether to automatically initialize sessions. Defaults to True.None
server_name
(str): Name of the serverMCPSession
: The session objectValueError
: If session does not existDict[str, MCPSession]
: Dictionary mapping server names to session objectsserver_name
(str): Name of the server whose session to closeNone
None
Dict[str, MCPSession]
Dictionary of active sessions by server name.
Example:
Dict
The configuration dictionary used to initialize the client.
Example:
bool
Whether sandbox mode is enabled for server execution.
Example:
SandboxOptions | None
Configuration options for sandbox execution.
Example: