fix(cli): update environment variable handling for server URL
Some checks failed
CI / build-and-test (push) Failing after -32m44s

This commit is contained in:
2026-04-21 22:00:43 +02:00
parent 55859811be
commit 979afc909e
2 changed files with 6 additions and 3 deletions

View File

@@ -572,7 +572,7 @@ server: https://your-amcs-server
token: your-bearer-token
```
Env vars override the config file: `AMCS_URL`, `AMCS_TOKEN`. Flags `--server` and `--token` override env vars.
Env vars override the config file: `AMCS_SERVER` (preferred), `AMCS_URL` (legacy alias), and `AMCS_TOKEN`. Flags `--server` and `--token` override env vars.
### stdio MCP client setup
@@ -586,7 +586,7 @@ With inline credentials (no config file):
```bash
claude mcp add --transport stdio amcs amcs-cli stdio \
--env AMCS_URL=https://your-amcs-server \
--env AMCS_SERVER=https://your-amcs-server \
--env AMCS_TOKEN=your-bearer-token
```

View File

@@ -54,6 +54,9 @@ func loadConfig() error {
return err
}
cfg = loaded
if v := strings.TrimSpace(os.Getenv("AMCS_SERVER")); v != "" {
cfg.Server = v
}
if v := strings.TrimSpace(os.Getenv("AMCS_URL")); v != "" {
cfg.Server = v
}
@@ -75,7 +78,7 @@ func loadConfig() error {
func requireServer() error {
if strings.TrimSpace(cfg.Server) == "" {
return fmt.Errorf("server URL is required; set --server, AMCS_URL, or config server")
return fmt.Errorf("server URL is required; set --server, AMCS_SERVER, AMCS_URL, or config server")
}
return nil
}