ServerConfig
object or a dictionary that will be converted to a :obj:ServerConfig
. The configuration determines the transport type and connection parameters.None
)10.0
)FunctionTool
objects
representing the available tools from the MCP server. Returns
an empty list if the client is not connected.
Note:
This method requires an active connection to the MCP server.
If the client is not connected, an empty list will be returned.
MCPClient
instance from various
configuration formats. This is the recommended way to create MCP clients
as it handles configuration validation and type conversion automatically.
Parameters:
ServerConfig
object. If a dictionary is provided, it will be automatically converted toServerConfig
. **kwargs: Additional keyword arguments passed to the :obj:MCPClient
constructor, such as :obj:client_info
, :obj:timeout
.MCPClient
instance ready for use as
an async context manager.
\{ "mcpServers": \{ "filesystem": \{ "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-filesystem", "/path" ] \}, "remote-server": \{ "url": "https://api.example.com/mcp", "headers": \{"Authorization": "Bearer token"\} \} \} \}
Usage:
.. code-block:: python
async with create_mcp_client_from_config_file(
“config.json”, “filesystem”
) as client:
tools = client.get_tools()