Skip to content

[plan] Add console error formatting to MCP validation code #12765

@github-actions

Description

@github-actions

Objective

Transform all 126 MCP error sites to use console.FormatErrorMessage for CLI visibility. Currently, 0/126 error messages use console formatting, making MCP errors invisible in terminal output.

Context

This addresses a critical finding from the MCP Server Integration Quality analysis: MCP configuration errors appear as plain text without color/emphasis, making debugging significantly harder.

Approach

  1. Review all MCP-related Go files for error handling
  2. Replace plain fmt.Errorf patterns with console-formatted errors
  3. Enhance user-facing errors with actionable guidance
  4. Follow the error message style guide in specs/error-messages.md
  5. Ensure all error paths use console formatting

Files to Modify

Priority files (by expected error count):

  • pkg/workflow/mcp_config_validation.go
  • pkg/workflow/mcp_gateway_schema_validation.go
  • pkg/cli/mcp_validation.go
  • pkg/cli/mcp_server.go
  • pkg/cli/mcp_inspect.go
  • pkg/workflow/mcp_renderer.go

Additional files:

  • pkg/workflow/mcp_gateway_config.go
  • pkg/workflow/mcp_environment.go
  • pkg/workflow/mcp_setup_generator.go
  • pkg/workflow/mcp_github_config.go
  • pkg/workflow/mcp-config-utils.go
  • pkg/workflow/mcp-config-playwright.go
  • pkg/parser/mcp.go

Pattern to Follow

Replace:

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

With:

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

For user-facing errors with 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)

Acceptance Criteria

  • All fmt.Errorf calls in MCP files use console formatting
  • Error messages follow the error message style guide (specs/error-messages.md)
  • Errors include actionable guidance where appropriate
  • Test cases verify error formatting
  • make agent-finish passes without errors

Related

AI generated by Plan Command for discussion #11508

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