Skip to content

Fix MCP gateway step succeeding when server checks fail#9555

Merged
pelikhan merged 2 commits into
mainfrom
copilot/fix-mcp-gateway-check
Jan 10, 2026
Merged

Fix MCP gateway step succeeding when server checks fail#9555
pelikhan merged 2 commits into
mainfrom
copilot/fix-mcp-gateway-check

Conversation

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

The "Start MCP Gateway" step was succeeding even when all MCP servers failed to connect because the exit code of check_mcp_servers.sh was being masked by piping through tee.

Changes

  • Enable pipefail before running check_mcp_servers.sh so the pipeline returns the check script's exit code instead of tee's
  • Disable pipefail after the check to avoid affecting other parts of the script
# Before: exit code came from tee (always 0)
if ! bash check_mcp_servers.sh ... 2>&1 | tee log.txt; then

# After: exit code comes from check_mcp_servers.sh
set -o pipefail
if ! bash check_mcp_servers.sh ... 2>&1 | tee log.txt; then
  # Error handling now properly triggered
fi
set +o pipefail

The step will now correctly fail when MCP servers cannot be reached, terminating the gateway process and failing the workflow as intended.

Original prompt

The check of mcp gateway server is fialing to connect to servers but the step is not failed. This indicates that the failure of the shell script is eaten away by the piping into a file. Fix this. The "Start MCP Gateway" should fail if check_mcp_gateway fails.

==========================================
MCP Server Check Summary
==========================================
Servers checked: 4
Servers succeeded: 0
Servers failed: 4
Servers skipped: 0

ERROR: One or more MCP servers failed to respond
Failed servers: 4

MCP gateway is running:
  - From host: http://localhost:8080
  - From containers: http://host.docker.internal:8080
Gateway PID: 3697

See https://github.com/githubnext/gh-aw/actions/runs/20885790532/job/60008765167


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

The issue was that when check_mcp_servers.sh was piped through tee,
the exit code was ignored because the shell returned tee's exit code
(which always succeeds) instead of check_mcp_servers.sh's exit code.

This fix enables pipefail before the check and disables it after, so
the pipeline returns the exit code of check_mcp_servers.sh. Now when
MCP servers fail to connect, the "Start MCP Gateway" step will properly
fail as expected.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MCP gateway check to fail on connection errors Fix MCP gateway step succeeding when server checks fail Jan 10, 2026
Copilot AI requested a review from pelikhan January 10, 2026 23:21
@pelikhan pelikhan added the smoke label Jan 10, 2026
@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident...

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

💀 Blimey! Changeset Generator failed and walked the plank! No treasure today, matey! ☠️

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@pelikhan pelikhan marked this pull request as ready for review January 10, 2026 23:29
@pelikhan pelikhan merged commit 9fe5825 into main Jan 10, 2026
32 of 36 checks passed
@pelikhan pelikhan deleted the copilot/fix-mcp-gateway-check branch January 10, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants