Skip to content

[Code Quality] Consolidate 4 duplicated MCP-server-stats structs in pkg/cli into a shared base #50676

Description

@github-actions

Description

The "per-MCP-server stats/health" concept has been independently modeled four separate times in pkg/cli, creating real drift risk as new fields get added to only some of them.

Suggested Changes

  • Introduce a shared MCPServerStatsBase{ServerName string; RequestCount, ToolCallCount, ErrorCount int}, mirroring the existing AnalysisBase/AggregatedSummaryBase dedup pattern already used in this package.
  • Have each report-specific struct embed the base, keeping only its own extra fields.

Files Affected

  • pkg/cli/audit_report.go:213MCPServerStats
  • pkg/cli/audit_expanded.go:90MCPServerHealthDetail
  • pkg/cli/audit_cross_run.go:81MCPServerCrossRunHealth
  • pkg/cli/gateway_logs_types.go:85GatewayServerMetrics

Success Criteria

  • Single canonical base struct embedded by all four report structs
  • No behavior change in generated reports
  • All existing tests pass

Source

Extracted from Typist: Go Type Consistency Analysis discussion #50544

Priority

Medium - improves maintainability; estimated 3-4 hours

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · auto · 44.7 AIC · ⌖ 3.06 AIC · ⊞ 10.3K ·

  • expires on Aug 6, 2026, 11:12 AM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions