Skip to content

refactor: co-locate sys tool handlers and extract savePayload to payload.go#7934

Merged
lpcox merged 4 commits into
mainfrom
copilot/refactor-semantic-function-clustering
Jun 22, 2026
Merged

refactor: co-locate sys tool handlers and extract savePayload to payload.go#7934
lpcox merged 4 commits into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Two semantic placement issues identified in a codebase analysis: sysInitHandler lived in session.go instead of alongside the other sys tool handlers, and savePayload was embedded in the 815-line jqschema.go despite being a self-contained concern.

internal/server/

  • Moved sysInitHandler from session.gosystem_tools.go, so all sys___* handlers registered in registerSysTools() are now co-located
  • Removed unused sdk import from session.go
  • session.go now focuses purely on session lifecycle

internal/middleware/

  • Extracted savePayload from jqschema.go → new payload.go, following the existing schema.go split-by-responsibility pattern
  • Removed unused os and path/filepath imports from jqschema.go
  • jqschema.go drops ~57 lines; payload storage is independently locatable and testable

GitHub Advanced Security started work on behalf of lpcox June 22, 2026 17:02 View session
GitHub Advanced Security finished work on behalf of lpcox June 22, 2026 17:02
Copilot AI changed the title [WIP] Refactor semantic function clustering analysis results refactor: co-locate sys tool handlers and extract savePayload to payload.go Jun 22, 2026
Copilot AI requested a review from lpcox June 22, 2026 17:10
Copilot finished work on behalf of lpcox June 22, 2026 17:10
GitHub Advanced Security started work on behalf of lpcox June 22, 2026 17:12 View session
GitHub Advanced Security finished work on behalf of lpcox June 22, 2026 17:12
@lpcox lpcox marked this pull request as ready for review June 22, 2026 17:19
Copilot AI review requested due to automatic review settings June 22, 2026 17:19

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 is a refactor to improve code organization in the MCP Gateway by co-locating system tool handlers and splitting payload persistence into a dedicated middleware file, keeping session lifecycle and jq-schema responsibilities more focused.

Changes:

  • Moved sysInitHandler from session.go to system_tools.go to co-locate all sys___* handlers with sys tool registration.
  • Extracted savePayload from jqschema.go into a new payload.go file in internal/middleware/.
  • Cleaned up now-unused imports in session.go and jqschema.go.
Show a summary per file
File Description
internal/server/system_tools.go Adds sysInitHandler alongside other sys tool handlers.
internal/server/session.go Removes sysInitHandler and drops the unused SDK import, keeping the file focused on session lifecycle helpers.
internal/middleware/payload.go New file containing savePayload for payload-on-disk handling.
internal/middleware/jqschema.go Removes inline savePayload and associated imports after extraction.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 2

Comment thread internal/server/system_tools.go Outdated
Comment thread internal/server/system_tools.go Outdated
lpcox and others added 2 commits June 22, 2026 11:43
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 22, 2026 18:44 View session
GitHub Advanced Security started work on behalf of lpcox June 22, 2026 18:44 View session
GitHub Advanced Security finished work on behalf of lpcox June 22, 2026 18:44
GitHub Advanced Security finished work on behalf of lpcox June 22, 2026 18:44
@lpcox lpcox merged commit ac9bf59 into main Jun 22, 2026
27 checks passed
@lpcox lpcox deleted the copilot/refactor-semantic-function-clustering branch June 22, 2026 18:57
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