Skip to content

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

Merged
pelikhan merged 7 commits into
mainfrom
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 into
mainfrom
copilot/debug-serena-issue

Conversation

CopilotAI commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI changed the title [WIP] Debug why Serena is not workingfix: use tools/list instead of ping to verify MCP backend readinessFeb 21, 2026
@pelikhan
pelikhan marked this pull request as ready for review February 21, 2026 11:24
CopilotAI review requested due to automatic review settings February 21, 2026 11:24
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actionsBot commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actionsBot commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

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

CopilotAI 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

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.

FileDescription
actions/setup/sh/check_mcp_servers.shChanges 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.shUpdates 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.

Comment threadactions/setup/sh/check_mcp_servers.sh
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Smoke test results for @pelikhan:

TestStatus
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

@github-actionsgithub-actionsBot 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.

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

Comment threadactions/setup/sh/check_mcp_servers.sh Outdated
Comment threadactions/setup/sh/check_mcp_servers_test.sh
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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
Copy Markdown
Contributor

Smoke Test Results — Run §22255965551

TestStatus
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

@github-actionsgithub-actionsBot 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.

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

@pelikhan

Copy link
Copy Markdown
Collaborator

@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>

CopilotAI commented Feb 21, 2026

Copy link
Copy Markdown
ContributorAuthor

@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.

CopilotAI changed the title fix: use tools/list instead of ping to verify MCP backend readinessfix: implement proper MCP protocol (initialize + session ID) in check_mcp_servers.shFeb 21, 2026
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot make sure to ping first

…ze → tools/list)
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

CopilotAI commented Feb 21, 2026

Copy link
Copy Markdown
ContributorAuthor

@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).

CopilotAI changed the title fix: implement proper MCP protocol (initialize + session ID) in check_mcp_servers.shfix: implement proper MCP protocol (ping + initialize + session ID + tools/list) in check_mcp_servers.shFeb 21, 2026
@github-actions

github-actionsBot commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actionsBot commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
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

Copy link
Copy Markdown
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

@github-actionsgithub-actionsBot 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.

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

Comment threadactions/setup/sh/check_mcp_servers.sh
Comment threadactions/setup/sh/check_mcp_servers_test.sh
@github-actions

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
Contributor

Smoke Test Results — Run §22256569852

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

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

💥 [THE END] — Illustrated by Smoke Claude

@github-actionsgithub-actionsBot 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.

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

Sign up for freeto 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.

4 participants

@pelikhan@codex