Skip to content

Commit b25e549

Browse files
authored
feat: raise default MCP_GATEWAY_SESSION_TIMEOUT from 2h to 6h (#3201)
The default unified-mode session timeout was 2h; 6h matches the GitHub Actions default job timeout, preventing premature session expiry in standard CI workflows. ## Changes - **`internal/server/transport.go`** — default argument to `GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", …)` changed from `2*time.Hour` → `6*time.Hour` - **`internal/envutil/envutil_test.go`** — updated real-world scenario test to reflect the new default - **`docs/ENVIRONMENT_VARIABLES.md`** / **`AGENTS.md`** — updated default values and rationale in documentation > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `example.com` > - Triggering command: `/tmp/go-build1794183046/b514/launcher.test /tmp/go-build1794183046/b514/launcher.test -test.testlogfile=/tmp/go-build1794183046/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1794183046/b434/vet.cfg /mcp/connection.go /mcp/errors.go x_amd64/vet /tmp/go-build188/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -imultiarch x86_64-linux-gnu-bool x_amd64/vet -W g_.a /tmp/go-build188-ifaceassert x_amd64/vet . ernal/middleware-atomic --64 x_amd64/vet` (dns block) > - `invalid-host-that-does-not-exist-12345.com` > - Triggering command: `/tmp/go-build1794183046/b496/config.test /tmp/go-build1794183046/b496/config.test -test.testlogfile=/tmp/go-build1794183046/b496/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1794183046/b394/vet.cfg 5.0/internal/doc-c=4 5.0/internal/oau-nolocalimports x_amd64/vet /tmp/go-build188/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet nal/strs x86_64-linux-gnu-bool x_amd64/vet abis�� g_.a -I x_amd64/vet` (dns block) > - `nonexistent.local` > - Triggering command: `/tmp/go-build1794183046/b514/launcher.test /tmp/go-build1794183046/b514/launcher.test -test.testlogfile=/tmp/go-build1794183046/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1794183046/b434/vet.cfg /mcp/connection.go /mcp/errors.go x_amd64/vet /tmp/go-build188/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -imultiarch x86_64-linux-gnu-bool x_amd64/vet -W g_.a /tmp/go-build188-ifaceassert x_amd64/vet . ernal/middleware-atomic --64 x_amd64/vet` (dns block) > - `slow.example.com` > - Triggering command: `/tmp/go-build1794183046/b514/launcher.test /tmp/go-build1794183046/b514/launcher.test -test.testlogfile=/tmp/go-build1794183046/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1794183046/b434/vet.cfg /mcp/connection.go /mcp/errors.go x_amd64/vet /tmp/go-build188/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -imultiarch x86_64-linux-gnu-bool x_amd64/vet -W g_.a /tmp/go-build188-ifaceassert x_amd64/vet . ernal/middleware-atomic --64 x_amd64/vet` (dns block) > - `this-host-does-not-exist-12345.com` > - Triggering command: `/tmp/go-build1794183046/b523/mcp.test /tmp/go-build1794183046/b523/mcp.test -test.testlogfile=/tmp/go-build1794183046/b523/testlog.txt -test.paniconexit0 -test.timeout=10m0s 9187�� .cfg pmgFoLvmr x_amd64/vet . --gdwarf2 --64 x_amd64/vet .cfg�� 9187355/b400/_pkg_.a 64/src/net/http/httptest/httptest.go x_amd64/vet -p t/transform -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: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/github/gh-aw-mcpg/settings/copilot/coding_agent) (admins only) > > </details>
2 parents a05ccb5 + d8fbff1 commit b25e549

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ DEBUG_COLORS=0 DEBUG=* ./awmg --config config.toml
376376
- `MCP_GATEWAY_PAYLOAD_DIR` - Large payload storage directory (sets default for `--payload-dir` flag, default: `/tmp/jq-payloads`)
377377
- `MCP_GATEWAY_PAYLOAD_PATH_PREFIX` - Path prefix for remapping payloadPath returned to clients (sets default for `--payload-path-prefix` flag, default: empty)
378378
- `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`)
379-
- `MCP_GATEWAY_SESSION_TIMEOUT` - Session timeout for unified mode (`/mcp`) stateful sessions. Accepts Go duration strings (e.g., `30m`, `1h`, `2h30m`). Routed mode is unaffected (hardcoded 30 min). (default: `2h`)
379+
- `MCP_GATEWAY_SESSION_TIMEOUT` - Session timeout for unified mode (`/mcp`) stateful sessions. Accepts Go duration strings (e.g., `30m`, `1h`, `2h30m`). Routed mode is unaffected (hardcoded 30 min). (default: `6h`)
380380
- `DOCKER_HOST` - Docker daemon socket path (default: `/var/run/docker.sock`)
381381
- `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`)
382382
- `MCP_GATEWAY_GUARDS_MODE` - Guards enforcement mode: `strict` (deny violations), `filter` (remove denied tools), `propagate` (auto-adjust agent labels) (sets default for `--guards-mode`, default: `strict`)

