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
feat: MCP_GATEWAY_TOOL_TIMEOUT env var + minimum 10s bound for toolTimeout (no upper limit) (#4967)
Slow MCP backends (e.g. Repo Mind full-text search) fail with the
hardcoded 60s tool timeout and had no way to override it per-workflow.
The `toolTimeout` field already existed in the stdin JSON schema but
lacked an env var fallback.
## Changes
**Env var fallback (`MCP_GATEWAY_TOOL_TIMEOUT`)**
- Priority chain: stdin `gateway.toolTimeout` →
`MCP_GATEWAY_TOOL_TIMEOUT` env var → built-in default (60s)
- Applied in `convertStdinConfig` for both "gateway section present" and
"no gateway section" paths
- Public `GetGatewayToolTimeoutFromEnv()` + private
`toolTimeoutEnvOrDefault()` in `config_env.go`
- Env var is only evaluated when stdin omits `gateway.toolTimeout`,
avoiding spurious log noise
**Bounds enforcement (minimum 10s, no upper limit)**
- New `rules.TimeoutMinimum(timeout, min, ...)` function for
minimum-only validation
- `validateGatewayConfig` uses `TimeoutMinimum(10)` for `toolTimeout` —
any value ≥ 10 seconds is accepted
- JSON schema updated: `minimum: 10` (no `maximum`)
- Constant `ToolTimeoutMin = 10` exported from `config_env.go`
**Example usage**
```json
{
"gateway": {
"toolTimeout": 3600
},
"mcpServers": { "repo-mind": { "type": "http", "url": "..." } }
}
```
Or without touching the config:
```bash
MCP_GATEWAY_TOOL_TIMEOUT=3600 ./awmg --config-stdin ...
```
**Test updates**
- New table-driven tests for `GetGatewayToolTimeoutFromEnv`,
`toolTimeoutEnvOrDefault`, and the three-level priority in
`convertStdinConfig`
- Tests cover large values (3600 = 1 hour, 86400 = 24 hours) to confirm
no upper bound
- Existing tests updated to reflect the minimum-only constraint
-`MCP_GATEWAY_PAYLOAD_PATH_PREFIX` - Path prefix for remapping payloadPath returned to clients (sets default for `--payload-path-prefix` flag, default: empty)
387
387
-`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`)
388
388
-`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`)
389
+
-`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`)
-`MCP_GATEWAY_GUARDS_SINK_SERVER_IDS` - Comma-separated server IDs whose RPC JSONL logs should include agent secrecy/integrity tag snapshots (sets default for `--guards-sink-server-ids`)
Copy file name to clipboardExpand all lines: docs/ENVIRONMENT_VARIABLES.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ When running locally (`run.sh`), these variables are optional (warnings shown if
26
26
|`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) |
27
27
|`MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD`| Size threshold in bytes for payload storage (sets default for `--payload-size-threshold` flag) |`524288`|
28
28
|`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`|
29
+
|`MCP_GATEWAY_TOOL_TIMEOUT`| Tool invocation timeout in seconds. Used as fallback when `gateway.toolTimeout` is not set in the stdin JSON config. Accepts any integer ≥ 10 (no upper bound). Priority: stdin `gateway.toolTimeout` > this env var > built-in default. |`60`|
29
30
|`MCP_GATEWAY_WASM_GUARDS_DIR`| Root directory for per-server WASM guards (`<root>/<serverID>/*.wasm`, first match is loaded) | (disabled) |
|`MCP_GATEWAY_GUARDS_SINK_SERVER_IDS`| Comma-separated sink server IDs for JSONL guards tag enrichment (sets default for `--guards-sink-server-ids`) | (disabled) |
0 commit comments