Class SecuredExampleClient
java.lang.Object
org.apache.juneau.examples.mcp.secured.SecuredExampleClient
A guided walkthrough of calling
SecuredExampleMcpServer, showing the secured request/response
cycle a newcomer to MCP OAuth 2.1 needs to see: a rejected unauthenticated call (twice — once at the
raw wire level, once through the real McpClient SDK), the full RFC 9728 → RFC 8414 discovery
chain, a successful read-only call, a scoped step-up rejection, and finally a successful write once a token
carrying the write scope has been acquired.
Run main with three arguments — the secured server's endpoint and the demo
client id/secret — all three of which SecuredExampleServer.main(String[]) prints on startup
(they cannot be hardcoded here: the demo client secret is freshly randomly generated on every server run, by
design; see OfflineAuthorizationServer). Unlike an earlier version of this walkthrough, the token
endpoint is no longer a fourth argument (M10): this client discovers it itself, the same way a real client
would.
-
Method Summary
-
Method Details
-
main
Runs the walkthrough against a runningSecuredExampleServer.- Parameters:
args- Three required arguments: endpoint, client id, client secret — copy these fromSecuredExampleServer.main(String[])'s startup banner.- Throws:
Exception- If any step fails unexpectedly (a REJECTED call is expected and handled, not thrown).
-
run
Executes each numbered step of the walkthrough.- Parameters:
endpoint- The secured MCP server's endpoint URL.clientId- The demo OAuth client id.clientSecret- The demo OAuth client secret.- Throws:
Exception- If an unexpected (non-auth-related) failure occurs.
-