Skip to content

Comments

fix: implement proper MCP protocol (ping + initialize + session ID + tools/list) in check_mcp_servers.sh#17419

Merged
pelikhan merged 7 commits intomainfrom
copilot/debug-serena-issue
Feb 21, 2026
Merged

fix: implement proper MCP protocol (ping + initialize + session ID + tools/list) in check_mcp_servers.sh#17419
pelikhan merged 7 commits intomainfrom
copilot/debug-serena-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 21, 2026

The MCP gateway handles ping requests directly at the proxy layer without forwarding to backend containers, causing check_mcp_servers.sh to pass in ~6s even when slow-starting backends (Serena takes ~22s) aren't ready. Additionally, sending tools/list directly without the required MCP initialize handshake violates the MCP protocol — the gateway requires initialize to establish a session before accepting subsequent requests, and the Mcp-Session-Id returned must be passed to tools/list.

Changes

  • check_mcp_servers.sh: Implement the full MCP protocol sequence for each server check:

    1. Send ping to verify basic connectivity
    2. Send initialize (with protocolVersion, clientInfo, and capabilities) to establish a session
    3. Extract Mcp-Session-Id from the initialize response headers
    4. Send tools/list with the Mcp-Session-Id header when present

    Since tools/list must be forwarded to the backend container (unlike ping, which the gateway handles itself), this also ensures the backend is truly ready before the check passes. Curl arguments are built in an array to avoid duplication across requests.

  • check_mcp_servers_test.sh: Add assertions that verify ping, initialize, and Mcp-Session-Id handling exist in the script.

The gateway startup step will now correctly wait until all backends (including Serena) are ready and have completed the full MCP handshake before the agent starts.

Warning

Custom agent used: agentic-workflows
GitHub Agentic Workflows (gh-aw) - Create, debug, and upgrade AI-powered workflows with intelligent prompt routing

Original prompt

Reference: https://github.com/github/gh-aw/actions/runs/22247376918/job/64364158609#step:45:1

Debug why Serena is not working

Custom agent used: agentic-workflows
GitHub Agentic Workflows (gh-aw) - Create, debug, and upgrade AI-powered workflows with intelligent prompt routing


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Changeset

  • Type: patch
  • Description: Ensure check_mcp_servers.sh uses tools/list instead of ping so the MCP readiness probe truly waits for backend containers to respond.

Generated by Changeset Generator



✨ PR Review Safe Output Test - Run 22255965551

💥 [THE END] — Illustrated by Smoke Claude


(www.google.com/redacted)

Generated by Changeset Generator



✨ PR Review Safe Output Test - Run 22256569852

💥 [THE END] — Illustrated by Smoke Claude

… backends are ready

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Debug why Serena is not working fix: use tools/list instead of ping to verify MCP backend readiness Feb 21, 2026
@pelikhan pelikhan marked this pull request as ready for review February 21, 2026 11:24
Copilot AI review requested due to automatic review settings February 21, 2026 11:24
@pelikhan pelikhan added the smoke label Feb 21, 2026
@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical issue where the MCP gateway readiness check was incorrectly passing before backend containers were fully ready. The ping method was being handled by the gateway proxy layer without forwarding to backends, causing the Copilot CLI to start too early and fail to access tools from slow-starting servers like Serena (which takes ~22s to start).

Changes:

  • Replace ping with tools/list as the readiness probe method in check_mcp_servers.sh
  • Update test assertions in check_mcp_servers_test.sh to verify the new tools/list probe method
  • Add explanatory comments documenting why tools/list is used instead of ping

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
actions/setup/sh/check_mcp_servers.sh Changes the JSON-RPC method from ping to tools/list in the payload, updates comments to explain the rationale, ensuring the gateway waits for backend containers to be truly ready
actions/setup/sh/check_mcp_servers_test.sh Updates test validation to check for tools/list method instead of ping in the script logic

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

@github-actions
Copy link
Contributor

🤖 Smoke test results for @pelikhan:

Test Status
GitHub MCP
safeinputs-gh CLI
Serena MCP
Playwright
File Writing
Bash Tool
Discussion
Build gh-aw
Workflow Dispatch
PR Review

Overall: ⚠️ PARTIAL PASS — Serena MCP tools not accessible.

📰 BREAKING: Report filed by Smoke Copilot

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR switches MCP health check from ping to tools/list — a smart fix ensuring the backend container is truly ready (not just the gateway proxy). Changes are clean, comments are clear, and the test is properly updated.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

PRs: #17435 Increase scout timeout for deep research
PRs: #17429 Enhance scout command with additional inputs
GitHub MCP (2 merged PRs) ✅
Serena MCP (activate + find_symbol) ✅
Playwright (GitHub title) ✅
File write ✅
Bash cat ✅
Build gh-aw ✅
Overall: PASS

