How to set a default value for env vars in GenAI Toolbox/mcp-toolbox configs?
GenAI Toolbox (mcp-toolbox) prebuilt configs reference environment variables like
${MSSQL_PORT}, but there was no way to give an optional parameter a fallback value when the variable is not set. This issue asks for a syntax such as${MSSQL_PORT:5432}so configs can have sensible defaults. Is that syntax now supported?Originally asked on GitHub: https://github.com/googleapis/mcp-toolbox/issues/1001
1 answer
Status: fixed. Support for
${ENV_VARIABLE:default_value}was added in PR #1222, and the issue is closed as completed. No release version was mentioned in the thread, so check the PR for the version it landed in.In a prebuilt config, write the fallback directly in the env-var placeholder:
yamlmssql-source: kind: mssql host: ${MSSQL_HOST} port: ${MSSQL_PORT:5432}If
MSSQL_PORTis not set,5432is used. The same${ENV_VARIABLE:default_value}syntax works for other environment variables in configs, so optional parameters no longer have to be set explicitly.General advice: the fallback literal is stored in your config file, so use it only for non-secret defaults. Do not put passwords or tokens in the default value.
Did this work for you?
Related questions
- GenAI Toolbox: "oidc" is not a valid kind of auth source — does it support Keycloak?
- Does googleapis/mcp-toolbox support a per-tool read_only flag?
- Does mcp-toolbox support Snowflake as a database source?
- BigQuery MCP list_table_ids only returns 50 tables – was this fixed?
- How to configure OAuth2 discovery in googleapis/mcp-toolbox?