Skip to content

[Code Quality] Add console error formatting to MCP validation code #11511

@github-actions

Description

@github-actions

Description

Currently, 0 out of 126 MCP error sites use console.FormatErrorMessage(), making MCP configuration errors appear as plain text without color/emphasis in CLI output. This significantly degrades the debugging experience when users encounter MCP configuration issues.

Background

Identified during MCP Server Integration Quality analysis on 2026-01-23 (discussion #11508). Analysis revealed that while the codebase has excellent console formatting infrastructure in pkg/console/, MCP-related error messages don't use it.

Current state: All 126 fmt.Errorf calls in MCP files output plain text errors
Impact: Errors invisible in CLI output, making MCP debugging significantly harder
Comparison: 1,410 correctly formatted errors in non-MCP code

Files Affected

Priority files (by error count):

  • pkg/workflow/mcp_config_validation.go - MCP configuration validation
  • pkg/workflow/mcp_gateway_schema_validation.go - Gateway schema validation
  • pkg/cli/mcp_validation.go - CLI validation
  • pkg/cli/mcp_server.go - MCP server commands
  • pkg/cli/mcp_inspect.go - MCP inspection
  • pkg/workflow/mcp_renderer.go - YAML rendering

Suggested Changes

Pattern to Follow

Before:

return fmt.Errorf("failed to configure MCP server: %w", err)

After:

fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
return fmt.Errorf("failed to configure MCP server: %w", err)

For user-facing errors, add actionable guidance:

msg := fmt.Sprintf("MCP mode must be 'remote' or 'local', got '%s'\n\nSuggestion: Update your workflow to specify:\n  tools:\n    github:\n      mode: remote", mode)
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(msg))
return fmt.Errorf("invalid MCP mode: %s", mode)

Guidelines

  1. Follow error message style guide in specs/error-messages.md
  2. Ensure all error paths in MCP validation use console formatting
  3. Add actionable guidance where appropriate
  4. Run make agent-finish to validate changes

Success Criteria

  • All fmt.Errorf calls in MCP files use console formatting
  • Error messages follow error message style guide
  • Errors include actionable guidance where appropriate
  • Test cases verify error formatting
  • Console formatting applied to at least 126 error sites
  • make agent-finish passes

Priority

High - Critical for CLI UX - makes MCP errors visible and debuggable

Estimated effort: Medium (2-3 hours across multiple files)

Source

Extracted from MCP Server Integration Quality analysis discussion #11508

Analysis quote:

"3. Error Message Invisibility (Critical)

  • 0/126 MCP error sites use console.FormatErrorMessage - Errors invisible in CLI output
  • 126 fmt.Errorf calls without console formatting
  • Compare to 1,410 correctly formatted errors in non-MCP code

Impact: MCP configuration errors appear as plain text without color/emphasis, making debugging significantly harder."

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 6, 2026, 2:07 PM UTC

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions