> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tronrental.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build with MCP

> Use TronRental's MCP server from your own app or agent: choose how to authenticate, then pick an example

The TronRental MCP server speaks the standard [Streamable HTTP transport](https://modelcontextprotocol.io/specification/latest/basic/transports) at `https://mcp.tronrental.com/mcp`. Any MCP SDK or LLM platform that supports remote MCP servers can use it.

* **Stateless:** every request is a plain `POST`; there are no sessions to keep.
* **Tools follow the credential:** `tools/list` returns only the tools the key or connection may call.
* **Same rules as REST:** each tool is a [REST API](https://docs.tronrental.com/api-reference/energy/get-prices.md) route behind the scenes, with the same prices, checks and error codes.

## Choose how to authenticate

> [card] API key — your own server
>
> For your backend, scripts and agents that act on **your** account. Send the key as `Authorization: Bearer <key>` or `X-API-Key: <key>`. No daily cap, `max_price_trx` optional, withdrawals possible with the `withdraw` scope.

> [card] OAuth — your users' accounts
>
> For apps where **each user** connects their own TronRental account. The user approves the [consent screen](https://docs.tronrental.com/agents/overview.md#you-stay-in-control); you get a token with the permissions and the daily cap they chose. See [OAuth for MCP clients](https://docs.tronrental.com/agents/reference/oauth.md).

Create an API key on the [API page](https://tronrental.com/dashboard/api) of the dashboard (available after top-ups of 100 TRX in total). Give it only the scopes your agent needs.

> [!WARNING]
>
> When an LLM platform calls the MCP server for you (OpenAI hosted MCP, the Claude API MCP connector), your key or token is sent to that platform, and the calls come from **its** IP addresses. Use a key without `withdraw`, keep its scopes narrow, and note that a key with an IP whitelist will refuse those calls. To keep the key on your own server, run an MCP client yourself (the TypeScript and Python examples).

## Pick an example

> [card] [TypeScript](https://docs.tronrental.com/agents/build/typescript.md)
>
> MCP client over Streamable HTTP with the official TypeScript SDK.

> [card] [Python](https://docs.tronrental.com/agents/build/python.md)
>
> MCP client over Streamable HTTP with the official Python SDK.

> [card] [OpenAI Agents SDK](https://docs.tronrental.com/agents/build/openai-agents.md)
>
> Hosted MCP tool and a local MCP client for OpenAI agents.

> [card] [Claude API](https://docs.tronrental.com/agents/build/claude-api.md)
>
> The MCP connector in a Messages API request.

## MCP or REST?

Use **MCP** when a language model decides which call to make: the model reads the tool list and their descriptions and picks the tool.

Use the **[REST API](https://docs.tronrental.com/api-reference/energy/get-prices.md)** when your code already knows what to do — for example, "buy 65,000 energy before each payout". It is one HTTP request with no MCP layer, and the [webhooks](https://docs.tronrental.com/api-reference/webhooks/overview.md) tell you when an order is done. Both use the same API key, so you can mix them.

## Before you go live

* **Quote, then buy.** Pass the quote's `total_trx` as `max_price_trx`. See [Spending and errors](https://docs.tronrental.com/agents/reference/spending-and-errors.md).
* **Retry safely.** Generate an `idempotency_key` (a UUID) per action and reuse it on retries.
* **Show the cost.** Tell the user what a call costs before calling a tool that spends — every such tool is marked `destructiveHint: true`.
* **Check the result.** Orders are delivered on-chain within seconds; read `get_order` or wait for the `order.updated` webhook.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.