refactor: move outlier functions to semantically correct files/packages#7394
Merged
lpcox merged 2 commits intoJun 12, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Refactor JSON utility in string utility package
refactor: move outlier functions to semantically correct files/packages
Jun 11, 2026
This was referenced Jun 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors internal helpers by relocating a handful of “outlier” functions into files that better match their responsibilities, without changing behavior. The goal is to improve code organization and discoverability across strutil, mcp, server, and mcpresult.
Changes:
- Moved
DeepCloneJSONout ofstrutil.gointo a dedicatedjson_clone.go. - Extracted MCP JSON-RPC helper functions from
pagination.gointo a newhelpers.go, leaving pagination focused on paging logic. - Consolidated MCP result parsing helpers (
NormalizeContentItems,ExtractTextContent) into a singlemcpresult.go, removing the prior tiny single-purpose files.
Show a summary per file
| File | Description |
|---|---|
| internal/strutil/strutil.go | Removes DeepCloneJSON from the general string-utility file. |
| internal/strutil/json_clone.go | Adds DeepCloneJSON in a semantically focused file within strutil. |
| internal/mcp/pagination.go | Removes non-pagination MCP helpers; keeps pagination primitives and list helpers. |
| internal/mcp/helpers.go | Adds shared MCP helper functions for response marshalling and param unmarshalling. |
| internal/server/http_helpers.go | Removes withResponseLogging from HTTP helpers (keeps request-body logging utilities). |
| internal/server/middleware.go | Adds withResponseLogging alongside other HTTP middleware/wrappers. |
| internal/mcpresult/mcpresult.go | Hosts both NormalizeContentItems and ExtractTextContent in one cohesive file. |
| internal/mcpresult/content_items.go | Removed as part of consolidating MCP result helpers. |
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: 0
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.
Four functions lived in files that didn't match their purpose. This moves each to its natural home with no logic changes.
Changes
strutil/json_clone.go(new) — extractsDeepCloneJSONfromstrutil.go; JSON deep-clone has nothing to do with string utilitiesmcp/helpers.go(new) — extractsmarshalToResponse,unmarshalParams, andcallParamMethodfrompagination.go; these are general-purpose MCP helpers consumed byconnection_methods.go, not pagination-specific codeserver/middleware.go— moveswithResponseLoggingfromhttp_helpers.go; it's anhttp.Handlerdecorator and belongs alongsideWithOTELTracing,authMiddleware,WithSDKLogging, etc.mcpresult/mcpresult.go(new, replacescontent_items.go+text_content.go) — consolidates two tiny single-function files into one;NormalizeContentItemsandExtractTextContentform a single logical unitFinding 5 (
AgentTagsSnapshotinmcp/connection_logging.go) is left as-is pending circular import analysis.