🔮 The oracle has spoken through Smoke Codex

@pelikhan
Copy link
Contributor

Debug this run that was missing Serena

https://github.com/github/gh-aw/actions/runs/22255965556/job/64386874977

MCP has a protocol and you need to call initialize first before tools/list . Also maintain the session id.

@github-actions
Copy link
Contributor

Smoke Test Results — Run §22255965551

Test Status
1 GitHub MCP
2 SafeInputs GH CLI
3 Serena MCP
4 Make Build
5 Playwright
6 Tavily Search
7 File Writing
8 Bash Verification
9 Discussion Interaction
10 Agentic Workflows MCP
11 Update PR Body
12 PR Review Comments
13 Submit PR Review
14 Resolve Review Thread
15 Add Reviewer
16 Push to PR Branch
17 Close Test PR ⚠️ Skipped

Overall: PARTIAL (16 pass, 1 skipped, 0 fail)

💥 [THE END] — Illustrated by Smoke Claude

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

@pelikhan
Copy link
Contributor

@copilot Debug this run that was missing Serena

https://github.com/github/gh-aw/actions/runs/22255965556/job/64386874977

MCP has a protocol and you need to call initialize first before tools/list . Also maintain the session id.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 21, 2026

@copilot Debug this run that was missing Serena

https://github.com/github/gh-aw/actions/runs/22255965556/job/64386874977...

Fixed in e73f270. The script now follows the full MCP protocol:

  1. Sends initialize first with proper params (protocol version, client info)
  2. Extracts Mcp-Session-Id from the response headers (when present)
  3. Sends tools/list with the Mcp-Session-Id header included

The curl args are built in an array to avoid duplication, so the session ID is conditionally appended cleanly.

Copilot AI changed the title fix: use tools/list instead of ping to verify MCP backend readiness fix: implement proper MCP protocol (initialize + session ID) in check_mcp_servers.sh Feb 21, 2026
@pelikhan
Copy link
Contributor

@copilot make sure to ping first

…ze → tools/list)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 21, 2026

@copilot make sure to ping first

Done in 88da7ae. The script now follows the full sequence: ping → initialize → tools/list. Ping is step 1 (basic connectivity), initialize is step 2 (establishes session + captures Mcp-Session-Id), and tools/list is step 3 (confirms the backend container is truly ready).

Copilot AI changed the title fix: implement proper MCP protocol (initialize + session ID) in check_mcp_servers.sh fix: implement proper MCP protocol (ping + initialize + session ID + tools/list) in check_mcp_servers.sh Feb 21, 2026
@pelikhan pelikhan added the smoke label Feb 21, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

PR titles:

  • fix(cli-version-checker): add go ecosystem to network allowlist for toolchain downloads
  • Relax brittle description assertion in live MCP registry integration test
    Tests: GitHub MCP ✅, Serena ✅, Playwright ✅, File write ✅, Bash cat ✅, Build ✅
    Overall status: PASS

🔮 The oracle has spoken through Smoke Codex

@github-actions github-actions bot removed the smoke label Feb 21, 2026
@github-actions
Copy link
Contributor

🤖 Smoke test §22256569880 results for @Copilot:

Test
GitHub MCP
Safe Inputs GH CLI
Serena MCP
Playwright
File Writing
Bash Tool
Discussion Interaction
Build gh-aw
Discussion Creation
Workflow Dispatch
PR Review

Overall: ❌ FAIL (Serena MCP not available)

📰 BREAKING: Report filed by Smoke Copilot

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Smoke test review of PR #17419. The full MCP handshake implementation (ping → initialize → tools/list with session ID) is correct and well-structured. Two minor observations: hardcoded protocol version and test ordering assertions. Overall this is a solid fix for the Serena readiness timing issue.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@pelikhan pelikhan merged commit a90de1b into main Feb 21, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/debug-serena-issue branch February 21, 2026 12:19
@github-actions
Copy link
Contributor

Smoke Test Results — Run §22256569852

Overall: PARTIAL (17 tests, 16 ✅, 1 ⚠️)

# Test
1 GitHub MCP (merged PRs)
2 safeinputs-gh CLI
3 Serena MCP (activate + find_symbol)
4 Make build
5 Playwright (GitHub title)
6 Tavily web search
7 File writing
8 Bash verification
9 Discussion comment
10 Agentic workflows status
11 Update PR body
12 PR review comments
13 Submit PR review
14 Resolve review thread
15 Add reviewer
16 Push to PR branch
17 Close PR ⚠️ skipped

💥 [THE END] — Illustrated by Smoke Claude

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

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.

2 participants