Class ExampleClient

java.lang.Object
org.apache.juneau.examples.mcp.ExampleClient

public final class ExampleClient extends Object
A guided, end-to-end walkthrough of every ExampleMcpServer surface using the v2 McpClient.

Run main (optionally passing the server endpoint; defaults to http://localhost:10000/) after starting ExampleServer. Each numbered step prints what it is doing and what it got back, so the transcript reads top-to-bottom like a tutorial.

The client advertises the elicitation capability, which the server requires before it will pause a call for input; without it the deleteNote elicitation step would be rejected.

Console output caveat: every printed line below is produced by re-serializing the already-parsed response bean with Json.of(...), purely for readable console output. That re-serialization drops the polymorphic content-block "type" discriminator (e.g. "text"/"audio") the real wire format carries, so what you see here is not byte-for-byte what came off the wire.

  • Method Details

    • main

      public static void main(String[] args) throws Exception
      Runs the walkthrough against a running ExampleServer.
      Parameters:
      args - Optional single argument: the server endpoint (defaults to http://localhost:10000/).
      Throws:
      Exception - If any step fails.
    • connect

      public static McpClient connect(String endpoint) throws IOException
      Builds and connects a client that advertises the elicitation capability.
      Parameters:
      endpoint - The MCP server endpoint URL.
      Returns:
      A connected client (its mandatory server/discover handshake already done).
      Throws:
      IOException - If the connection or handshake fails.
    • run

      public static void run(McpClient client) throws Exception
      Executes each numbered step of the walkthrough against an already-connected client.
      Parameters:
      client - The connected MCP client.
      Throws:
      Exception - If any step fails.