MCPcopy Index your code
hub / github.com/github/gh-aw / renderMCPToolsDiffPrettySection

Function renderMCPToolsDiffPrettySection

pkg/cli/audit_diff_render.go:385–448  ·  view source on GitHub ↗

renderMCPToolsDiffPrettySection renders the MCP tools diff as a pretty console sub-section

(diff *MCPToolsDiff)

Source from the content-addressed store, hash-verified

383
384// renderMCPToolsDiffPrettySection renders the MCP tools diff as a pretty console sub-section
385func renderMCPToolsDiffPrettySection(diff *MCPToolsDiff) {
386 if diff == nil || isEmptyMCPToolsDiff(diff) {
387 return
388 }
389
390 fmt.Fprintln(os.Stderr, console.FormatSectionHeader("MCP Tool Changes"))
391 fmt.Fprintln(os.Stderr)
392
393 if len(diff.NewTools) > 0 {
394 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("New Tools (%d)", len(diff.NewTools))))
395 config := console.TableConfig{
396 Headers: []string{"Server", "Tool", "Calls", "Anomaly"},
397 Rows: make([][]string, 0, len(diff.NewTools)),
398 }
399 for _, entry := range diff.NewTools {
400 anomalyNote := formatAnomalyNote(entry.IsAnomaly, entry.AnomalyNote)
401 config.Rows = append(config.Rows, []string{
402 entry.ServerName,
403 entry.ToolName,
404 strconv.Itoa(entry.Run2CallCount),
405 anomalyNote,
406 })
407 }
408 fmt.Fprint(os.Stderr, console.RenderTable(config))
409 }
410
411 if len(diff.RemovedTools) > 0 {
412 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Removed Tools (%d)", len(diff.RemovedTools))))
413 config := console.TableConfig{
414 Headers: []string{"Server", "Tool", "Previous Calls"},
415 Rows: make([][]string, 0, len(diff.RemovedTools)),
416 }
417 for _, entry := range diff.RemovedTools {
418 config.Rows = append(config.Rows, []string{
419 entry.ServerName,
420 entry.ToolName,
421 strconv.Itoa(entry.Run1CallCount),
422 })
423 }
424 fmt.Fprint(os.Stderr, console.RenderTable(config))
425 }
426
427 if len(diff.ChangedTools) > 0 {
428 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Changed Tools (%d)", len(diff.ChangedTools))))
429 config := console.TableConfig{
430 Headers: []string{"Server", "Tool", "Calls (before)", "Calls (after)", "Change", "Errors (before)", "Errors (after)", "Anomaly"},
431 Rows: make([][]string, 0, len(diff.ChangedTools)),
432 }
433 for _, entry := range diff.ChangedTools {
434 anomalyNote := formatAnomalyNote(entry.IsAnomaly, entry.AnomalyNote)
435 config.Rows = append(config.Rows, []string{
436 entry.ServerName,
437 entry.ToolName,
438 strconv.Itoa(entry.Run1CallCount),
439 strconv.Itoa(entry.Run2CallCount),
440 entry.CallCountChange,
441 strconv.Itoa(entry.Run1ErrorCount),
442 strconv.Itoa(entry.Run2ErrorCount),

Callers 1

Calls 5

FormatSectionHeaderFunction · 0.92
FormatInfoMessageFunction · 0.92
RenderTableFunction · 0.92
isEmptyMCPToolsDiffFunction · 0.85
formatAnomalyNoteFunction · 0.85

Tested by

no test coverage detected