Fix environment variable documentation discrepancies#901
Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates documentation to better reflect which environment variables are actually honored by the gateway vs helper scripts, and to surface missing debug-related env vars.
Changes:
- README: removes
HOST/MODEfrom the “Optional (Non-Containerized Mode)” env var table; addsDEBUG/DEBUG_COLORS; adds guidance note about using CLI flags. - README: revises
DOCKER_API_VERSIONdescription/default. - AGENTS: removes
PORT/HOST/MODEfrom env var list; adds note claiming these are test-only and that the gateway uses CLI flags.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| README.md | Updates environment variable tables/notes and clarifies Docker-related env var behavior. |
| AGENTS.md | Adjusts documented env vars and adds a note about script-only variables vs gateway CLI flags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| | `DEBUG` | Enable debug logging with pattern matching (e.g., `*`, `server:*,launcher:*`) | (disabled) | | ||
| | `DEBUG_COLORS` | Control colored debug output (0 to disable, auto-disabled when piping) | Auto-detect | | ||
|
|
||
| **Note:** The `HOST` and `MODE` environment variables are not used by the gateway application. Use the `--listen` flag to set the bind address (default: `127.0.0.1:3000`) and the `--routed` or `--unified` flags to set the gateway mode. |
There was a problem hiding this comment.
The note states HOST and MODE are not used and instructs users to use --listen/--routed/--unified. While the Go binary doesn’t read HOST/MODE, run.sh does read HOST, PORT, and MODE and converts them into those flags (FLAGS="$MODE --listen ${HOST}:${PORT}"). In this “running locally (run.sh)” section, the current wording is misleading because run.sh doesn’t forward arbitrary CLI args, so users can’t actually supply --listen/--routed/--unified unless they bypass run.sh and run ./awmg directly. Consider documenting HOST/MODE as run.sh-only inputs (or clarify the note to distinguish run.sh vs awmg).
| **Note:** The `HOST` and `MODE` environment variables are not used by the gateway application. Use the `--listen` flag to set the bind address (default: `127.0.0.1:3000`) and the `--routed` or `--unified` flags to set the gateway mode. | |
| **Note:** When using `run.sh`, the script reads the `HOST`, `PORT`, and `MODE` environment variables and translates them into the equivalent `--listen` and `--routed`/`--unified` flags for the gateway binary. The gateway application itself does not read `HOST` or `MODE` directly. If you invoke `./awmg` manually (without `run.sh`), use the `--listen` flag to set the bind address (default: `127.0.0.1:3000`) and the `--routed` or `--unified` flags to select the gateway mode. |
| |----------|-------------|---------| | ||
| | `DOCKER_HOST` | Docker daemon socket path | `/var/run/docker.sock` | | ||
| | `DOCKER_API_VERSION` | Docker API version | Auto-detected (1.43 for arm64, 1.44 for amd64) | | ||
| | `DOCKER_API_VERSION` | Docker API version (set by helper scripts, Docker client auto-negotiates) | Set by run.sh based on architecture | |
There was a problem hiding this comment.
The updated DOCKER_API_VERSION default/description doesn’t match what the helper scripts actually do: run.sh/run_containerized.sh first try to set DOCKER_API_VERSION from docker version --format '{{.Server.APIVersion}}' and only fall back to an architecture-based value. The table currently says “Set by run.sh based on architecture”, which omits the primary (server API) behavior and may be inaccurate if the server API differs. Please align the wording/default with the scripts’ logic (server API version when available; architecture fallback).
| | `DOCKER_API_VERSION` | Docker API version (set by helper scripts, Docker client auto-negotiates) | Set by run.sh based on architecture | | |
| | `DOCKER_API_VERSION` | Docker API version (set by helper scripts: uses `docker version --format '{{.Server.APIVersion}}'` when available, with an architecture-based fallback) | Server API version when available; architecture-based fallback | |
| - `MCP_GATEWAY_LOG_DIR` - Log file directory (sets default for `--log-dir` flag, default: `/tmp/gh-aw/mcp-logs`) | ||
| - `MCP_GATEWAY_PAYLOAD_DIR` - Large payload storage directory (sets default for `--payload-dir` flag, default: `/tmp/jq-payloads`) | ||
|
|
||
| **Note:** The `PORT`, `HOST`, and `MODE` environment variables are used only by test scripts and are not read by the gateway application. The gateway uses command-line flags instead: `--listen` for bind address and `--routed`/`--unified` for mode selection. |
There was a problem hiding this comment.
This note claims PORT, HOST, and MODE are used only by test scripts, but run.sh also reads all three and uses them to construct the ./awmg invocation (--listen ${HOST}:${PORT} and $MODE). The note should be revised to reflect that these vars are script-level inputs (used by run.sh and some test helpers), not strictly test-only.
| **Note:** The `PORT`, `HOST`, and `MODE` environment variables are used only by test scripts and are not read by the gateway application. The gateway uses command-line flags instead: `--listen` for bind address and `--routed`/`--unified` for mode selection. | |
| **Note:** The `PORT`, `HOST`, and `MODE` environment variables are consumed by the `run.sh` wrapper and some test helper scripts to construct the `./awmg` invocation (for example, `--listen ${HOST}:${PORT}` and the selected mode), but they are not read directly by the gateway binary. The gateway itself uses command-line flags instead: `--listen` for bind address and `--routed`/`--unified` for mode selection. |
The documentation listed
HOSTandMODEas functional environment variables when they're only used by test scripts. Meanwhile, the functionalDEBUGandDEBUG_COLORSvariables were missing from the environment variables table.Changes
README.md - Optional Environment Variables:
HOSTandMODEfrom the table (test-only, not read by gateway)DEBUGandDEBUG_COLORSwith descriptions (functional but undocumented)--listenflag and--routed/--unifiedflagsDOCKER_API_VERSIONis set by scripts but not read by Go code (Docker client auto-negotiates)AGENTS.md - Environment Variables:
PORT,HOST,MODEfrom listContext
The gateway application reads environment variables through
os.Getenv()calls in production code. Searching the codebase shows:HOSTandMODEonly appear intest/integration/pipe_launch_test.goand helper scripts--listenflag (internal/cmd/flags_core.go:37)--routed/--unifiedflags (internal/cmd/flags_core.go:38-39)DEBUGandDEBUG_COLORSare actively used by internal/logger/logger.go but were only documented in the Logging section, not the comprehensive environment variables tableWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build895006319/b279/launcher.test /tmp/go-build895006319/b279/launcher.test -test.testlogfile=/tmp/go-build895006319/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo HEAD x_amd64/link get 6778014/b038/ .12/x64/git x_amd64/link /hom�� ache/go/1.25.6/x64/src/runtime/cgo1.25.6 git x_amd64/vet --local credential.userndocker-cli-plugin-metadata .12/x64/git x_amd64/vet(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build895006319/b264/config.test /tmp/go-build895006319/b264/config.test -test.testlogfile=/tmp/go-build895006319/b264/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo 64/src/internal/race/doc.go ache/go/1.25.6/x64/pkg/tool/linu-o unset --global ndor/bin/which 07.o rev-�� 64/src/runtime/c-p mon/httpcommon.ggo/ast x_amd64/compile get /maps rgo/bin/git x_amd64/compile(dns block)nonexistent.local/tmp/go-build895006319/b279/launcher.test /tmp/go-build895006319/b279/launcher.test -test.testlogfile=/tmp/go-build895006319/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo HEAD x_amd64/link get 6778014/b038/ .12/x64/git x_amd64/link /hom�� ache/go/1.25.6/x64/src/runtime/cgo1.25.6 git x_amd64/vet --local credential.userndocker-cli-plugin-metadata .12/x64/git x_amd64/vet(dns block)slow.example.com/tmp/go-build895006319/b279/launcher.test /tmp/go-build895006319/b279/launcher.test -test.testlogfile=/tmp/go-build895006319/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo HEAD x_amd64/link get 6778014/b038/ .12/x64/git x_amd64/link /hom�� ache/go/1.25.6/x64/src/runtime/cgo1.25.6 git x_amd64/vet --local credential.userndocker-cli-plugin-metadata .12/x64/git x_amd64/vet(dns block)this-host-does-not-exist-12345.com/tmp/go-build895006319/b288/mcp.test /tmp/go-build895006319/b288/mcp.test -test.testlogfile=/tmp/go-build895006319/b288/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true ache/go/1.25.6/xgo1.25.6 US0A/9-_MkWPRpSv-c=4 x_amd64/vet --local pull.rebase bin/node x_amd64/vet go_.�� 64/src/net a/fips.go x_amd64/vet -p 6778014/b126/ -lang=go1.25 x_amd64/vet(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>📚 Environment Variables Documentation Discrepancies - HOST and MODE</issue_title>
<issue_description>## Summary
Found 2 environment variables documented in README.md that are not actually used in production code, and 2 functional environment variables that are undocumented.
Important Issues 🟡
1. HOST Environment Variable - Documented But Not Used
Location: README.md, line 315
Problem: The
HOSTvariable is documented as "Gateway bind address" with default0.0.0.0, but this variable is NOT used anywhere in the production Go code.Actual Behavior:
test/integration/pipe_launch_test.go--listenflag (default:127.0.0.1:3000)run.shscript setsHOSTbut the Go application ignores itImpact: Users may set
HOSTexpecting it to work, but it has no effect. This could cause confusion when trying to bind to different addresses.Suggested Fix:
Code Reference:
internal/cmd/flags_core.godefines--listenflag but noHOSTenvironment variable handling2. MODE Environment Variable - Documented But Not Used
Location: README.md, line 316
Problem: The
MODEvariable is documented as "Gateway mode flag" with default--routed, but this variable is NOT used in the production Go code.Actual Behavior:
test/integration/pipe_launch_test.go--routedor--unifiedflagsrun.shscript setsMODEbut the Go application ignores itImpact: Users may set
MODEexpecting to switch between routed/unified modes, but it has no effect. Must use command-line flags instead.Suggested Fix:
Code Reference:
internal/cmd/flags_core.godefines--routedand--unifiedflags but noMODEenvironment variable handling3. DEBUG Environment Variable - Functional But Undocumented
Location: Not documented in README.md Environment Variables section (lines 292-326)
Problem: The
DEBUGenvironment variable is fully functional and controls debug logging, but it's only documented in the "Logging" section (line 481), not in the comprehensive environment variables table.Actual Behavior:
DEBUG=*,DEBUG=server:*,launcher:*)internal/logger/logger.go:46Impact: Users may miss this important debugging feature when reviewing the environment variables section.
Suggested Fix: Add to environment variables table:
Code Reference:
internal/logger/logger.go:26,464. DEBUG_COLORS Environment Variable - Functional But Undocumented
Location: Not documented in README.md Environment Variables section
Problem: The
DEBUG_COLORSenvironment variable controls colored output for debug logs but is not documented.Actual Behavior:
internal/logger/logger.go:26Impact: Users may want to disable colors in specific scenarios but don't know this option exists.
Suggested Fix: Add to environment variables table (see suggestion above)
Code Reference:
internal/logger/logger.go:26Minor Issues 🔵
5. DOCKER_API_VERSION - Set But Not Read
Location: README.md, line 326
Problem: Documentation states "Auto-detected (1.43 for arm64, 1.44 for amd64)", but the Go code doesn't actually read this environment variable. It's set by
run.shandrun_containerized.shbut never used.Actual Behavior:
Impact: Low -...