docs/ENVIRONMENT_VARIABLES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ When running locally (`run.sh`), these variables are optional (warnings shown if
2525
| `MCP_GATEWAY_PAYLOAD_DIR` | Large payload storage directory (sets default for `--payload-dir` flag) | `/tmp/jq-payloads` |
2626
| `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) |
2727
| `MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD` | Size threshold in bytes for payload storage (sets default for `--payload-size-threshold` flag) | `524288` |
28-
| `MCP_GATEWAY_SESSION_TIMEOUT` | Session timeout for unified mode (`/mcp`) stateful sessions. Accepts Go duration strings (e.g., `30m`, `1h`). Default is 2 hours to accommodate long-running agentic workflows. Routed mode is unaffected (hardcoded 30 min). | `2h` |
28+
| `MCP_GATEWAY_SESSION_TIMEOUT` | Session timeout for unified mode (`/mcp`) stateful sessions. Accepts Go duration strings (e.g., `30m`, `1h`). Default is 6 hours to match the GitHub Actions default timeout. Routed mode is unaffected (hardcoded 30 min). | `6h` |
2929
| `MCP_GATEWAY_WASM_GUARDS_DIR` | Root directory for per-server WASM guards (`<root>/<serverID>/*.wasm`, first match is loaded) | (disabled) |
3030
| `MCP_GATEWAY_GUARDS_MODE` | Guards enforcement mode: `strict` (deny violations), `filter` (remove denied tools), `propagate` (auto-adjust agent labels) (sets default for `--guards-mode`) | `strict` |
3131
| `MCP_GATEWAY_GUARDS_SINK_SERVER_IDS` | Comma-separated sink server IDs for JSONL guards tag enrichment (sets default for `--guards-sink-server-ids`) | (disabled) |

internal/envutil/envutil_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ func TestGetEnvDurationRealWorldScenarios(t *testing.T) {
112112
defer os.Unsetenv("MCP_GATEWAY_SESSION_TIMEOUT")
113113

114114
// Default case
115-
result := GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 2*time.Hour)
116-
assert.Equal(t, 2*time.Hour, result)
115+
result := GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 6*time.Hour)
116+
assert.Equal(t, 6*time.Hour, result)
117117

118118
// Override with shorter timeout
119119
os.Setenv("MCP_GATEWAY_SESSION_TIMEOUT", "30m")
120-
result = GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 2*time.Hour)
120+
result = GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 6*time.Hour)
121121
assert.Equal(t, 30*time.Minute, result)
122122

123123
// Override with longer timeout
124124
os.Setenv("MCP_GATEWAY_SESSION_TIMEOUT", "4h")
125-
result = GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 2*time.Hour)
125+
result = GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 6*time.Hour)
126126
assert.Equal(t, 4*time.Hour, result)
127127
})
128128
}

internal/server/transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func CreateHTTPServerForMCP(addr string, unifiedServer *UnifiedServer, apiKey st
3838
}, &sdk.StreamableHTTPOptions{
3939
Stateless: false, // Support stateful sessions
4040
Logger: logger.NewSlogLoggerWithHandler(logTransport), // Integrate SDK logging with project logger
41-
SessionTimeout: envutil.GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 2*time.Hour), // Configurable; 2h default accommodates long-running workflows with idle periods
41+
SessionTimeout: envutil.GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 6*time.Hour), // Configurable; 6h default matches GitHub Actions default timeout
4242
})
4343

4444
// Apply standard middleware stack (SDK logging → shutdown check → auth)

0 commit comments

Comments
 (0)