Conversation
…er construction Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/138c6db4-6535-4161-b982-09b8470d9702 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the internal MCP HTTP server setup by extracting the repeated “StreamableHTTP handler + session auto-init + standard middleware chain” construction into a shared helper, so unified and routed server modes stay in sync when the handler stack changes.
Changes:
- Added
buildMCPHandlerhelper to construct the standard MCP handler stack in one place. - Updated unified mode (
transport.go) to usebuildMCPHandlerinstead of inline construction. - Updated routed mode (
routed.go) to usebuildMCPHandlerinside the per-backend route loop.
Show a summary per file
| File | Description |
|---|---|
| internal/server/http_helpers.go | Introduces buildMCPHandler to centralize the StreamableHTTP + auto-init + middleware construction. |
| internal/server/transport.go | Replaces the unified-mode inline handler stack setup with a buildMCPHandler call. |
| internal/server/routed.go | Replaces the routed-mode inline handler stack setup with a buildMCPHandler call per backend route. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
| func buildMCPHandler( | ||
| serverFactory func(*http.Request) *sdk.Server, | ||
| log *logger.Logger, | ||
| sessionTimeout time.Duration, | ||
| logTag string, |
| logTag string, | ||
| unifiedServer *UnifiedServer, | ||
| apiKey, hmacSecret string, | ||
| ) http.Handler { | ||
| h := sdk.NewStreamableHTTPHandler(serverFactory, &sdk.StreamableHTTPOptions{ |
|
@copilot address the review feedback and fix the failing integration test ci check |
…ename log param Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/4cb8b5a7-15e7-4c1f-a2c7-4e34308cde7e Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Addressed both review comments in commit
Regarding the CI failures ( 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 merge main |
…-code-streamable-handler # Conflicts: # internal/server/transport.go Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Done — merged 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:
|
Both
transport.go(unified mode) androuted.go(routed mode) repeated the same three-step handler stack construction, meaning any middleware chain change required edits in two places.Changes
internal/server/http_helpers.go— addsbuildMCPHandlerhelper and amcpHandlerConfigoptions struct that encapsulates the full stack:transport.go— replaces inline 3-step construction with a singlebuildMCPHandlercall usingmcpHandlerConfig; usesgetSessionTimeout()introduced onmainrouted.go— same, inside the per-backend loop