Initializing the Protocol
After creating a client, you need to initialize it before using it to communicate with the server,
that means, before making any requests, you must initialize the protocol by calling the initialize()
method.
The initialize();
method initializes the transport and sets up notification handling.
The Initialize method:
- Sends an initialize request to the server
- Stores the server's capabilities
- Sends an "initialized" notification
- Marks the client as initialized
After successful initialization, the client can make other requests to the server.
After creating the McpClient, you should call the initialize();
right away.
McpClient mcpClient = McpClient.builder()
.clientName("my-host")
.clientVersion("1.2")
.transport(sseTransport)
.build();
mcpClient.initialize();