Skip to content

Commit 822fe77

Browse files
authored
Reconcile docs with runtime behavior for env vars, launch flags, and config semantics (#5779)
Nightly reconciliation found drift between docs/comments and implementation across environment variables, startup behavior, and config field support. This PR aligns operator-facing docs and inline config comments with current code paths to remove ambiguity in day-to-day usage. - **Environment variable reference alignment** - Added missing vars to `AGENTS.md`: - `GITHUB_MCP_SERVER_TOKEN` (documented as highest-priority auth token) - `OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_SERVICE_NAME` (CLI default sources for tracing flags) - `AWMG_BINARY_PATH`, `AWMG_WASM_GUARD_PATH` (integration test overrides) - Corrected `run.sh` note in `AGENTS.md` to reflect actual priority: `MCP_GATEWAY_PORT` first, then `PORT`. - Updated `docs/ENVIRONMENT_VARIABLES.md` so `DOCKER_API_VERSION` is documented under helper-script variables (not binary-consumed vars). - **Launch/config discoverability** - Documented `--sequential-launch` in both `AGENTS.md` and `CONTRIBUTING.md`. - Documented JSON stdin server `args` behavior in `AGENTS.md` (extra Docker runtime args inserted before image). - **Terminology and package description consistency** - Aligned `CONTRIBUTING.md` package descriptions with `AGENTS.md`: - `internal/guard`: `WriteSinkGuard` naming - `internal/httputil`: “Shared HTTP helper utilities (server responses, proxy transport)” - **Config semantics clarification** - Corrected `ServerConfig` comments for `RateLimitThreshold` and `RateLimitCooldown` in `internal/config/config_core.go` to state TOML-only support (not JSON stdin). - **Example guidance cleanup** - Added a clarifying comment in `config.example-payload-threshold.toml` that `/tmp` there is a runtime data-dir example, distinct from agent file-editing guidance. ```go // Supported in TOML config only; the JSON stdin config does not currently accept this field. RateLimitThreshold int `toml:"rate_limit_threshold" json:"rate_limit_threshold,omitempty"` // Supported in TOML config only; the JSON stdin config does not currently accept this field. RateLimitCooldown int `toml:"rate_limit_cooldown" json:"rate_limit_cooldown,omitempty"` ```
2 parents fd87f39 + 3b5b33d commit 822fe77

5 files changed

Lines changed: 26 additions & 10 deletions

File tree

AGENTS.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ Quick reference for AI agents working with MCP Gateway (Go-based MCP proxy serve
1616
**Format**: `make format` (auto-format code with gofmt)
1717
**Clean**: `make clean` (remove build artifacts)
1818
**Agent-Finished**: `make agent-finished` (run format, build, lint, and all tests - ALWAYS run before completion)
19-
**Run**: `./awmg --config config.toml`
20-
**Run with Custom Log Directory**: `./awmg --config config.toml --log-dir /path/to/logs`
21-
**Run with Custom Payload Directory**: `./awmg --config config.toml --payload-dir /path/to/payloads`
19+
**Run**: `./awmg --config config.toml`
20+
**Run sequentially**: `./awmg --config config.toml --sequential-launch`
21+
**Run with Custom Log Directory**: `./awmg --config config.toml --log-dir /path/to/logs`
22+
**Run with Custom Payload Directory**: `./awmg --config config.toml --payload-dir /path/to/payloads`
2223

2324
## Project Structure
2425

@@ -97,6 +98,7 @@ args = ["run", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "-i", "ghcr.io/gith
9798
- Required fields: `container` for stdio, `url` for http
9899
- **Containerization Requirement**: TOML stdio servers must use `command = "docker"` per [MCP Gateway Specification Section 3.2.1](https://github.com/github/gh-aw/blob/main/docs/src/content/docs/reference/mcp-gateway.md#321-containerization-requirement)
99100
- **Note**: In JSON stdin format, the `command` field is not supported - stdio servers must use `container` field
101+
- **Note**: In JSON stdin format, `args` is optional and provides extra Docker runtime arguments inserted before the container image name
100102
- Port range validation: 1-65535
101103
- Timeout validation: positive integers only
102104

@@ -374,6 +376,7 @@ DEBUG_COLORS=0 DEBUG=* ./awmg --config config.toml
374376

375377
## Environment Variables
376378

379+
- `GITHUB_MCP_SERVER_TOKEN` - Highest-priority GitHub auth token (takes precedence over `GITHUB_TOKEN`, `GITHUB_PERSONAL_ACCESS_TOKEN`, `GH_TOKEN`)
377380
- `GITHUB_PERSONAL_ACCESS_TOKEN` - GitHub auth
378381
- `GITHUB_API_URL` - Explicit GitHub API endpoint (e.g., `https://copilot-api.mycompany.ghe.com`); used by proxy to set upstream target
379382
- `GITHUB_SERVER_URL` - GitHub server URL; proxy auto-derives API endpoint: `*.ghe.com``copilot-api.*.ghe.com`, GHES → `<host>/api/v3`, `github.com``api.github.com`
@@ -404,9 +407,13 @@ DEBUG_COLORS=0 DEBUG=* ./awmg --config config.toml
404407
- `MCP_GATEWAY_TLS_KEY` - Path to TLS server private key PEM file; required when `MCP_GATEWAY_TLS_CERT` is set (sets default for `--tls-key`)
405408
- `MCP_GATEWAY_CA_CERT` - Path to CA certificate PEM file for client certificate verification; enables mutual TLS (mTLS) when set alongside `MCP_GATEWAY_TLS_CERT`/`MCP_GATEWAY_TLS_KEY` (sets default for `--tls-ca`)
406409
- `MCP_GATEWAY_HMAC_SECRET` - Shared HMAC-SHA256 secret for request signing and replay protection; when set, requests to MCP handlers must carry valid `X-MCP-Timestamp`, `X-MCP-Nonce`, and `X-MCP-Signature` headers (sets default for `--hmac-secret`)
410+
- `OTEL_EXPORTER_OTLP_ENDPOINT` - OTLP HTTP endpoint for trace export; sets default for `--otlp-endpoint`
411+
- `OTEL_SERVICE_NAME` - Service name in traces; sets default for `--otlp-service-name`
412+
- `AWMG_BINARY_PATH` - Override binary path for integration tests
413+
- `AWMG_WASM_GUARD_PATH` - Override WASM guard path for proxy integration tests
407414
- `RUNNING_IN_CONTAINER` - Set to `"true"` to force container detection when `/.dockerenv` and cgroup detection are unavailable
408415

409-
**Note:** `MCP_GATEWAY_PORT` is read by the `awmg` binary for environment validation (`--validate-env`) only. Plain `PORT`, `HOST`, and `MODE` are not read by `awmg` directly. However, `run.sh` uses `PORT`, `HOST` (default: `0.0.0.0`), and `MODE` (default: `--routed`) to set the bind address and routing mode. Use the `--listen` and `--routed`/`--unified` flags when running `awmg` directly.
416+
**Note:** `MCP_GATEWAY_PORT` is read by the `awmg` binary for environment validation (`--validate-env`) only. Plain `PORT`, `HOST`, and `MODE` are not read by `awmg` directly. However, `run.sh` uses `MCP_GATEWAY_PORT` (falling back to `PORT`), `HOST` (default: `0.0.0.0`), and `MODE` (default: `--routed`) to set the bind address and routing mode. Use the `--listen` and `--routed`/`--unified` flags when running `awmg` directly.
410417

411418
**File Logging:**
412419
- Operational logs are always written to log files in the configured log directory

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ echo '{"mcpServers": {...}}' | ./awmg --config-stdin
175175
# Increase verbosity
176176
./awmg --config config.toml -v
177177

178+
# Launch MCP servers sequentially during startup
179+
./awmg --config config.toml --sequential-launch
180+
178181
# Custom payload directory and size threshold (payload dir must be absolute)
179182
./awmg --config config.toml --payload-dir /tmp/payloads --payload-size-threshold 1048576
180183
```
@@ -263,8 +266,8 @@ gh-aw-mcpg/
263266
├── config/ # Configuration loading (TOML/JSON)
264267
├── difc/ # Decentralized Information Flow Control
265268
├── envutil/ # Environment variable utilities
266-
├── guard/ # Security guards (NoopGuard, WasmGuard, WriteSink)
267-
├── httputil/ # Shared HTTP response helpers
269+
├── guard/ # Security guards (NoopGuard, WasmGuard, WriteSinkGuard)
270+
├── httputil/ # Shared HTTP helper utilities (server responses, proxy transport)
268271
├── launcher/ # Backend server management
269272
├── logger/ # Debug logging framework
270273
├── mcp/ # MCP protocol types & connection
@@ -289,7 +292,7 @@ gh-aw-mcpg/
289292
- **`internal/difc/`** - Decentralized Information Flow Control
290293
- **`internal/envutil/`** - Environment variable utilities
291294
- **`internal/guard/`** - Guard framework for resource labeling
292-
- **`internal/httputil/`** - Shared HTTP response helpers (JSON responses, error formatting)
295+
- **`internal/httputil/`** - Shared HTTP helper utilities (server responses, proxy transport)
293296
- **`internal/launcher/`** - Backend process management (Docker, stdio)
294297
- **`internal/logger/`** - Micro logger for debug output
295298
- **`internal/mcp/`** - MCP protocol types and JSON-RPC handling

config.example-payload-threshold.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ api_key = "your-api-key-here"
1717
# - Flag: --payload-dir /custom/path
1818
# - Env: MCP_GATEWAY_PAYLOAD_DIR=/custom/path
1919
# Default: /tmp/jq-payloads
20+
# Note: This runtime storage path may live under /tmp and is separate from any agent editing workspace.
2021
payload_dir = "/tmp/jq-payloads"
2122

2223
# Payload path prefix for remapping file paths returned to clients

docs/ENVIRONMENT_VARIABLES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ When using `run_containerized.sh`, these additional variables are available:
5555
| Variable | Description | Default |
5656
|----------|-------------|---------|
5757
| `DOCKER_HOST` | Docker daemon socket path | `/var/run/docker.sock` |
58-
| `DOCKER_API_VERSION` | Docker API version (set by helper scripts, Docker client auto-negotiates) | Set by querying Docker daemon's current API version; falls back to `1.44` if detection fails |
58+
59+
### Helper/CLI Docker Variables
60+
61+
| Variable | Description | Default |
62+
|----------|-------------|---------|
63+
| `DOCKER_API_VERSION` | Docker API version used by helper scripts such as `run.sh`, integration test scripts, and `run_containerized.sh`. The Docker Go client in `awmg` auto-negotiates API version, but an exported `DOCKER_API_VERSION` can still affect `docker` CLI subprocesses launched with the inherited environment. | Set by querying Docker daemon's current API version; falls back to `1.44` if detection fails |
5964

6065
## GitHub Authentication
6166

internal/config/config_core.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ type ServerConfig struct {
252252
// RateLimitThreshold is the number of consecutive rate-limit errors from this backend
253253
// that will trip the circuit breaker (transition CLOSED → OPEN). When OPEN, requests
254254
// are immediately rejected until the cooldown period elapses. Default: 3.
255-
// Supported in file-based config (TOML/JSON); stdin JSON config does not currently accept this field.
255+
// Supported in TOML config only; the JSON stdin config does not currently accept this field.
256256
RateLimitThreshold int `toml:"rate_limit_threshold" json:"rate_limit_threshold,omitempty"`
257257

258258
// RateLimitCooldown is the number of seconds the circuit breaker stays OPEN before
259259
// allowing a single probe request (transition OPEN → HALF-OPEN). If the probe
260260
// succeeds the circuit closes; if rate-limited again it re-opens. Default: 60.
261-
// Supported in file-based config (TOML/JSON); stdin JSON config does not currently accept this field.
261+
// Supported in TOML config only; the JSON stdin config does not currently accept this field.
262262
RateLimitCooldown int `toml:"rate_limit_cooldown" json:"rate_limit_cooldown,omitempty"`
263263
}
264264

0 commit comments

Comments
 (0)