Skip to content

Refactor HTTP transport auth helpers and simplify sys/tracing boundaries#7693

Merged
lpcox merged 9 commits into
mainfrom
copilot/refactor-http-transport-split
Jun 18, 2026
Merged

Refactor HTTP transport auth helpers and simplify sys/tracing boundaries#7693
lpcox merged 9 commits into
mainfrom
copilot/refactor-http-transport-split

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This PR addresses four carry-over refactoring items from the semantic clustering analysis plus the dead SysServer routing 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

    • Moved the HTTP client/auth construction layer out of internal/mcp/http_transport.go into internal/mcp/http_transport_client.go
    • Isolates:
      • newMCPClient
      • headerInjectingRoundTripper
      • buildHTTPClientWithHeaders
      • oidcRoundTripper
      • buildHTTPClientWithOIDC
    • Leaves http_transport.go focused on negotiation, parsing, request execution, and session handling
  • Sys tool session lifecycle moved to session.go

    • Extracted the inline sys___init / sys___list_servers closures from internal/server/tool_registry.go
    • Added named UnifiedServer methods in internal/server/session.go:
      • sysInitHandler
      • sysListServersHandler
    • Consolidates session creation, session validation, and payload-directory setup with the rest of the session lifecycle code
  • Tracing ParentContext inlined at the public API

    • Moved the full parent-context construction logic into internal/tracing/provider.go:ParentContext
    • Removed the extra forwarding layer from internal/tracing/config_resolver.go
    • Keeps the exported tracing API and its implementation in one place
  • Dead SysServer request router removed

    • Simplified internal/server/system_tools.go to direct methods:
      • SysInit()
      • ListServers()
    • Removed the unused HandleRequest("tools/list" | "tools/call") abstraction and the dead tools/list production branch
    • Updated callSysServer to dispatch directly to SysServer methods
  • Focused test updates

    • Reworked sys tool tests to cover direct SysInit / ListServers behavior instead of the removed router
    • Added session-handler coverage for the extracted sysInitHandler and sysListServersHandler
    • Kept existing HTTP transport and tracing coverage aligned with the refactor

Example of the SysServer simplification:

func (us *UnifiedServer) callSysServer(toolName string) (interface{}, error) {
	switch toolName {
	case "sys_init":
		return us.sysServer.SysInit()
	case "sys_list_servers":
		return us.sysServer.ListServers()
	default:
		return nil, fmt.Errorf("unknown tool: %s", toolName)
	}
}

GitHub Advanced Security started work on behalf of lpcox June 17, 2026 23:39 View session
GitHub Advanced Security finished work on behalf of lpcox June 17, 2026 23:40
GitHub Advanced Security started work on behalf of lpcox June 17, 2026 23:45 View session
GitHub Advanced Security finished work on behalf of lpcox June 17, 2026 23:46
GitHub Advanced Security started work on behalf of lpcox June 17, 2026 23:49 View session
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
Copilot AI requested a review from lpcox June 17, 2026 23:49
Copilot finished work on behalf of lpcox June 17, 2026 23:49
GitHub Advanced Security finished work on behalf of lpcox June 17, 2026 23:50
@lpcox lpcox marked this pull request as ready for review June 18, 2026 00:26
Copilot AI review requested due to automatic review settings June 18, 2026 00:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ParentContext and removes the extra forwarding layer in config_resolver.go.
  • Simplifies sys tool dispatch to call SysServer.SysInit() / SysServer.ListServers() directly, and moves sys session lifecycle handlers into session.go.
  • Splits HTTP transport auth/client construction helpers into a dedicated http_transport_client.go file 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

Comment thread internal/server/system_tools_test.go Outdated
Comment thread internal/server/system_tools_test.go Outdated
Comment thread internal/server/session.go Outdated
Comment thread internal/server/session.go Outdated
Comment thread internal/server/session.go Outdated
}

logger.LogInfo("client", "MCP session initialized successfully, session=%s, available_servers=%v", sessionID, us.launcher.ServerIDs())
return us.callAndLogSysTool(sessionID, "session initialization", "sys_init")
Comment thread internal/server/session.go Outdated
lpcox and others added 5 commits June 17, 2026 17:31
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>
GitHub Advanced Security started work on behalf of lpcox June 18, 2026 00:32 View session
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 00:33
GitHub Advanced Security started work on behalf of lpcox June 18, 2026 00:34 View session
@lpcox lpcox merged commit 272e089 into main Jun 18, 2026
28 checks passed
@lpcox lpcox deleted the copilot/refactor-http-transport-split branch June 18, 2026 00:35
GitHub Advanced Security started work on behalf of lpcox June 18, 2026 00:35 View session
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 00:35
Copilot stopped work on behalf of lpcox due to an error June 18, 2026 00:35
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 00:36
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants