Checked on November 20, 2026 against
@modelcontextprotocol/client 2.4.0 (the v2 SDK, Node.js 20+). On the older @modelcontextprotocol/sdk 1.x the classes are the same; import them from @modelcontextprotocol/sdk/client/index.js and @modelcontextprotocol/sdk/client/streamableHttp.js.Install
Origin header.
List tools and get a quote
quote.mjs
tools/list returns only the tools your key’s scopes allow. Each tool’s inputSchema describes its arguments.
Buy energy
Quote first, pass the quote’stotal_trx as max_price_trx, and keep one idempotency_key for the purchase so a retry cannot charge twice:
isError: true and the error code in structuredContent.error.
Sign users in with OAuth
For an app where each user connects their own account, pass anauthProvider to the transport instead of a header. The SDK’s OAuthClientProvider interface runs discovery, client registration and PKCE against TronRental’s OAuth server; you store the tokens and send the user to the authorization URL. See the SDK’s OAuth guide.
Use a loopback redirect URI (http://127.0.0.1:<port>/callback) for desktop and CLI apps; for a web app’s own callback, contact support.