You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reconcile stdin config support and developer docs with implementation (#5645)
## Bug Fix
The nightly documentation reconciliation found several drifts between
the documented config surface and the actual implementation. The main
gaps were missing JSON stdin support for `gateway.payloadPathPrefix`,
inconsistent stdin server timeout field naming, and contributor docs
that no longer matched the `internal/config` package layout or
validation rules.
### What was the bug?
- `AGENTS.md` implied a single `internal/config/config.go` entry point
even though the config package is split across multiple files.
- JSON stdin config could not set `gateway.payloadPathPrefix`, despite
TOML and env/flag paths supporting it.
- Per-server stdin timeout fields used `snake_case` while the rest of
the JSON gateway config uses `camelCase`.
- Docs/examples were missing or outdated for:
- absolute-path requirements on `payload_dir`
- OpenTelemetry vs legacy tracing key precedence
- integration-test env vars `AWMG_BINARY_PATH` and
`AWMG_WASM_GUARD_PATH`
### How did you fix it?
- **JSON stdin config parity**
- Added `payloadPathPrefix` to `StdinGatewayConfig` and wired it into
stdin-to-runtime config conversion.
- Standardized stdin server timeout fields on `connectTimeout` /
`toolTimeout`.
- Kept `connect_timeout` / `tool_timeout` as backward-compatible JSON
aliases during unmarshalling.
- Updated the stdin JSON schema and config tests to cover the new field
and alias behavior.
- **Developer docs reconciliation**
- Updated `AGENTS.md` to describe the real multi-file `internal/config`
layout, including `config_core.go`, `config_stdin.go`, feature-specific
config files, and split validation files.
- Documented that `payload_dir` / `MCP_GATEWAY_PAYLOAD_DIR` must be
absolute in examples and reference docs.
- Added migration guidance for `[gateway.opentelemetry]` vs legacy
`[gateway.tracing]`, including precedence when both are present.
- Added integration test environment variable docs to `CONTRIBUTING.md`.
- **Reference/example cleanup**
- Updated config examples and docs to reflect the supported JSON field
names and current behavior.
- Added `payloadPathPrefix` to the configuration reference alongside
existing payload settings.
### Testing
- Added/updated focused config tests for:
- `gateway.payloadPathPrefix` in stdin JSON
- camelCase per-server timeout fields
- backward-compatible snake_case timeout aliases
```json
{
"gateway": {
"apiKey": "${MCP_GATEWAY_API_KEY}",
"payloadPathPrefix": "/workspace/payloads"
},
"mcpServers": {
"repo-mind": {
"type": "http",
"url": "http://127.0.0.1:8000/mcp",
"connectTimeout": 45,
"toolTimeout": 600
}
}
}
```
-`MCP_GATEWAY_PAYLOAD_DIR` - Large payload storage directory (sets default for `--payload-dir` flag, default: `/tmp/jq-payloads`)
387
-
-`MCP_GATEWAY_PAYLOAD_PATH_PREFIX` - Path prefix for remapping payloadPath returned to clients (sets default for `--payload-path-prefix` flag, default: empty)
389
+
-`MCP_GATEWAY_PAYLOAD_DIR` - Large payload storage directory (sets default for `--payload-dir` flag, default: `/tmp/jq-payloads`). Must be an absolute path.
390
+
-`MCP_GATEWAY_PAYLOAD_PATH_PREFIX` - Path prefix for remapping payloadPath returned to clients (sets default for `--payload-path-prefix` flag, default: empty). In JSON stdin config use `gateway.payloadPathPrefix`.
388
391
-`MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD` - Size threshold in bytes for payload storage; payloads larger than this are stored to disk (sets default for `--payload-size-threshold` flag, default: `524288`)
389
392
-`MCP_GATEWAY_SESSION_TIMEOUT` - Session timeout for stateful sessions in both unified mode (`/mcp`) and routed mode (`/mcp/<server>`). Accepts Go duration strings (e.g., `30m`, `1h`, `2h30m`). (default: `6h`)
390
393
-`MCP_GATEWAY_TOOL_TIMEOUT` - Tool invocation timeout in seconds. Fallback when `gateway.toolTimeout` is not set in stdin JSON config. Accepts any integer ≥ 10 (no upper bound). Priority: stdin config > env var > built-in default. (default: `60`)
- Large tool response payloads are stored in the configured payload directory
429
-
- Default payload directory: `/tmp/jq-payloads` (configurable via `--payload-dir` flag, `MCP_GATEWAY_PAYLOAD_DIR` env var, or `payload_dir` in config)
432
+
- Default payload directory: `/tmp/jq-payloads` (configurable via `--payload-dir` flag, `MCP_GATEWAY_PAYLOAD_DIR` env var, or `payload_dir` in config). The configured path must be absolute.
430
433
- Payloads are organized by session ID: `{payload_dir}/{sessionID}/{queryID}/payload.json`
431
434
- This allows agents to mount their session-specific subdirectory to access full payloads
432
435
- The jq middleware returns: preview (first `PayloadPreviewSize` chars, default 500), schema, payloadPath, queryID, originalSize, truncated flag
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,6 +107,11 @@ make test-container-proxy
107
107
108
108
This target builds a Docker image and tests proxy mode with TLS. It requires a GitHub token available via the `gh` CLI (`gh auth login`) or the `GITHUB_TOKEN`/`GH_TOKEN` environment variable.
109
109
110
+
#### Testing Environment Variables
111
+
112
+
-`AWMG_BINARY_PATH` — Override the binary path used by integration tests when you want to run tests against a prebuilt `awmg` binary.
113
+
-`AWMG_WASM_GUARD_PATH` — Override the GitHub guard WASM path used by proxy integration tests when the default build output path is not available.
114
+
110
115
#### Race Detection Tests
111
116
Run unit tests with Go's race detector to catch concurrent data races:
Copy file name to clipboardExpand all lines: docs/CONFIGURATION.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,11 +185,11 @@ Run `./awmg --help` for full CLI options. Key flags:
185
185
- Enables per-server DIFC guard assignment independent of `guard-policies`
186
186
- Example: `guard = "github"` (uses the guard named `github` from `[guards.github]`)
187
187
188
-
- **`connect_timeout`** (optional, HTTP servers only): Per-transport connection timeout in seconds for connecting to HTTP backends. The gateway tries streamable HTTP, then SSE, then plain JSON-RPC over HTTP POST in sequence; this timeout applies to each attempt. It does **not** set the end-to-end `tools/call` execution timeout. Default: `30`.
188
+
- **`connectTimeout`** (preferred JSON) / **`connect_timeout`** (legacy JSON alias, HTTP servers only): Per-transport connection timeout in seconds for connecting to HTTP backends. The gateway tries streamable HTTP, then SSE, then plain JSON-RPC over HTTP POST in sequence; this timeout applies to each attempt. It does **not** set the end-to-end `tools/call` execution timeout. Default: `30`.
189
189
190
-
- **`tool_timeout`** (optional): Per-server tool invocation timeout in seconds. When set to a positive value, overrides the global tool timeout for `tools/call` requests to this specific server. This allows reusable shared workflow components wrapping long-running HTTP MCP servers to set an appropriate timeout once, without requiring every consumer to configure `MCP_GATEWAY_TOOL_TIMEOUT`. Minimum: `10`. Omit the field (or set to `0`) to fall back to the global timeout.
190
+
- **`toolTimeout`** (preferred JSON) / **`tool_timeout`** (legacy JSON alias, optional): Per-server tool invocation timeout in seconds. When set to a positive value, overrides the global tool timeout for `tools/call` requests to this specific server. This allows reusable shared workflow components wrapping long-running HTTP MCP servers to set an appropriate timeout once, without requiring every consumer to configure `MCP_GATEWAY_TOOL_TIMEOUT`. Minimum: `10`. Omit the field (or set to `0`) to fall back to the global timeout.
191
191
- Global timeout field name: **`toolTimeout`** in stdin JSON (`gateway.toolTimeout`), **`tool_timeout`** in TOML (`[gateway]` → `tool_timeout`)
192
-
- Example (stdin JSON): `"tool_timeout": 600` on an HTTP MCP server that may take up to 10 minutes
192
+
- Example (stdin JSON): `"toolTimeout": 600` on an HTTP MCP server that may take up to 10 minutes
193
193
- Example (TOML): `tool_timeout = 600` under a `[servers.my-server]` section
194
194
195
195
- **`rate_limit_threshold`** (optional, TOML/JSON file configs only): Number of consecutive rate-limit errors from this backend that will trip the circuit breaker (transition CLOSED → OPEN). When OPEN, requests are immediately rejected until the breaker is eligible to transition to HALF-OPEN again; this is normally controlled by `rate_limit_cooldown`, but if the gateway knows an upstream rate-limit reset time (for example from response headers or parsed tool error text), that reset time takes precedence. **Not available in JSON stdin format.** Default: `3`.
@@ -394,7 +394,8 @@ The `customSchemas` top-level field allows you to define custom server types bey
394
394
|`domain`| Gateway domain (`"localhost"`, `"host.docker.internal"`, or `"${VAR}"`) | (unset) |
395
395
|`startupTimeout`| Seconds to wait for backend startup |`30`|
396
396
|`toolTimeout`| Maximum seconds for a single tool call, enforced as a context deadline on all backend requests (stdio and HTTP) |`60`|
397
-
|`payloadDir`| Directory for large payload files |`/tmp/jq-payloads`|
397
+
|`payloadDir`| Directory for large payload files. Must be an absolute path. |`/tmp/jq-payloads`|
398
+
|`payloadPathPrefix`| Optional path prefix used when returning `payloadPath` values to clients (for example when the host payload directory is mounted at a different in-container path) | (empty - use actual filesystem path) |
398
399
|`payloadSizeThreshold` (JSON) / `payload_size_threshold` (TOML) | Size threshold in bytes; responses larger than this are stored to disk and returned as a `payloadPath` reference |`524288` (512 KB) |
399
400
|`trustedBots` (JSON) / `trusted_bots` (TOML) | Optional list of additional bot usernames to trust with "approved" integrity level. Additive to the built-in trusted bot list. When specified, must be a non-empty array with non-empty string entries (spec §4.1.3.4); omit the field entirely if not needed. Example: `["my-bot[bot]", "org-automation"]`| (disabled) |
400
401
|`keepaliveInterval` (JSON) / `keepalive_interval` (TOML) | Interval (seconds) between keepalive pings sent to HTTP backends. Prevents remote servers from expiring idle sessions. Set to `-1` to disable keepalive pings entirely. |`1500` (25 min) |
Copy file name to clipboardExpand all lines: docs/ENVIRONMENT_VARIABLES.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ When running locally (`run.sh`), these variables are optional (warnings shown if
23
23
|`MCP_GATEWAY_API_KEY`| Informational only — not read directly by the binary; must be referenced in your config via `"${MCP_GATEWAY_API_KEY}"` to enable authentication | (disabled) |
24
24
|`MCP_GATEWAY_LOG_DIR`| Log file directory (sets default for `--log-dir` flag) |`/tmp/gh-aw/mcp-logs`|
25
25
|`MCP_GATEWAY_WASM_CACHE_DIR`| Disk-backed wazero compilation cache directory (sets default for `--wasm-cache-dir`; defaults to `<log-dir>/wazero-cache`) |`/tmp/gh-aw/mcp-logs/wazero-cache`|
26
-
|`MCP_GATEWAY_PAYLOAD_DIR`| Large payload storage directory (sets default for `--payload-dir` flag) |`/tmp/jq-payloads`|
26
+
|`MCP_GATEWAY_PAYLOAD_DIR`| Large payload storage directory (sets default for `--payload-dir` flag). Must be an absolute path.|`/tmp/jq-payloads`|
27
27
|`MCP_GATEWAY_PAYLOAD_PATH_PREFIX`| Path prefix for remapping payloadPath returned to clients (sets default for `--payload-path-prefix` flag) | (empty - use actual filesystem path) |
28
28
|`MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD`| Size threshold in bytes for payload storage (sets default for `--payload-size-threshold` flag) |`524288`|
29
29
|`MCP_GATEWAY_SESSION_TIMEOUT`| Session timeout for stateful sessions in both unified (`/mcp`) and routed (`/mcp/<server>`) modes. Accepts Go duration strings (e.g., `30m`, `1h`). Default is 6 hours to match the GitHub Actions default timeout. |`6h`|
0 commit comments