Skip to content

πŸ› Bug: MCP server rejects ping message before initializeΒ #469

@antoniordz96

Description

@antoniordz96

Summary

When running the AWS Agent Core MCP server backed by quarkus-mcp-server, the MCP client receives an error when it sends a ping message before completing the initialize handshake.


πŸ’₯ Observed Behavior

Server logs show:

{
  "jsonrpc" : "2.0",
  "method" : "ping",
  "params" : null,
  "id" : 4
}
2025-10-25 02:23:21,753 INFO  [io.qua.mcp.ser.traffic] (vert.x-eventloop-thread-0) MCP message sent [...]:
{
  "jsonrpc" : "2.0",
  "id" : 4,
  "error" : {
    "code" : -32601,
    "message" : "The first message from the client must be \"initialize\": ping"
  }
}

As a result, the server rejects legitimate ping requests that occur before initialize.


πŸ“œ Expected Behavior (per MCP spec)

According to the [Model Context Protocol Specification (2025-06-18)](https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle):

The client SHOULD NOT send requests other than pings before the server has responded to the initialize request.
The server SHOULD NOT send requests other than pings and logging before receiving the initialized notification.

Therefore, ping should be accepted at any point in the lifecycle, including before initialization completes.


βš™οΈ Environment

  • MCP server: Quarkus MCP Server (io.quarkiverse.mcp.server)
  • Deployment: AWS Agent Core
  • Protocol: Streamable HTTP v1.7.0

🧩 Likely Root Cause

McpMessageHandler.initializeNew(...) currently enforces:

if (!INITIALIZE.equals(method)) {
    String msg = "The first message from the client must be \"initialize\": " + method;
    ...
}

This check blocks legitimate pre-initialize ping requests, contrary to the latest spec.


βœ… Suggested Fix

Permit ping in the NEW connection state (before initialize) β€” for example:

if (PING.equals(method)) {
    return ping(message, mcpRequest);
}

before the if (!INITIALIZE.equals(method)) check in initializeNew(...).

This would make the behavior compliant with the 2025-06-18 MCP lifecycle specification.


Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-feedbackPull requests that update Java code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions