Refactor HTTP transport auth helpers and simplify sys/tracing boundaries#7693
Merged
Conversation
Copilot
AI
changed the title
[WIP] Refactor HTTP transport negotiation and dead-code paths
Refactor HTTP transport auth helpers and simplify sys/tracing boundaries
Jun 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors several internal boundaries to better align responsibilities across the MCP HTTP transport layer, sys tool dispatch/session lifecycle, and tracing parent-context construction, while removing a dead SysServer routing abstraction and updating tests accordingly.
Changes:
- Inlines W3C parent span context construction into
tracing.ParentContextand removes the extra forwarding layer inconfig_resolver.go. - Simplifies sys tool dispatch to call
SysServer.SysInit()/SysServer.ListServers()directly, and moves sys session lifecycle handlers intosession.go. - Splits HTTP transport auth/client construction helpers into a dedicated
http_transport_client.gofile and updates tests for the refactor.
Show a summary per file
| File | Description |
|---|---|
| internal/tracing/provider.go | Inlines ParentContext W3C trace/span parsing and context enrichment. |
| internal/tracing/provider_test.go | Updates test descriptions to reference ParentContext after refactor. |
| internal/tracing/config_resolver.go | Removes the now-redundant resolveParentContext implementation. |
| internal/server/tool_registry.go | Switches sys tool dispatch to direct SysServer method calls and wires handlers from session.go. |
| internal/server/system_tools.go | Removes dead request router and exposes direct SysInit / ListServers methods. |
| internal/server/system_tools_test.go | Reworks tests to target direct SysInit / ListServers behavior and updates concurrency test structure. |
| internal/server/session.go | Adds sysInitHandler / sysListServersHandler and consolidates sys tool session lifecycle with session management. |
| internal/server/session_test.go | Adds coverage for the extracted sys session handlers. |
| internal/mcp/http_transport.go | Removes HTTP client/auth helper implementations to focus file on transport negotiation/parsing/execution. |
| internal/mcp/http_transport_client.go | New file containing MCP client creation + header/OIDC RoundTrippers and HTTP client construction helpers. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 10/10 changed files
- Comments generated: 7
| } | ||
|
|
||
| logger.LogInfo("client", "MCP session initialized successfully, session=%s, available_servers=%v", sessionID, us.launcher.ServerIDs()) | ||
| return us.callAndLogSysTool(sessionID, "session initialization", "sys_init") |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot stopped work on behalf of
lpcox due to an error
June 18, 2026 00:35
Copilot stopped work on behalf of
lpcox due to an error
June 18, 2026 00:37
Copilot stopped work on behalf of
lpcox due to an error
June 18, 2026 00:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses four carry-over refactoring items from the semantic clustering analysis plus the dead
SysServerrouting path. The goal is to tighten file boundaries so transport auth, session lifecycle, tracing parent-context construction, and sys tool dispatch each live with their actual responsibilities.HTTP transport auth/client split
internal/mcp/http_transport.gointointernal/mcp/http_transport_client.gonewMCPClientheaderInjectingRoundTripperbuildHTTPClientWithHeadersoidcRoundTripperbuildHTTPClientWithOIDChttp_transport.gofocused on negotiation, parsing, request execution, and session handlingSys tool session lifecycle moved to
session.gosys___init/sys___list_serversclosures frominternal/server/tool_registry.goUnifiedServermethods ininternal/server/session.go:sysInitHandlersysListServersHandlerTracing
ParentContextinlined at the public APIinternal/tracing/provider.go:ParentContextinternal/tracing/config_resolver.goDead
SysServerrequest router removedinternal/server/system_tools.goto direct methods:SysInit()ListServers()HandleRequest("tools/list" | "tools/call")abstraction and the deadtools/listproduction branchcallSysServerto dispatch directly toSysServermethodsFocused test updates
SysInit/ListServersbehavior instead of the removed routersysInitHandlerandsysListServersHandlerExample of the
SysServersimplification: