14namespace entropic::config {
23static std::string
get_env(
const char* name)
25 const char*
val = std::getenv(name);
26 return val !=
nullptr ? std::string(
val) :
"";
38 return val ==
"true" ||
val ==
"True" ||
val ==
"TRUE"
39 ||
val ==
"yes" ||
val ==
"1";
54template <
typename Setter>
57 if (
val.empty()) {
return; }
58 s_log->info(
"Env override: {}={}", key,
val);
76 apply_env(
"ENTROPIC_MCP__EXTERNAL__ENABLED",
77 [&](
const std::string&
v) {
80 apply_env(
"ENTROPIC_MCP__EXTERNAL__HTTP_PORT",
81 [&](
const std::string&
v) {
83 const long port = std::strtol(
v.c_str(), &
end, 10);
84 config.mcp.external.http_port =
85 (
end !=
v.c_str() && *
end ==
'\0') ?
static_cast<int>(
port)
99 [&](
const std::string&
v) {
config.log_level =
v; });
101 [&](
const std::string&
v) {
config.models.default_tier =
v; });
103 [&](
const std::string&
v) {
106 apply_env(
"ENTROPIC_ROUTING__FALLBACK_TIER",
107 [&](
const std::string&
v) {
config.routing.fallback_tier =
v; });
108 apply_env(
"ENTROPIC_COMPACTION__THRESHOLD_PERCENT",
109 [&](
const std::string&
v) {
110 config.compaction.threshold_percent = std::stof(
v);
112 apply_env(
"ENTROPIC_COMPACTION__ENABLED",
113 [&](
const std::string&
v) {
117 [&](
const std::string&
v) {
118 config.vram_reserve_mb = std::stoi(
v);
121 [&](
const std::string&
v) {
122 config.config_dir = std::filesystem::path(
v);
static bool parse_bool(const std::string &val)
Parse a boolean from string (true/false/yes/no/1/0).
static void apply_mcp_external_env(ParsedConfig &config)
The mcp.external overrides entropic serve sets (gh#204).
static void apply_env(const char *key, Setter setter)
Apply one ENTROPIC_* override if the env var is set.
static std::string get_env(const char *name)
Get environment variable value or empty string.
Config loader — YAML to C++ structs with validation.
ENTROPIC_EXPORT void apply_env_overrides(ParsedConfig &config)
Apply ENTROPIC_* environment variable overrides.
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
@ optional
optional: every escape asks the host's path approver
std::string config
–config FILE
Full parsed configuration.