> ## 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.

# Claude API

> Give Claude TronRental tools in a Messages API request with the MCP connector

> [!NOTE]
>
> Checked on November 20, 2026 against the [MCP connector docs](https://platform.claude.com/docs/en/agents-and-tools/mcp-connector) (beta `mcp-client-2025-11-20`), `anthropic` **2.11.0** (Python) and `@anthropic-ai/sdk` **1.11.0** (TypeScript).

With the MCP connector, Claude calls TronRental from Anthropic's side during the request — no MCP client in your code. The connector sends only `authorization_token`, as `Authorization: Bearer <token>`: an API key, or an OAuth access token of the user. Calls come from Anthropic's IP addresses, so a key with an IP whitelist is refused.

Each server in `mcp_servers` needs a matching `mcp_toolset` entry in `tools`.

## Python

```bash theme={null}
pip install "anthropic>=2.11"
```

```python claude.py theme={null}
import os

import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY

response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "How much is 65,000 energy for 1 hour on TronRental?"}],
    mcp_servers=[
        {
            "type": "url",
            "url": "https://mcp.tronrental.com/mcp",
            "name": "tronrental",
            "authorization_token": os.environ["TRONRENTAL_API_KEY"],
        }
    ],
    tools=[
        {
            "type": "mcp_toolset",
            "mcp_server_name": "tronrental",
            # Only the tools this assistant needs; everything else stays off.
            "default_config": {"enabled": False},
            "configs": {
                "get_energy_prices": {"enabled": True},
                "quote_energy": {"enabled": True},
                "get_balance": {"enabled": True},
            },
        }
    ],
    betas=["mcp-client-2025-11-20"],
)

for block in response.content:
    if block.type == "text":
        print(block.text)
```

## TypeScript

```bash theme={null}
npm install @anthropic-ai/sdk
```

```ts claude.mjs theme={null}
import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic(); // reads ANTHROPIC_API_KEY

const response = await anthropic.beta.messages.create({
  model: "claude-opus-5-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "How much is 65,000 energy for 1 hour on TronRental?" }],
  mcp_servers: [
    {
      type: "url",
      url: "https://mcp.tronrental.com/mcp",
      name: "tronrental",
      authorization_token: process.env.TRONRENTAL_API_KEY,
    },
  ],
  tools: [{ type: "mcp_toolset", mcp_server_name: "tronrental" }],
  betas: ["mcp-client-2025-11-20"],
});

for (const block of response.content) {
  if (block.type === "text") console.log(block.text);
}
```

## Purchases

The connector runs tool calls inside the request without asking you. Before letting Claude spend:

* enable only the tools it needs (`default_config` and `configs`, as in the Python example);
* prefer an API key with narrow scopes, or a user's OAuth token, whose [daily spending cap](https://docs.tronrental.com/agents/reference/spending-and-errors.md#the-daily-spending-cap) bounds what a request can spend;
* if a person must confirm each purchase, run your own MCP client instead ([TypeScript](https://docs.tronrental.com/agents/build/typescript.md), [Python](https://docs.tronrental.com/agents/build/python.md)) and call `buy_energy` after they agree.

The tool calls and their results come back in `response.content` as `mcp_tool_use` and `mcp_tool_result` blocks.


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