Skip to content

[duplicate-code] Duplicate Code Analysis Report #5070

@github-actions

Description

@github-actions

Summary

Analysis of the latest commit (8d77398) found 2 significant duplication patterns in the Go source files. Both are in the internal/server/ package and relate to MCP session handling.

Detected Patterns

  1. Session Timeout Env-Var Literal — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Session Timeout Env-Var Literal #5071
  2. StreamableHTTP Handler + Middleware Chain — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: StreamableHTTP Handler + Middleware Chain #5072

Overall Impact

  • Total Duplicated Lines: ~15–20
  • Affected Files: internal/server/transport.go, internal/server/routed.go
  • Maintainability Risk: Medium — the same env-var key and default appear in two places; a future change to the default or key name must be applied in two spots.
  • Refactoring Priority: Medium

Next Steps

  1. Review the two sub-issues for details.
  2. Have transport.go call getRoutedSessionTimeout() (already defined in routed.go) instead of repeating the envutil.GetEnvDuration call.
  3. Consider extracting a shared newStreamableHTTPHandler(logger, sessionTimeout, serverFactory) helper that encapsulates the sdk.NewStreamableHTTPHandler + WrapWithSessionAutoInit + wrapWithMiddleware chain.

Analysis Metadata

  • Analyzed Files: 107 non-test Go files changed in commit 8d77398
  • Detection Method: Pattern search + code review
  • Commit: 8d77398d5c51896b9ffa29be3d7bbc34f597a4f2
  • Analysis Date: 2026-05-04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions