Skip to content

Add console error formatting to MCP CLI commands#11606

Merged
pelikhan merged 3 commits into
mainfrom
copilot/add-console-error-formatting
Jan 24, 2026
Merged

Add console error formatting to MCP CLI commands#11606
pelikhan merged 3 commits into
mainfrom
copilot/add-console-error-formatting

Conversation

Copilot AI commented Jan 24, 2026

Copy link
Copy Markdown
Contributor

MCP configuration errors appeared as plain text without color/emphasis in CLI output, making debugging difficult. 0 of 126 MCP error sites used console.FormatErrorMessage().

Changes

Added console formatting to 27 error sites in MCP CLI commands:

  • pkg/cli/mcp_validation.go (9 sites): GitHub token validation, environment variables, status commands
  • pkg/cli/mcp_inspect.go (18 sites): File I/O, server startup, configuration merging

Validation library (pkg/workflow/mcp_config_validation.go) unchanged - errors already formatted at CLI boundary in compile_workflow_processor.go:147.

Example

Before:

failed to parse workflow file: tool 'my-tool' mcp configuration missing required property 'url'

After:

✗ failed to parse workflow file: tool 'my-tool' mcp configuration missing required property 'url'. Example:
mcp-servers:
  my-tool:
    url: "value"

Pattern

Console formatting applied only at CLI boundaries, not in validation libraries:

if err != nil {
    errMsg := fmt.Sprintf("failed to read workflow file: %v", err)
    fmt.Fprintln(os.Stderr, console.FormatErrorMessage(errMsg))
    return fmt.Errorf("failed to read workflow file: %w", err)
}
Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Add console error formatting to MCP validation code</issue_title>
<issue_description>## 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 githubnext/gh-aw#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

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 24, 2026 07:08
- Added console.FormatErrorMessage() to pkg/workflow/mcp_config_validation.go (10 error sites)
- Added console.FormatErrorMessage() to pkg/cli/mcp_validation.go (9 error sites)
- Added console.FormatErrorMessage() to pkg/cli/mcp_inspect.go (18 error sites)
- All error messages now use console formatting for better CLI visibility

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… formatting)

- Reverted console.FormatErrorMessage() from pkg/workflow/mcp_config_validation.go (library code)
- Kept console.FormatErrorMessage() in pkg/cli/mcp_validation.go (9 error sites - CLI helper functions)
- Kept console.FormatErrorMessage() in pkg/cli/mcp_inspect.go (18 error sites - CLI helper functions)

Validation library errors are already formatted when they reach CLI in compile_workflow_processor.go

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add console error formatting to MCP validation code Add console error formatting to MCP CLI commands Jan 24, 2026
Copilot AI requested a review from pelikhan January 24, 2026 07:28
@pelikhan pelikhan marked this pull request as ready for review January 24, 2026 10:34
@pelikhan pelikhan merged commit 3d82a7a into main Jan 24, 2026
213 checks passed
@pelikhan pelikhan deleted the copilot/add-console-error-formatting branch January 24, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants