Skip to content

MCP gateway startup: degrade on optional server failures, fail only on required/no-success cases#46919

Merged
pelikhan merged 5 commits into
mainfrom
copilot/aw-fixstart-mcp-gateway-failures
Jul 21, 2026
Merged

MCP gateway startup: degrade on optional server failures, fail only on required/no-success cases#46919
pelikhan merged 5 commits into
mainfrom
copilot/aw-fixstart-mcp-gateway-failures

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Start MCP Gateway was deterministically failing the MCP Inspector job when a single MCP server (Datadog) returned 403 during initialize. This change makes gateway readiness tolerant of optional server failures while preserving strict failure behavior for startup-critical servers.

  • Startup failure policy in MCP readiness checks

    • Updated actions/setup/sh/check_mcp_servers.sh to treat per-server failures as:
      • fatal only when server config sets required: true
      • warning when required is omitted/false
    • Preserved existing hard-fail behavior when:
      • no HTTP MCP servers connect successfully
      • any required server fails connectivity checks
    • Adjusted summary output to distinguish clean pass vs. pass-with-warnings.
  • Targeted coverage for new behavior

    • Extended actions/setup/sh/check_mcp_servers_test.sh with scenarios for:
      • one healthy server + one optional failing server (403 on initialize) => startup check succeeds with warning
      • one healthy server + one required failing server => startup check fails
    • Added shared mock-server helper logic to keep test behavior consistent and reduce duplication.

Example of the new server-level control:

{
  "mcpServers": {
    "github": { "type": "http", "url": "http://127.0.0.1:8080/mcp/github" },
    "datadog": { "type": "http", "url": "http://127.0.0.1:8080/mcp/datadog" }
  }
}

With the above, Datadog failure degrades to warning if GitHub connects. Marking Datadog as "required": true restores fail-fast behavior for that server.


pr-sous-chef run: https://github.com/github/gh-aw/actions/runs/29783168867

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 14.3 AIC · ⌖ 4.15 AIC · ⊞ 6.9K ·
Comment /souschef to run again


Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 9.44 AIC · ⌖ 7.25 AIC · ⊞ 6.9K ·
Comment /souschef to run again


branch update requested from https://github.com/github/gh-aw/actions/runs/29788028039

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 9.37 AIC · ⌖ 7.68 AIC · ⊞ 6.9K ·
Comment /souschef to run again


Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 9.99 AIC · ⌖ 10.1 AIC · ⊞ 6.9K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 20, 2026 20:29
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MCP Inspector Agent to handle datadog 403 error MCP gateway startup: degrade on optional server failures, fail only on required/no-success cases Jul 20, 2026
Copilot AI requested a review from pelikhan July 20, 2026 21:01
@pelikhan
pelikhan marked this pull request as ready for review July 20, 2026 21:15
Copilot AI review requested due to automatic review settings July 20, 2026 21:15
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot add support in frontmatter to specify a MCP tool as required:false (default true)

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #46919 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes MCP gateway readiness tolerant of optional server failures while retaining fatal handling for required or universally failing servers.

Changes:

  • Adds optional/required failure classification and warning summaries.
  • Adds mock-server tests for optional and required failures.
Show a summary per file
File Description
actions/setup/sh/check_mcp_servers.sh Implements revised readiness policy.
actions/setup/sh/check_mcp_servers_test.sh Adds targeted connectivity tests.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread actions/setup/sh/check_mcp_servers.sh Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST_CHANGES — 2 correctness bugs + 2 test reliability issues

The optional/required split is the right approach, but the implementation has a logic ordering bug that will produce wrong error messages in production, plus test-infrastructure issues that can leave orphaned processes and leaked temp dirs.

Issues found

1. Branch order inverts error semantics (high)

SERVERS_SUCCEEDED == 0 is checked before REQUIRED_SERVERS_FAILED > 0. When all servers are required and all fail, the script exits with No

🔎 Code quality review by PR Code Quality Reviewer · 41.8 AIC · ⌖ 4.82 AIC · ⊞ 5.6K
Comment /review to run again

Comments that could not be inline-anchored

actions/setup/sh/check_mcp_servers.sh:67

Wrong branch order hides required-server failures when zero servers succeed: the SERVERS_SUCCEEDED == 0 branch fires before REQUIRED_SERVERS_FAILED &gt; 0, so if every server is required and all fail, the user sees "No HTTP servers were successfully checked / maybe all stdio-type" — not "required server(s) failed". The actual root cause is invisible in CI logs.

<details>
<summary>💡 Suggested fix</summary>

Swap the branch order so required-failure is checked first:

if [ $REQUIRE</details>

<details><summary>actions/setup/sh/check_mcp_servers.sh:60</summary>

**Misleading error message when all optional servers fail**: the `SERVERS_SUCCEEDED == 0` error text lists only two causes — &quot;No HTTP-type MCP servers configured&quot; or &quot;all servers are stdio-type&quot; — but there is now a third reachable cause: all configured HTTP servers failed connectivity but were all optional. A user hitting this branch after a total optional-server outage will see a stdio-type hint and waste time chasing a non-existent config problem.

&lt;details&gt;
&lt;summary&gt;💡 Suggested fix&lt;/summar…

</details>

<details><summary>actions/setup/sh/check_mcp_servers_test.sh:38</summary>

**`start_mock_mcp_server` echoes the shell PID, not the Node process PID**: `node - ... &lt;&lt;&#39;NODE&#39; &amp;` backgrounds a shell that in turn execs Node; `$!` is the shell wrapper&#39;s PID. Calling `kill &quot;$server_pid&quot;` later kills that wrapper but leaves the Node process orphaned — it keeps the ephemeral port open and can cause port conflicts when tests are re-run back-to-back or in parallel.

&lt;details&gt;
&lt;summary&gt;💡 Suggested fix&lt;/summary&gt;

Write the Node PID from inside the JS before the shell exits, or us…

</details>

<details><summary>actions/setup/sh/check_mcp_servers_test.sh:231</summary>

**`tmpdir` leaked when mock server fails to start**: both new tests return early (via `return`) on mock-server startup failure without calling `rm -rf &quot;$tmpdir&quot;`, leaking the temp directory on every test-environment failure.

&lt;details&gt;
&lt;summary&gt;💡 Suggested fix&lt;/summary&gt;

Add cleanup before the early return:

```sh
if ! server_pid=$(start_and_validate_mock_server &quot;$port_file&quot; &quot;$tmpdir/mock.log&quot;); then
  rm -rf &quot;$tmpdir&quot;
  print_result &quot;Mock MCP server failed to start&quot; &quot;FAIL&quot;
  return
fi

Or…

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: MCP gateway startup degradation

The overall design is sound — tolerating optional server failures while preserving hard-fail semantics for required servers is the right approach, and the test coverage is thorough.

One blocking correctness issue found (see inline comment):

Branch-ordering bug at the summary block — when a required: true server fails and is the only server, SERVERS_SUCCEEDED is 0 and the new SERVERS_SUCCEEDED -eq 0 guard fires first, printing a misleading "no HTTP servers configured" error instead of the intended "required server failed" message. The fix is to add && [ $REQUIRED_SERVERS_FAILED -eq 0 ] to the first condition (or reorder so required-failure is checked first).

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 30.2 AIC · ⌖ 4.49 AIC · ⊞ 5K

Comment thread actions/setup/sh/check_mcp_servers.sh Outdated
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 45 AIC · ⌖ 4.55 AIC · ⊞ 6.7K
Comment /matt to run again

Comment thread actions/setup/sh/check_mcp_servers.sh Outdated
Comment thread actions/setup/sh/check_mcp_servers_test.sh
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add support in frontmatter to specify a MCP tool as required:false (default true)

Done in commit Add required:false frontmatter support for MCP servers (default true).

The required property is now supported end-to-end:

  • required is accepted in mcp-servers frontmatter (previously rejected as an unknown property)
  • The compiler emits "required": false in the gateway JSON only when explicitly set — absent field means required (the default)
  • The JSON schema for both stdioServerConfig and httpServerConfig defines required as an optional boolean with default: true
  • check_mcp_servers.sh now defaults servers to required; set required: false to degrade failures to warnings

Example:

mcp-servers:
  github:
    type: http
    url: "http://127.0.0.1:8080/mcp/github"
  datadog:
    type: http
    url: "http://127.0.0.1:8080/mcp/datadog"
    required: false   # startup continues with a warning if this server fails

Copilot AI requested a review from gh-aw-bot July 20, 2026 22:41
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Unresolved review threads to close out:

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 9.44 AIC · ⌖ 7.25 AIC · ⊞ 6.9K ·
Comment /souschef to run again

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Unresolved review threads to close out:...

All four threads have been addressed in code and replied to:

  • r3617649641 (Copilot — required not wired end-to-end) → fixed in b49bbc4, replied ✅
  • r3617677974 (wrong error branch for required-only server) → fixed in 34abaa9, replied ✅
  • r3617683297 (misleading all-optional-fail error) → fixed in 34abaa9, replied ✅
  • r3617683308 (missing all-optional-fail test) → Test 13 added in 34abaa9, replied ✅

Threads 1–3 are is_outdated on GitHub (the diff moved past the comment locations). All 22 shell tests pass locally. The threads show as unresolved because marking them resolved requires the GraphQL resolveReviewThread mutation, which isn't available from the agent environment — a reviewer needs to resolve them on the GitHub UI.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Unresolved review threads to close out:

Run: https://github.com/github/gh-aw/actions/runs/29788028039

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 9.37 AIC · ⌖ 7.68 AIC · ⊞ 6.9K ·
Comment /souschef to run again

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Unresolved review threads to close out:...

All four threads are already fully addressed in code and have replies:

  • r3617649641 (required not wired end-to-end) → fixed in b49bbc4
  • r3617677974 (wrong error branch for single required server) → fixed in 34abaa9
  • r3617683297 (misleading all-optional-fail error) → fixed in 34abaa9
  • r3617683308 (missing Test 13) → added in 34abaa9

The PR Sous Chef run (29788028039) completed with success and no errors. Local validation is clean (22/22 shell tests pass). The threads remain technically "unresolved" on GitHub because the resolveReviewThread GraphQL mutation is not available to this agent — a reviewer needs to resolve them on the GitHub UI.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address any remaining review feedback, and rerun checks once the branch is up to date.

Run: https://github.com/github/gh-aw/actions/runs/29789600762

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 13.2 AIC · ⌖ 8.86 AIC · ⊞ 6.9K ·
Comment /souschef to run again

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address any remaining review feedback, and rerun checks once the branch is up to date.

Run: https://github.com/github/gh-aw/actions/runs/29789600762...

All 4 review threads are now resolved. PR Sous Chef run 29789600762 completed with success and no errors. Local validation is clean (22/22 shell tests pass, working tree clean).

  • Reviews — All 4 threads resolved
  • Checks (local) — 22/22 shell tests pass
  • Checks (CI) — PR Sous Chef 29789600762 succeeded
  • Mergeable — PR is open, not draft, no conflicts

Ready for merge.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Triage — Run §29791496271

Field Value
Category bug
Risk 🟡 medium
Score 71/100 (impact 35 + urgency 22 + quality 14)
Action fast_track

Rationale: MCP Inspector deterministically failing when Datadog returns 403. Graceful degradation fix with tests. Ready for review.

Generated by 🔧 PR Triage Agent · 40.1 AIC · ⌖ 6.65 AIC · ⊞ 5.6K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address any unresolved review feedback, confirm the branch is current, and summarize the next concrete maintainer action once checks are ready.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 9.99 AIC · ⌖ 10.1 AIC · ⊞ 6.9K ·
Comment /souschef to run again

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address any unresolved review feedback, confirm the branch is current, and summarize the next concrete maintainer action once checks are ready.

...

  • Reviews — All 4 review threads are resolved: the copilot-pull-request-reviewer thread (r3617649641) was fixed in b49bbc4; the three github-actions[bot] threads (r3617677974, r3617683297, r3617683308) were fixed and replied to in 34abaa9. No unresolved threads remain.
  • Checks (local)make fmt, make lint, make test-unit all pass. Shell test suite: 22/22 passed (including Test 13 for the all-optional-fail scenario).
  • Checks (CI) — A CI run (29792052510) is currently in progress on the branch HEAD (34abaa9). The 4 prior completed CI runs on this PR all concluded success. The agent's pushes do not re-trigger CI — stale after agent push; needs human re-trigger if this run doesn't complete on its own.
  • Mergeable — PR is open, not draft, no conflicts. Currently blocked pending the in-progress CI check.

Actions taken: None in this run — all prior work was already complete.

Next concrete maintainer action: Wait for the current CI run (29792052510) to finish. If it succeeds, the PR is ready to merge. If it fails, review the logs and re-trigger CI as needed.

@pelikhan
pelikhan merged commit 192fb05 into main Jul 21, 2026
28 checks passed
@pelikhan
pelikhan deleted the copilot/aw-fixstart-mcp-gateway-failures branch July 21, 2026 03:36
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw-failures] [aw-fix] P1: MCP Inspector Agent — Start MCP Gateway hard-fails (exit 1) on datadog MCP 403 Forbidden

4 participants