diff --git a/app/ensure_codex_config.py b/app/ensure_codex_config.py index a61c000..42e104d 100644 --- a/app/ensure_codex_config.py +++ b/app/ensure_codex_config.py @@ -15,6 +15,16 @@ def main() -> None: config_path = codex_home / "config.toml" state_path = os.getenv("BOT_STATE_PATH", "/app/data/state.json") timezone = os.getenv("BOT_TIMEZONE", "Asia/Seoul") + gitea_env = _mcp_env_lines( + [ + "GITEA_BASE_URL", + "GITEA_USERNAME", + "GITEA_EMAIL", + "GITEA_TOKEN", + "GITEA_DEFAULT_OWNER", + "GITEA_DEFAULT_REPO", + ] + ) block = f"""{BEGIN} [mcp_servers.telegram_bridge] @@ -33,6 +43,7 @@ approval_mode = "approve" PYTHONPATH = "/app" BOT_STATE_PATH = "{_toml_string(state_path)}" BOT_TIMEZONE = "{_toml_string(timezone)}" +{gitea_env} {END} """ @@ -52,5 +63,15 @@ def _toml_string(value: str) -> str: return value.replace("\\", "\\\\").replace('"', '\\"') +def _mcp_env_lines(names: list[str]) -> str: + lines: list[str] = [] + for name in names: + value = os.getenv(name) + if value is None: + continue + lines.append(f'{name} = "{_toml_string(value)}"') + return "\n".join(lines) + + if __name__ == "__main__": main()