# MCP server

Source: https://tenergy.me/docs/mcp
Last updated: 2026-09-25

`@tenergy/mcp` is a Model Context Protocol server over the public API. Your agent prices, quotes and orders energy through it; the server signs with your API key, and the key never reaches the model.

> [!NOTE]
> The package is not published to npm yet. Until it is, the lines below are the install you will run on release; the [agent quickstart](https://tenergy.me/docs/agent-quickstart) covers the same flow over plain HTTP.

## Tools

| Tool | Needs a key | What it does |
|---|---|---|
| `get_prices`, `get_address_resources` | No | Price table; a receiver's energy and bandwidth |
| `estimate_transfer` | Yes | Cost of one USDT transfer to a receiver |
| `get_balance`, `get_deposit_addresses` | Yes | Prepaid balance; where to top it up |
| `create_quote`, `create_order` | Yes (spending scopes) | Pin a price for 120 s; buy it |
| `get_order`, `list_orders` | Yes | Status and history |

Resources: `tenergy://docs/quickstart`, `tenergy://llms.txt`.

## Install

Run: `npx -y @tenergy/mcp` (stdio) or `npx -y @tenergy/mcp --http 3333` (streamable HTTP at `http://localhost:3333/mcp`).

**Claude Desktop** — `claude_desktop_config.json`:

```json title="claude_desktop_config.json"
{"mcpServers":{"tenergy":{"command":"npx","args":["-y","@tenergy/mcp"],"env":{"TENERGY_API_KEY":"...","TENERGY_API_SECRET":"..."}}}}
```

**Claude Code**:

```bash title="Shell"
claude mcp add tenergy -e TENERGY_API_KEY=... -e TENERGY_API_SECRET=... -- npx -y @tenergy/mcp
```

**ChatGPT** (Settings → Connectors → developer mode → add connector): run `npx -y @tenergy/mcp --http 3333` behind a public HTTPS URL and enter `https://<your-host>/mcp` as the server URL.

**Cursor / Antigravity** — `mcp.json`:

```json title="mcp.json"
{"mcpServers":{"tenergy":{"command":"npx","args":["-y","@tenergy/mcp"],"env":{"TENERGY_API_KEY":"...","TENERGY_API_SECRET":"..."}}}}
```

## Environment

| Variable | Default | Meaning |
|---|---|---|
| `TENERGY_API_URL` | `https://api-nile.tenergy.me/v1` (Nile) | API base including `/v1`; set the mainnet host deliberately |
| `TENERGY_API_KEY`, `TENERGY_API_SECRET` | unset | Your key pair, used to sign and never sent to the model. Unset: only `get_prices` and `get_address_resources` are registered |
| `TENERGY_SITE_URL` | `https://tenergy.me` | Docs host for the resources |
| `TENERGY_MCP_READ_ONLY` | unset | `1` removes `create_quote` and `create_order`, even with a spending key |
| `TENERGY_MCP_MAX_ORDER_TRX` | `50` | `create_order` prices the order first and refuses, without buying, above this total |

## Safety rules

| Rule | Why |
|---|---|
| The server refuses to start if any env value looks like a raw private key (64 hex chars) | It never signs transactions; a wallet key has no business here |
| `create_order` requires `max_price_sun` and `client_order_id` | A price ceiling and an idempotency key on every purchase |
| Orders above `TENERGY_MCP_MAX_ORDER_TRX` are refused before any charge | A confused agent cannot drain the balance in one call |
| Give the key only the scopes the agent needs; there is no default set | See [Authentication](https://tenergy.me/docs/authentication) |
| Rehearse on Nile first | [Environments](https://tenergy.me/docs/environments) lists what Nile cannot prove |
