Support configurable MCP gateway session timeout via engine.mcp.session-timeout#29354
Support configurable MCP gateway session timeout via engine.mcp.session-timeout#29354
engine.mcp.session-timeout#29354Conversation
…ession timeout - Add MCPSessionTimeout field to EngineConfig - Parse engine.mcp.session-timeout in ExtractEngineConfig - Add SessionTimeout field to MCPGatewayRuntimeConfig - Propagate session timeout from engine config in buildMCPGatewayConfig - Render sessionTimeout in gateway JSON config (mcp_renderer.go) - Add validateEngineMCPSessionTimeout (5m-12h bounds) in engine_validation.go - Wire validation in compiler_orchestrator_workflow.go - Update JSON schema with engine.mcp.session-timeout property - Add docs section in mcp-gateway.md - Add tests for extraction, validation, config building, and rendering Agent-Logs-Url: https://github.com/github/gh-aw/sessions/28633935-f9d4-454d-b410-68ff66ca2853 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/28633935-f9d4-454d-b410-68ff66ca2853 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
engine.mcp.session-timeout
There was a problem hiding this comment.
Pull request overview
Adds a per-workflow configuration option (engine.mcp.session-timeout) to control MCP gateway session lifetime, validating it at compile time and emitting it into the generated gateway JSON config.
Changes:
- Parse
engine.mcp.session-timeoutintoEngineConfig.MCPSessionTimeoutand propagate it into the built MCP gateway runtime config. - Render
sessionTimeoutinto the gateway JSON block when set; add min/max duration constants and compiler validation (5m–12h). - Update schema and docs to document the new field; add unit tests covering extraction, validation, propagation, and rendering.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/tools_types.go | Adds SessionTimeout to MCPGatewayRuntimeConfig. |
| pkg/workflow/mcp_renderer.go | Emits sessionTimeout into gateway JSON when non-empty. |
| pkg/workflow/mcp_renderer_test.go | Adds rendering tests for sessionTimeout presence/absence. |
| pkg/workflow/mcp_gateway_config.go | Propagates engine-level session timeout into gateway runtime config. |
| pkg/workflow/mcp_gateway_config_test.go | Tests propagation behavior from EngineConfig into gateway config. |
| pkg/workflow/engine.go | Extracts engine.mcp.session-timeout into EngineConfig. |
| pkg/workflow/engine_config_test.go | Tests extraction behavior for the new engine mcp field. |
| pkg/workflow/engine_validation.go | Validates duration format and bounds using new constants. |
| pkg/workflow/engine_validation_test.go | Adds validation tests for valid/invalid durations and bounds. |
| pkg/workflow/compiler_orchestrator_workflow.go | Hooks session-timeout validation into the file-based parse pipeline. |
| pkg/parser/schemas/main_workflow_schema.json | Adds engine.mcp.session-timeout to the workflow schema. |
| pkg/constants/constants.go | Introduces min/max duration constants for the new validation. |
| docs/src/content/docs/reference/mcp-gateway.md | Documents sessionTimeout semantics, precedence, and changelog entry. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 13/13 changed files
- Comments generated: 6
| "properties": { | ||
| "session-timeout": { | ||
| "type": "string", | ||
| "description": "Session timeout for MCP gateway sessions as a Go duration string (e.g. \"30m\", \"4h\", \"6h\"). Must be between 5m and 12h. Empty or omitted uses the gateway default (6h). Longer timeouts benefit multi-hour workflows such as large-scale migrations; shorter values free gateway resources sooner.", |
| // Validate optional engine.mcp.session-timeout configuration. | ||
| if err := c.validateEngineMCPSessionTimeout(workflowData); err != nil { | ||
| return nil, fmt.Errorf("%s: %w", cleanPath, err) | ||
| } |
| "session-timeout": { | ||
| "type": "string", | ||
| "description": "Session timeout for MCP gateway sessions as a Go duration string (e.g. \"30m\", \"4h\", \"6h\"). Must be between 5m and 12h. Empty or omitted uses the gateway default (6h). Longer timeouts benefit multi-hour workflows such as large-scale migrations; shorter values free gateway resources sooner.", | ||
| "examples": ["30m", "1h", "4h", "6h", "12h"] |
| name: "extracts session-timeout using camelCase key", | ||
| frontmatter: map[string]any{ | ||
| "engine": map[string]any{ | ||
| "id": "copilot", | ||
| "mcp": map[string]any{ | ||
| "sessionTimeout": "30m", | ||
| }, | ||
| }, | ||
| }, | ||
| expectedTimeout: "30m", | ||
| }, | ||
| { |
| | `trustedBots` | array[string] | No | Additional GitHub bot identity strings (e.g., `github-actions[bot]`) passed to the gateway and merged with its built-in trusted identity list. This field is additive — it extends the internal list but cannot remove built-in entries. | | ||
| | `keepaliveInterval` | integer | No | Keepalive ping interval in seconds for HTTP MCP backends. Prevents session expiry during long-running tasks. Use `-1` to disable, `0` or unset for gateway default (1500s = 25 min), or a positive integer for a custom interval. | | ||
| | `sessionTimeout` | string | No | Session timeout for MCP gateway sessions as a Go duration string (e.g. `"30m"`, `"4h"`, `"6h"`). Empty or omitted uses the gateway default (6h). Must be between 5m and 12h when set by the workflow compiler (infrastructure operators may override via `MCP_GATEWAY_SESSION_TIMEOUT` env var). | | ||
| | `opentelemetry` | object | No | OpenTelemetry configuration for emitting distributed tracing events for MCP calls. See Section 4.1.3.6 for details. | |
| PayloadSizeThreshold int `yaml:"payload-size-threshold,omitempty"` // Size threshold in bytes for storing payloads to disk (default: 524288 = 512KB) | ||
| TrustedBots []string `yaml:"trusted-bots,omitempty"` // Additional bot identity strings to pass to the gateway, merged with its built-in list | ||
| KeepaliveInterval int `yaml:"keepalive-interval,omitempty"` // Keepalive ping interval in seconds for HTTP MCP backends (0=default 1500s, -1=disabled, >0=custom) | ||
| SessionTimeout string `yaml:"session-timeout,omitempty"` // Session timeout for MCP gateway sessions as a Go duration string (e.g. "4h", "30m"); empty = gateway default (6h) |
🧪 Test Quality Sentinel ReportTest Quality Score: 80/100✅ Excellent
Test Classification Details
Score Breakdown
Language SupportTests analyzed: Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §25178770892
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Commit pushed:
|
|
@copilot review all comments |
…ion, fix docs references - Drop sessionTimeout camelCase alias in engine.go (schema only allows session-timeout) - Remove camelCase test case from engine_config_test.go - Add validateEngineMCPSessionTimeout call to ParseWorkflowString (compiler_string_api.go) - Fix OpenTelemetry table reference: Section 4.1.3.6 -> 4.1.3.7 in mcp-gateway.md - Update tools_types.go comment to reflect full precedence chain - Update schema description to mention MCP_GATEWAY_SESSION_TIMEOUT env var precedence Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5441c30c-eea8-47fe-991f-07f56d21b15a Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed all review comments in b432096:
Warning 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot no MCPSessionTimeoutMax , let it be as high as needed |
- Remove MCPSessionTimeoutMax constant from pkg/constants - Drop upper-bound check from validateEngineMCPSessionTimeout (min 5m only) - Replace "too long - 13h" test case with "valid duration 24h (no upper bound)" - Update schema description, docs table, compliance rules, changelog, and ADR to reflect no upper bound Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4b9e19de-6066-4b7e-a4a9-340a513242e1 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in b4f3831. |
|
@copilot review all comments |
All comments are addressed in the current commits. Summary of the complete set:
|
All workflows sharing a gateway instance inherit the same session lifetime (
MCP_GATEWAY_SESSION_TIMEOUT), with no per-workflow override. This addsengine.mcp.session-timeoutso workflow authors can declare session lifetime requirements declaratively.Frontmatter
Changes
engine.go): Parsesengine.mcp.session-timeout(kebab-case only) from theengine.mcpsub-object intoEngineConfig.MCPSessionTimeouttools_types.go): AddedSessionTimeout stringtoMCPGatewayRuntimeConfig; comment reflects full precedence chain (stdin config > MCP_GATEWAY_SESSION_TIMEOUT env var > built-in default 6h)mcp_gateway_config.go):buildMCPGatewayConfigreadsSessionTimeoutfromworkflowData.EngineConfigmcp_renderer.go): Emits"sessionTimeout": "<value>"into the gateway JSONgatewayblock when non-emptyengine_validation.go):validateEngineMCPSessionTimeoutvalidates Go duration format and enforces a minimum of 5m (no upper bound); called from both the file-based orchestrator andParseWorkflowString(Wasm/browser path)pkg/constants): AddedMCPSessionTimeoutMin(5m); no maximum constantmain_workflow_schema.json): Addedmcpsub-object withsession-timeoutproperty (kebab-case only,additionalProperties: false); description documents env var precedence and no upper boundmcp-gateway.md): New §4.1.3.6 coveringsessionTimeoutsemantics and precedence (stdin config > MCP_GATEWAY_SESSION_TIMEOUT env var > gateway default 6h); OpenTelemetry section corrected to §4.1.3.7; v1.11.0 changelog entry