diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index 1acd8ff..4ff29d0 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -22,10 +22,10 @@ type Config struct { // DBPath is the SQLite database file path. DBPath string - // GarminPythonPath is mcp-garmin's venv python executable. + // GarminPythonPath is the python3 interpreter used to run the embedded + // Garmin wrapper script (internal/garmin's go:embed'd wrapper.py). + // Defaults to "python3" resolved via PATH if unset. GarminPythonPath string - // GarminServerPath is mcp-garmin's server.py. - GarminServerPath string // GarminTokenStoreRoot is the root directory under which each user's // mcp-garmin session cache lives (one subdirectory per user id, e.g. // "/3"). Read from the GARMIN_TOKENSTORE env var; if unset, it @@ -60,8 +60,7 @@ func Load() (Config, error) { cfg := Config{ Addr: getEnvDefault("GENIUSRUN_ADDR", ":8080"), DBPath: getEnvDefault("GENIUSRUN_DB_PATH", "geniusrun.db"), - GarminPythonPath: os.Getenv("MCP_GARMIN_PYTHON"), - GarminServerPath: os.Getenv("MCP_GARMIN_SERVER"), + GarminPythonPath: getEnvDefault("GARMIN_WRAPPER_PYTHON", "python3"), GarminTokenStoreRoot: os.Getenv("GARMIN_TOKENSTORE"), MinConfidence: getEnvFloat("GENIUSRUN_MIN_CONFIDENCE", 0.6), IncrementalSyncEvery: getEnvDuration("GENIUSRUN_INCREMENTAL_SYNC_EVERY", 6*time.Hour), @@ -78,12 +77,6 @@ func Load() (Config, error) { log.Printf("GARMIN_TOKENSTORE not set, defaulting to %q", cfg.GarminTokenStoreRoot) } - if cfg.GarminPythonPath == "" { - return cfg, fmt.Errorf("MCP_GARMIN_PYTHON is required (path to mcp-garmin's venv python)") - } - if cfg.GarminServerPath == "" { - return cfg, fmt.Errorf("MCP_GARMIN_SERVER is required (path to mcp-garmin's server.py)") - } if cfg.PublicBaseURL == "" { return cfg, fmt.Errorf("GENIUSRUN_PUBLIC_BASE_URL is required (e.g. https://geniusrun.example.com)") } diff --git a/backend/internal/config/config_test.go b/backend/internal/config/config_test.go index 1e50def..c48c946 100644 --- a/backend/internal/config/config_test.go +++ b/backend/internal/config/config_test.go @@ -8,8 +8,6 @@ import ( func setRequiredEnv(t *testing.T) { t.Helper() - t.Setenv("MCP_GARMIN_PYTHON", "/usr/bin/python3") - t.Setenv("MCP_GARMIN_SERVER", "/opt/mcp-garmin/server.py") t.Setenv("GENIUSRUN_PUBLIC_BASE_URL", "https://geniusrun.example.com") t.Setenv("GENIUSRUN_OIDC_ISSUER_URL", "https://keycloak.example.com/realms/myrealm") t.Setenv("GENIUSRUN_OIDC_CLIENT_ID", "geniusrun") @@ -110,6 +108,32 @@ func TestLoad_GarminTokenStoreRootExplicitOverridesDefault(t *testing.T) { } } +func TestLoad_GarminPythonPathDefaultsToPython3(t *testing.T) { + setRequiredEnv(t) + t.Setenv("GARMIN_WRAPPER_PYTHON", "") + + cfg, err := Load() + if err != nil { + t.Fatalf("Load: %v", err) + } + if cfg.GarminPythonPath != "python3" { + t.Errorf("GarminPythonPath = %q, want default %q", cfg.GarminPythonPath, "python3") + } +} + +func TestLoad_GarminPythonPathExplicitOverridesDefault(t *testing.T) { + setRequiredEnv(t) + t.Setenv("GARMIN_WRAPPER_PYTHON", "/opt/venv/bin/python3") + + cfg, err := Load() + if err != nil { + t.Fatalf("Load: %v", err) + } + if cfg.GarminPythonPath != "/opt/venv/bin/python3" { + t.Errorf("GarminPythonPath = %q, want explicit override", cfg.GarminPythonPath) + } +} + func TestLoad_CustomRoleAndDuration(t *testing.T) { setRequiredEnv(t) t.Setenv("GENIUSRUN_OIDC_REQUIRED_ROLE", "admin")