Skip to content

Add MCP server functionality check after gateway health validation#9516

Merged
pelikhan merged 4 commits into
mainfrom
copilot/add-mcp-server-check-script
Jan 10, 2026
Merged

Add MCP server functionality check after gateway health validation#9516
pelikhan merged 4 commits into
mainfrom
copilot/add-mcp-server-check-script

Conversation

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

Adds a validation script that verifies MCP servers are operational after the gateway starts. The script sends MCP protocol messages to each configured server and displays available tools. The script fails and terminates the gateway if any HTTP server fails to respond.

Changes

  • New script: check_mcp_servers.sh

    • Parses gateway output config to enumerate servers
    • Sends JSON-RPC initialize and tools/list requests to each HTTP server
    • Displays tool names, descriptions, and schemas with verbose logging
    • Handles connection failures gracefully (5s timeout)
    • Skips stdio servers (no HTTP endpoint) - tracked separately
    • Exits with code 1 if ANY HTTP server fails to respond
  • Integration: start_mcp_gateway.sh

    • Invokes check script after successful health check
    • Passes gateway config path, URL, and API key
    • Terminates gateway process and exits with error if server checks fail
  • Test coverage: check_mcp_servers_test.sh

    • 16 tests covering argument validation, error cases, and server configurations
    • Tests validate both success and failure scenarios

Behavior

  • Success (exit 0): All HTTP servers respond successfully
  • Failure (exit 1): Any HTTP server fails OR no HTTP servers to check
  • Skipped: Stdio servers (without HTTP URLs) are tracked separately and don't count as failures

Example Output (Success)

==========================================
Checking server: github
==========================================
Server URL: http://localhost:8080/mcp/github
Authentication: Configured (******

Step 1: Sending MCP initialize request...
✓ Initialize request succeeded

Step 2: Sending tools/list request...
✓ tools/list request succeeded

Available tools from github:
  [1] create_issue
      Description: Create a new GitHub issue
  [2] list_repositories
      Description: List user repositories
---

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

✓ All HTTP server checks succeeded (1 succeeded, 1 skipped)

Example Output (Failure)

==========================================
MCP Server Check Summary
==========================================
Servers checked: 3
Servers succeeded: 1
Servers failed: 1
Servers skipped: 1

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

Exit code: 1 (causes gateway to be terminated)

Original prompt

Add a shell script in actions/setup that performs a basic MCP server functionality check of the mcp servers configured by the mcp gateway. This happens in the start_mcp_gateway.sh script after health is established.

algo:

for each server in the config returned by the gateway MCP config

   attempt to connect to the server use auth information
   Send MCP messages to get the list of tools
   Display tools

Use extensive logging use echo


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

- Created check_mcp_servers.sh to verify MCP server connectivity
- Implements algorithm: parse gateway config, connect to each server, send initialize and tools/list requests
- Displays available tools from each server with extensive logging
- Integrated into start_mcp_gateway.sh after health check
- Added comprehensive test suite (16 tests, all passing)
- Handles curl timeouts and connection failures gracefully

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add shell script for MCP server functionality check Add MCP server functionality check after gateway health validation Jan 10, 2026
Copilot AI requested a review from pelikhan January 10, 2026 16:29
@pelikhan pelikhan added the smoke label Jan 10, 2026
@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

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

@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

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

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot update check script to fail if you are unable to connect any of the servers

- Script now exits with code 1 if no servers successfully connect
- Updated start_mcp_gateway.sh to propagate failure and terminate gateway
- Updated all tests to reflect new failure behavior
- All 16 tests passing with new logic

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

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot update check script to fail if you are unable to connect any of the servers

Updated in commit 17a9b97. The script now exits with code 1 if no servers successfully connect, and start_mcp_gateway.sh terminates the gateway process on failure.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot fails if "any" MCP server fails to respond

- Script now fails if any HTTP server fails to respond (not just all)
- Added separate counter for skipped servers (stdio without HTTP URLs)
- Stdio servers are skipped, not counted as failures
- Success only if all HTTP servers succeed and at least one exists
- Updated summary output to show skipped vs failed servers separately
- All 16 tests still passing

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

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fails if "any" MCP server fails to respond

Updated in commit 0b92182. The script now fails if ANY HTTP server fails to respond. Stdio servers (without HTTP URLs) are tracked separately as "skipped" and don't count as failures.

@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

📰 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

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

@pelikhan pelikhan marked this pull request as ready for review January 10, 2026 17:11
@pelikhan pelikhan merged commit 3a564c4 into main Jan 10, 2026
32 of 36 checks passed
@pelikhan pelikhan deleted the copilot/add-mcp-server-check-script branch January 10, 2026 17:11
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