You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/mcp/client.md
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,29 +189,34 @@ The configuration file should be a JSON file with an `mcpServers` object contain
189
189
190
190
### Environment Variables
191
191
192
-
The configuration file supports environment variable expansion using the `${VAR_NAME}` syntax. This is useful for keeping sensitive information like API keys or host names out of your configuration files:
192
+
The configuration file supports environment variable expansion using the `${VAR}` and `${VAR:-default}` syntax,
193
+
[like Claude Code](https://code.claude.com/docs/en/mcp#environment-variable-expansion-in-mcp-json).
194
+
This is useful for keeping sensitive information like API keys or host names out of your configuration files:
When loading this configuration with [`load_mcp_servers()`][pydantic_ai.mcp.load_mcp_servers], the `${VAR_NAME}` references will be replaced with the corresponding environment variable values.
213
+
When loading this configuration with [`load_mcp_servers()`][pydantic_ai.mcp.load_mcp_servers]:
214
+
215
+
-`${VAR}` references will be replaced with the corresponding environment variable values.
216
+
-`${VAR:-default}` references will use the environment variable value if set, otherwise the default value.
212
217
213
218
!!! warning
214
-
If a referenced environment variable is not defined, a `ValueError` will be raised. Make sure all required environment variables are set before loading the configuration.
219
+
If a referenced environment variable using `${VAR}` syntax is not defined, a `ValueError` will be raised. Use the `${VAR:-default}` syntax to provide a fallback value.
0 commit comments