---
title: "Config"
description: "Configuration loader for MCP session API Documentation"
icon: "code"
github: "https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/client/config.py"
---

import {RandomGradientBackground} from "/snippets/gradient.jsx"

<Callout type="info" title="Source Code">
View the source code for this module on GitHub: <a href='https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/client/config.py' target='_blank' rel='noopener noreferrer'>https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/client/config.py</a>
</Callout>

Configuration loader for MCP session.

This module provides functionality to load MCP configuration from JSON files.


## create_connector_from_config
<Card type="info">
### `function` create_connector_from_config

Create a connector based on server configuration.
    This function can be called with just the server_config parameter:
    create_connector_from_config(server_config)

```python
from mcp_use.client.config import create_connector_from_config
```

**Parameters**
><ParamField body="server_config" type="dict[str, Any]" required="True" >   The server configuration section </ParamField>
><ParamField body="sandbox" type="bool" default="False" >   Whether to use sandboxed execution mode for running MCP servers. </ParamField>
><ParamField body="sandbox_options" type="mcp_use.client.connectors.sandbox.SandboxOptions | None" default="None" >   Optional sandbox configuration options. </ParamField>
><ParamField body="sampling_callback" type="mcp.client.session.SamplingFnT | None" default="None" >   Optional sampling callback function. </ParamField>
><ParamField body="elicitation_callback" type="mcp.client.session.ElicitationFnT | None" default="None" >   Callback function </ParamField>
><ParamField body="message_handler" type="mcp.client.session.MessageHandlerFnT | None" default="None" >   Parameter value </ParamField>
><ParamField body="logging_callback" type="mcp.client.session.LoggingFnT | None" default="None" >   Callback function </ParamField>
><ParamField body="middleware" type="list[mcp_use.client.middleware.middleware.Middleware] | None" default="None" >   Middleware instance </ParamField>
><ParamField body="verify" type="bool | None" default="True" >   Boolean flag </ParamField>
><ParamField body="roots" type="list[mcp.types.Root] | None" default="None" >   List of items </ParamField>
><ParamField body="list_roots_callback" type="mcp.client.session.ListRootsFnT | None" default="None" >   Callback function </ParamField>

**Returns**
><ResponseField name="returns" type="mcp_use.client.connectors.base.BaseConnector" >A configured connector instance</ResponseField>

**Signature**
```python wrap
def create_connector_from_config(
server_config: dict[str,
    Any],
    sandbox: bool = False,
    sandbox_options: mcp_use.client.connectors.sandbox.SandboxOptions | None = None,
    sampling_callback: mcp.client.session.SamplingFnT | None = None,
    elicitation_callback: mcp.client.session.ElicitationFnT | None = None,
    message_handler: mcp.client.session.MessageHandlerFnT | None = None,
    logging_callback: mcp.client.session.LoggingFnT | None = None,
    middleware: list[mcp_use.client.middleware.middleware.Middleware] | None = None,
    verify: bool | None = True,
    roots: list[mcp.types.Root] | None = None,
    list_roots_callback: mcp.client.session.ListRootsFnT | None = None
):
```

</Card>


## load_config_file
<Card type="info">
### `function` load_config_file

Load a configuration file.


```python
from mcp_use.client.config import load_config_file
```

**Parameters**
><ParamField body="filepath" type="str" required="True" >   Path to the configuration file </ParamField>

**Returns**
><ResponseField name="returns" type="dict[str, Any]" >The parsed configuration</ResponseField>

**Signature**
```python wrap
def load_config_file(filepath: str):
```

</Card>
