View the source code for this module on GitHub: https://github.com/mcp-use/mcp-use/blob/main/mcp_use/client.py
MCPClient
method
init
Initialize a new MCP client.ParametersSignatureEither a dict containing configuration or a path to a JSON config file.Server name or configurationWhether to use sandboxed execution mode for running MCP servers.Optional sandbox configuration options.Optional sampling callback function.Callback functionParameter valueCallback functionMiddleware instance
method
close_all_sessions
Close all active sessions.This method ensures all sessions are closed even if some fail.Signaturemethod
create_session
Create a session for the specified server.ParametersReturnsThe name of the server to create a session for.Whether to automatically initialize the session.
SignatureThe created MCPSession.