Skip to main content
Checked on November 20, 2026 against mcp 2.3.0 (Python 3.11+, HTTP via httpx2). In mcp 2.x the transport function is streamable_http_client and it takes headers from the HTTP client; the 1.x name streamablehttp_client no longer exists.

Install

List tools and get a quote

quote.py
Client runs the MCP initialize handshake for you. tools/list returns only the tools your key’s scopes allow.

Buy energy

Quote first, pass the quote’s total_trx as max_price_trx, and keep one idempotency_key for the purchase so a retry cannot charge twice:
A refused call does not raise in the SDK: the result has is_error set and the error code in structured_content["error"].

Sign users in with OAuth

For an app where each user connects their own account, use the SDK’s mcp.client.auth.OAuthClientProvider as the auth of the httpx2.AsyncClient instead of a header. It runs discovery, client registration and PKCE against TronRental’s OAuth server; you provide token storage and the redirect and callback handlers. See the SDK’s authorization 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.