Class ExampleClient
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 Summary
Modifier and TypeMethodDescriptionstatic McpClientBuilds and connects a client that advertises the elicitation capability.static voidRuns the walkthrough against a runningExampleServer.static voidExecutes each numbered step of the walkthrough against an already-connected client.
-
Method Details
-
main
Runs the walkthrough against a runningExampleServer.- Parameters:
args- Optional single argument: the server endpoint (defaults tohttp://localhost:10000/).- Throws:
Exception- If any step fails.
-
connect
Builds and connects a client that advertises the elicitation capability.- Parameters:
endpoint- The MCP server endpoint URL.- Returns:
- A connected client (its mandatory
server/discoverhandshake already done). - Throws:
IOException- If the connection or handshake fails.
-
run
Executes each numbered step of the walkthrough against an already-connected client.- Parameters:
client- The connected MCP client.- Throws:
Exception- If any step fails.
-