***

title: ConfigLoader
slug: /reference/python/agents/configuration/config-loader
description: JSON configuration loading with environment variable substitution.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[securityconfig]: /docs/server-sdks/reference/python/agents/configuration/security-config

[mcp-gateway]: /docs/server-sdks/reference/python/agents/cli/mcp-gateway

[findconfigfile]: /docs/server-sdks/reference/python/agents/configuration/config-loader/find-config-file

[get]: /docs/server-sdks/reference/python/agents/configuration/config-loader/get

[getconfig]: /docs/server-sdks/reference/python/agents/configuration/config-loader/get-config

[getconfigfile]: /docs/server-sdks/reference/python/agents/configuration/config-loader/get-config-file

[getsection]: /docs/server-sdks/reference/python/agents/configuration/config-loader/get-section

[hasconfig]: /docs/server-sdks/reference/python/agents/configuration/config-loader/has-config

[mergewithenv]: /docs/server-sdks/reference/python/agents/configuration/config-loader/merge-with-env

[substitutevars]: /docs/server-sdks/reference/python/agents/configuration/config-loader/substitute-vars

`ConfigLoader` loads JSON configuration files and substitutes environment
variables using `${VAR|default}` syntax. It is used internally by
[`SecurityConfig`][securityconfig]
and the [`mcp-gateway`][mcp-gateway] service,
and can be used directly for custom configuration needs.

```python
from signalwire.core.config_loader import ConfigLoader
```

## **Properties**

<ParamField path="config_paths" type="list[str]" toc={true}>
  List of file paths checked during initialization. The first existing file is loaded.
</ParamField>

## **Methods**

<CardGroup cols={3}>
  <Card title="find_config_file" href="/docs/server-sdks/reference/python/agents/configuration/config-loader/find-config-file">
    Static method to locate a config file without loading it.
  </Card>

  <Card title="get" href="/docs/server-sdks/reference/python/agents/configuration/config-loader/get">
    Get a configuration value by dot-notation path.
  </Card>

  <Card title="get_config" href="/docs/server-sdks/reference/python/agents/configuration/config-loader/get-config">
    Get the raw configuration dictionary before environment variable substitution.
  </Card>

  <Card title="get_config_file" href="/docs/server-sdks/reference/python/agents/configuration/config-loader/get-config-file">
    Get the path of the loaded config file.
  </Card>

  <Card title="get_section" href="/docs/server-sdks/reference/python/agents/configuration/config-loader/get-section">
    Get an entire configuration section with environment variables substituted.
  </Card>

  <Card title="has_config" href="/docs/server-sdks/reference/python/agents/configuration/config-loader/has-config">
    Check whether a configuration file was successfully loaded.
  </Card>

  <Card title="merge_with_env" href="/docs/server-sdks/reference/python/agents/configuration/config-loader/merge-with-env">
    Merge configuration with environment variables matching a prefix.
  </Card>

  <Card title="substitute_vars" href="/docs/server-sdks/reference/python/agents/configuration/config-loader/substitute-vars">
    Recursively substitute environment variables in configuration values.
  </Card>
</CardGroup>

## **Example**

```python {4,8}
from signalwire.core.config_loader import ConfigLoader

# Auto-discover config file
loader = ConfigLoader()
print(f"Config loaded: {loader.has_config()}")

# Explicit config file path
loader = ConfigLoader(["./my-config.json", "/etc/myapp/config.json"])
print(f"Config file: {loader.get_config_file()}")
```