refactor: split oversized files by responsibility (mcp/connection, proxy/handler, httputil) - #4701
Merged
Merged
Conversation
4 tasks
…putil Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/157ad9ad-2fb1-4217-89cc-7854435a6d50 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor semantic function clustering analysis based on identified opportunities
refactor: split oversized files by responsibility (mcp/connection, proxy/handler, httputil)
Apr 28, 2026
lpcox
marked this pull request as ready for review
April 28, 2026 02:54
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors oversized internal packages by splitting mixed-responsibility Go files into smaller units (MCP connection/pagination/logging, proxy response transforms, and GitHub-specific HTTP utilities) while keeping behavior the same.
Changes:
- Split
internal/mcp/connection.gointo dedicated files for SDK method dispatch, RPC logging, and pagination/helpers. - Extract proxy JSON response transformation helpers from
handler.gointoresponse_transform.go. - Extract GitHub-specific HTTP helpers from
httputil.gointogithub_http.go.
Show a summary per file
| File | Description |
|---|---|
| internal/mcp/connection.go | Removes logging/SDK dispatch/pagination helpers that were moved into dedicated files. |
| internal/mcp/connection_methods.go | New file containing SDK RPC method dispatch and list/call/read wrappers. |
| internal/mcp/connection_logging.go | New file containing reconnect + RPC request/response logging helpers. |
| internal/mcp/pagination.go | New file containing shared marshal/unmarshal helpers and pagination utilities. |
| internal/proxy/handler.go | Removes response-shape transformation helpers now living outside the HTTP handler. |
| internal/proxy/response_transform.go | New file containing JSON response transformation + deep-clone helpers. |
| internal/httputil/httputil.go | Keeps generic HTTP helpers; removes GitHub-specific helpers. |
| internal/httputil/github_http.go | New file containing GitHub-specific headers + rate limit reset parsing. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/8 changed files
- Comments generated: 1
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was referenced Apr 28, 2026
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.
Three files had grown beyond single-responsibility:
mcp/connection.go(749 lines, 4 distinct concerns),proxy/handler.go(618 lines, HTTP dispatch mixed with JSON transforms), andhttputil/httputil.go(generic utilities mixed with GitHub-specific helpers). Pure mechanical splits — zero logic changes.internal/mcp/connection.go→ 4 filesconnection.goNewConnection,NewHTTPConnection,Close,reconnect*,SendRequest*connection_methods.gocallSDKMethod,listTools,callTool,listResources,readResource,listPrompts,getPromptconnection_logging.gologOutboundRPCRequest,logInboundRPC*,logReconnect*pagination.gopaginateAll,listMCPItems,marshalToResponse,unmarshalParams,callParamMethodinternal/proxy/handler.go→ newresponse_transform.goExtracted 5 pure data-manipulation utilities that had no business sitting in the HTTP handler layer:
internal/httputil/httputil.go→ newgithub_http.goFollows the existing
envutil/github.gopattern — GitHub-specific helpers extracted to a dedicated file: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:
example.com/tmp/go-build864305169/b509/launcher.test /tmp/go-build864305169/b509/launcher.test -test.testlogfile=/tmp/go-build864305169/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true ache/go/1.25.9/x64/src/runtime/c--gdwarf-5 8J3C/BnJLWL_dWV6lGp5L8J3C x_amd64/compile(dns block)/tmp/go-build1786442162/b513/launcher.test /tmp/go-build1786442162/b513/launcher.test -test.testlogfile=/tmp/go-build1786442162/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build864305169/b491/config.test /tmp/go-build864305169/b491/config.test -test.testlogfile=/tmp/go-build864305169/b491/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true rnal/descopts/op-errorsas ache/go/1.25.9/x-ifaceassert x_amd64/compile(dns block)/tmp/go-build1786442162/b495/config.test /tmp/go-build1786442162/b495/config.test -test.testlogfile=/tmp/go-build1786442162/b495/testlog.txt -test.paniconexit0 -test.timeout=10m0s(dns block)nonexistent.local/tmp/go-build864305169/b509/launcher.test /tmp/go-build864305169/b509/launcher.test -test.testlogfile=/tmp/go-build864305169/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true ache/go/1.25.9/x64/src/runtime/c--gdwarf-5 8J3C/BnJLWL_dWV6lGp5L8J3C x_amd64/compile(dns block)/tmp/go-build1786442162/b513/launcher.test /tmp/go-build1786442162/b513/launcher.test -test.testlogfile=/tmp/go-build1786442162/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s(dns block)slow.example.com/tmp/go-build864305169/b509/launcher.test /tmp/go-build864305169/b509/launcher.test -test.testlogfile=/tmp/go-build864305169/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true ache/go/1.25.9/x64/src/runtime/c--gdwarf-5 8J3C/BnJLWL_dWV6lGp5L8J3C x_amd64/compile(dns block)/tmp/go-build1786442162/b513/launcher.test /tmp/go-build1786442162/b513/launcher.test -test.testlogfile=/tmp/go-build1786442162/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s(dns block)this-host-does-not-exist-12345.com/tmp/go-build864305169/b518/mcp.test /tmp/go-build864305169/b518/mcp.test -test.testlogfile=/tmp/go-build864305169/b518/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -quiet 649241/b151/ x_amd64/vet -I . -imultiarch x_amd64/vet 6492�� 1.80.0/balancer/balancer.go 1.80.0/balancer/conn_state_evalu-nolocalimports x_amd64/vet --gdwarf-5 --64 -o jk0CHzx/dUnZUsTpJceORqTvO77n(dns block)/tmp/go-build1786442162/b522/mcp.test /tmp/go-build1786442162/b522/mcp.test -test.testlogfile=/tmp/go-build1786442162/b522/testlog.txt -test.paniconexit0 -test.timeout=10m0s -o /tmp/go-build175649241/b461/_pkg-p -trimpath x_amd64/vet -p github.com/githu/usr/bin/runc -lang=go1.25 x_amd64/vet -uns�� -unreachable=false /tmp/go-build864305169/b035/vet.-nolocalimports x_amd64/vet -c=4 -nolocalimports -importcfg x_amd64/vet(dns block)If you need me to access, download, or install something from one of these locations, you can either: