-
Notifications
You must be signed in to change notification settings - Fork 308
Closed
Closed
Copy link
Description
Overview
The latest commit (f3c7b792f95f8b3e6178f8612109832ca13dc627) contains repeated JSON MCP configuration scaffolding across engine implementations in pkg/workflow. The duplicated block is large enough (>10 lines) and appears in multiple engine-specific files with only small callback/path differences.
Critical Information
- Severity: Medium
- Pattern type: Structural duplication (copy-paste with minor variations)
- Occurrences: 3 primary occurrences
- Impacted area: MCP configuration rendering for CLI engines
Duplication Details
Pattern: Engine RenderMCPConfig setup repetition
pkg/workflow/claude_mcp.go:12pkg/workflow/gemini_mcp.go:12pkg/workflow/copilot_mcp.go:12
The methods repeat the same sequence:
- Log render start
- Construct JSON renderer factory
- Build gateway config with
buildMCPGatewayConfig(workflowData) - Build standard JSON renderers
- Call
RenderJSONMCPConfig(...)
Representative duplicated block
createRenderer := buildMCPRendererFactory(workflowData, "json", false, false)
return RenderJSONMCPConfig(yaml, tools, mcpTools, workflowData, JSONMCPConfigOptions{
ConfigPath: "/tmp/gh-aw/mcp-config/mcp-servers.json",
GatewayConfig: buildMCPGatewayConfig(workflowData),
Renderers: buildStandardJSONMCPRenderers(workflowData, createRenderer, false, func(yaml *strings.Builder, toolName string, toolConfig map[string]any, isLast bool) error {
// engine-specific callback only
return ...
}),
})Impact Analysis
- Maintainability: Changes to shared JSON MCP behavior must be repeated in multiple files, increasing drift risk.
- Bug risk: Engine-specific files can diverge subtly when only one file is updated during future feature work.
- Code bloat: Repeated setup logic reduces signal-to-noise in engine modules.
Refactoring Recommendations
- Extract a shared helper for JSON MCP rendering options
- Suggested location:
pkg/workflow/mcp_renderer_helpers.goorpkg/workflow/mcp_engine_shared.go - Helper input: config path, copilot flags, callback, optional tool filter
- Helper output: unified
RenderJSONMCPConfig(...)invocation
- Keep only engine-specific concerns in engine files
- Claude/Gemini: callback function and logger message
- Copilot: pre-step (
mkdir) andFilterTool
Implementation Checklist
- Introduce shared helper for JSON MCP config scaffolding
- Update
claude_mcp.go,gemini_mcp.go, andcopilot_mcp.goto use helper - Validate generated MCP config output parity for all engines
- Add/adjust focused unit tests around helper behavior
Analysis Metadata
- Analyzed scope:
pkg/**/*.go(non-test files in changed commit) - Deep semantic review focus: MCP gateway/config rendering paths
- Detection method: Serena symbol/body comparison + targeted pattern search
- Workflow run: §23328418561
- Analysis date: 2026-03-20 UTC
References:
Warning
⚠️ Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
ab.chatgpt.com
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
Generated by Duplicate Code Detector · ◷
Reactions are currently unavailable
Metadata
Metadata
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.