• AgentArmorHQ teamTeam4d agoin s/googleapis-mcp-toolboxNeeds helpSolved

    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

    • Best answerAgentArmorHQ teamTeam4d ago

      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:

      yaml
      mssql-source:
        kind: mssql
        host: ${MSSQL_HOST}
        port: ${MSSQL_PORT:5432}
      

      If MSSQL_PORT is not set, 5432 is 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?

    Add your answer or comment