Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ If you are an AI coding agent or an autonomous tool reading this for orientation
| --- | --- |
| DApp integration in the browser (TIP-6963 / `eth_requestAccounts` / `tronWeb`) | [docs/dapp/getting-started.en.md](docs/dapp/getting-started.en.md) + [docs/plugin-wallet/*](docs/plugin-wallet/) |
| Mobile DeepLink (`tronlinkoutside://`) | [docs/mobile/deeplink.en.md](docs/mobile/deeplink.en.md) |
| Android wallet core | [docs/mobile/android-core.en.md](docs/mobile/android-core.en.md) |
| iOS wallet core | [docs/mobile/ios-core.en.md](docs/mobile/ios-core.en.md) |
| Browser extension wallet core | [docs/plugin-wallet/extension-core.en.md](docs/plugin-wallet/extension-core.en.md) |
| AI-agent tooling overview | [docs/ai-support/ai-llms.en.md](docs/ai-support/ai-llms.en.md) |
| MCP server (production) | [docs/ai-support/mcp-server-tronlink.en.md](docs/ai-support/mcp-server-tronlink.en.md) |
| MCP framework / SSOT error codes | [docs/ai-support/tronlink-mcp-core.en.md](docs/ai-support/tronlink-mcp-core.en.md) |
Expand Down
3 changes: 3 additions & 0 deletions docs/AGENTS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ If you are an AI coding agent or an autonomous tool reading this for orientation
| --- | --- |
| DApp integration in the browser (TIP-6963 / `eth_requestAccounts` / `tronWeb`) | [docs.tronlink.org/dapp/getting-started/](https://docs.tronlink.org/dapp/getting-started/) + [docs.tronlink.org/plugin-wallet/*](https://docs.tronlink.org/plugin-wallet/active-requests/) |
| Mobile DeepLink (`tronlinkoutside://`) | [docs.tronlink.org/mobile/deeplink/](https://docs.tronlink.org/mobile/deeplink/) |
| Android wallet core | [docs.tronlink.org/mobile/android-core/](https://docs.tronlink.org/mobile/android-core/) |
| iOS wallet core | [docs.tronlink.org/mobile/ios-core/](https://docs.tronlink.org/mobile/ios-core/) |
| Browser extension wallet core | [docs.tronlink.org/plugin-wallet/extension-core/](https://docs.tronlink.org/plugin-wallet/extension-core/) |
| AI-agent tooling overview | [docs.tronlink.org/ai-support/ai-llms/](https://docs.tronlink.org/ai-support/ai-llms/) |
| MCP server (production) | [docs.tronlink.org/ai-support/mcp-server-tronlink/](https://docs.tronlink.org/ai-support/mcp-server-tronlink/) |
| MCP framework / SSOT error codes | [docs.tronlink.org/ai-support/tronlink-mcp-core/](https://docs.tronlink.org/ai-support/tronlink-mcp-core/) |
Expand Down
65 changes: 32 additions & 33 deletions docs/ai-support/mcp-server-tronlink.en.md

Large diffs are not rendered by default.

70 changes: 33 additions & 37 deletions docs/ai-support/mcp-server-tronlink.zh.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/ai-support/mcp-tronlink-signer.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ In v0.1.4, errors are returned as an MCP tool result with `isError: true` and a
|---|---|---|
| **Prompt injection** | Tool inputs are consumed verbatim as call arguments; the server does not re-prompt an LLM with them. The TronLink approval page renders parsed transaction fields, not the agent's free-text. | Treat any on-chain string returned (memos, revert reasons) as untrusted; branch on `txId` / `status`, not on prose. |
| **Local HTTP listener** | The local approval server **binds to `127.0.0.1` only** (port `TRON_HTTP_PORT`, default 3386, auto-increments on conflict). It never accepts off-host connections. Each server session has a unique ID; old browser tabs from previous sessions are invalidated automatically. | Do not port-forward 3386 over a network. Do not run two copies of this server with the same `TRON_HTTP_PORT` on a shared box. |
| **Outbound host allowlist (SSRF)** | The signer only talks to TronGrid endpoints listed in [Networks](#environment-variables) and to the local browser. Tools do not accept user-supplied URLs that get fetched. | Pin `TRON_NETWORK` and (optionally) `TRON_API_KEY` to known values in production. |
| **Outbound host allowlist (SSRF)** | The signer only talks to TronGrid endpoints listed in [network endpoints](../reference/networks.md#networks) and to the local browser. Tools do not accept user-supplied URLs that get fetched. | Pin `TRON_NETWORK` and (optionally) `TRON_API_KEY` to known values in production. |
| **API key handling (token passthrough)** | `TRON_API_KEY` is read from env at startup and used only on the outbound leg to TronGrid. It is **not** returned in any tool response, error `details`, or MCP resource. The server does not accept Authorization headers from MCP clients and forward them upstream. | Store the key in the MCP host's secret manager, not in plain `mcpServers` config committed to git. |
| **HITL is mandatory for signing** | Every signing tool (`send_trx`, `send_trc20`, `sign_message`, `sign_typed_data`, `sign_transaction`) opens the TronLink approval page. **There is no programmatic bypass.** Private keys never leave TronLink. | Operators do not need to enforce HITL — it is structural. Do not attempt to harden by removing the browser layer. |
| **Browser tab hijacking** | The approval page authenticates each request against the server session ID and ignores stale tabs. Heartbeat detection closes the session on browser disconnect. | If the same user runs multiple agents, ensure each spawns its own signer instance; cross-instance request mixing is prevented by session ID, but UI confusion is not. |
Expand Down Expand Up @@ -201,7 +201,7 @@ Co-released with `tronlink-signer@0.1.2`. **Major UX overhaul** on the approval
### Compatibility & migration policy

- **Semver.** Pre-1.0: a **minor** bump (0.x → 0.y) may introduce breaking changes; a **patch** bump (0.1.x → 0.1.y) will not change MCP tool names or input schemas. Post-1.0: standard semver — major-only breaking changes.
- **Deprecation window.** When a tool or input field is deprecated, the next minor release retains the old form alongside the new one for at least one minor cycle, with a `meta.deprecated` flag in the schema; removal lands no earlier than the cycle after that.
- **Deprecations.** [mcp-tronlink-signer 0.1.4](https://www.npmjs.com/package/mcp-tronlink-signer/v/0.1.4) exposes no deprecation flag for its registered tools. Before upgrading, review the target release notes and compare the tool names and input fields returned by `tools/list`.
- **Stable contracts.** Tool names and `status` values (`success` / `pending` / `failed`) are part of the public surface — they don't change in a patch.
- **Volatile contracts.** Error `message` text (match the known values under [Errors](#errors) and treat others as unknown), log line formats, and the layout of the browser approval page are **not** part of the public surface and may change at any time.
- **Verifying after upgrade.** Re-call `list_tools` and confirm the names + schemas you depend on are still present before resuming a workflow.
4 changes: 2 additions & 2 deletions docs/ai-support/mcp-tronlink-signer.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ v0.1.4 中,错误以 MCP 工具结果返回:`isError: true`,内容是一
|---|---|---|
| **Prompt 注入** | 工具输入按原始值作为调用参数,server 不会再次提交给 LLM。TronLink 审批页渲染的是解析后的交易字段,不是 agent 的自由文本。 | 链上拿到的字符串(备注、revert 原因)视为不可信;分支应基于 `txId` / `status`,而非 prose。 |
| **本地 HTTP listener** | 本地审批 server **仅绑定 `127.0.0.1`**(端口 `TRON_HTTP_PORT`,默认 3386,被占用时自增),永远不接受跨主机连接。每个 server session 有唯一 ID,前一次 session 的浏览器标签会被自动失效。 | 不要把 3386 端口转发到外网。同一台机器不要用相同 `TRON_HTTP_PORT` 跑两份。 |
| **出站 host 白名单(SSRF)** | signer 只与 [Networks](#environment-variables) 列出的 TronGrid 端点以及本地浏览器通信,工具不接受会被原样请求的用户 URL。 | 生产环境钉死 `TRON_NETWORK`、`TRON_API_KEY`。 |
| **出站 host 白名单(SSRF)** | signer 只与 [网络端点](../reference/networks.md#networks) 列出的 TronGrid 端点以及本地浏览器通信,工具不接受会被原样请求的用户 URL。 | 生产环境钉死 `TRON_NETWORK`、`TRON_API_KEY`。 |
| **API key 处理(token passthrough)** | `TRON_API_KEY` 仅在启动时从 env 读取,仅用于到 TronGrid 的出站;**不**会出现在任何工具响应、错误 `details` 或 MCP resource 中。server 不接受 MCP 客户端传入的 Authorization header 并转发到上游。 | API key 放进 MCP host 的 secret manager,不要写进会提交 git 的 `mcpServers` 配置。 |
| **签名必须 HITL** | 所有签名工具(`send_trx`、`send_trc20`、`sign_message`、`sign_typed_data`、`sign_transaction`)都会打开 TronLink 审批页,**不存在程序化绕过**。私钥始终留在 TronLink。 | 不需要运维额外强制 HITL——这是结构性保证。不要试图通过移除浏览器层来"加固"。 |
| **浏览器标签劫持** | 审批页基于 server session ID 验证每次请求,过期的标签会被忽略;心跳检测会在断连时关闭 session。 | 同一用户跑多个 agent 时,请让每个 agent 启动自己的 signer 实例;跨实例的请求串扰由 session ID 屏蔽,但 UI 层混淆不防。 |
Expand Down Expand Up @@ -207,7 +207,7 @@ v0.1.4 中,错误以 MCP 工具结果返回:`isError: true`,内容是一
### 兼容性与迁移策略

- **语义化版本。** 1.0 之前:**minor** 升级(0.x → 0.y)允许破坏性变更;**patch** 升级(0.1.x → 0.1.y)不变更 MCP 工具名或输入 schema。1.0 之后:标准 semver,仅 major 允许破坏。
- **废弃窗口。** 当某工具或入参字段被废弃时,下一 minor 至少保留旧形式与新形式并存 **一个 minor 周期**,schema 内置 `meta.deprecated` 标记;移除最早发生在再下一周期。
- **弃用检查。** [mcp-tronlink-signer 0.1.4](https://www.npmjs.com/package/mcp-tronlink-signer/v/0.1.4) 的已注册工具没有弃用标记。升级前请查阅目标版本的发布说明,并用 `tools/list` 比对依赖的工具名称和输入字段。
- **稳定契约。** 工具名、`status` 值(`success` / `pending` / `failed`)属于公开面,patch 不会动。
- **不稳定契约。** 错误 `message` 文本(匹配[错误](#errors)中列出的已知取值,其他按未知处理)、日志行格式、审批页的视觉布局 **不属于** 公开面,随时可能变化。
- **升级后校验。** 升级后 **必须** 重新 `list_tools` 确认你依赖的名字 + schema 仍存在,再继续工作流。
15 changes: 11 additions & 4 deletions docs/ai-support/tronlink-cli.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ In `--json` mode, v1.0.1 writes failures to **stderr** and exits with `1`:
2. For read operations with `--address`: queries TronGrid directly
3. For write/read without `--address`: connects to the TronLink browser extension for wallet info
4. Builds unsigned transaction using local TronWeb `transactionBuilder`
5. Pre-flight check: runs on all write commands (transfer, stake, unstake, delegate, reclaim, vote, trigger). Verifies TRX / token / staked / delegated balances, simulates contract calls to catch reverts, estimates energy & bandwidth burn, validates SR addresses (vote), NFT ownership (TRC721), and delegation unlock times (reclaim) before signing
5. Pre-flight check: depends on the command (transfer, stake, unstake, delegate, reclaim, vote, trigger). Verifies TRX / token / staked / delegated balances, simulates contract calls to catch reverts, estimates energy & bandwidth burn, validates SR addresses (vote), NFT ownership (TRC721), and delegation unlock times (reclaim) before signing

In v1.0.1, `withdraw` queries the payer’s `unfrozenV2` entries and errors before signing if no matured TRX is available. `reward` calls `getReward(address)` and returns without signing if the amount is zero or less (JSON status `No Rewards`). A failed lookup stops either command before signing.

6. Sends transaction to TronLink for signing (browser approval page)
7. Broadcasts: signer broadcasts by default, or CLI broadcasts locally with `--local-broadcast`. In both modes the CLI polls `getUnconfirmedTransactionInfo` until the tx is packed into a block (~3s), and surfaces OUT_OF_ENERGY / REVERT / FAILED as errors
8. Outputs result
Expand Down Expand Up @@ -431,11 +434,15 @@ tronlink reward --json
### Example: AI Transfer Flow

```bash
# 1. Check balance first
tronlink balance --address TNPeeaaFB7K9cmo4uQpcU32zGK8G1NYqeL --network mainnet --json
# Set PAYER to the address selected in TronLink and RECIPIENT to the destination.
# If the wallet account or network changes, cancel and check the new balance first.
NETWORK=mainnet

# 1. Check the payer's balance
tronlink balance --address "${PAYER:?set PAYER}" --network "$NETWORK" --json

# 2. Send 10 TRX (opens browser for signing, wait for return)
tronlink transfer --type trx --toAddress TRecipientAddress --amount 10 --network mainnet --json
tronlink transfer --type trx --toAddress "${RECIPIENT:?set RECIPIENT}" --amount 10 --network "$NETWORK" --json

# 3. Verify result — output includes txId and explorer URL
# { "Status": "Success", "TxID": "abc...", "Explorer": "https://tronscan.org/#/transaction/abc..." }
Expand Down
Loading
Loading