@bankofai/mcp-server-tron 1.1.7-beta → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -48
- package/build/core/prompts.js +5 -11
- package/build/core/prompts.js.map +1 -1
- package/build/core/services/agent-wallet.d.ts +1 -4
- package/build/core/services/agent-wallet.js +14 -35
- package/build/core/services/agent-wallet.js.map +1 -1
- package/build/core/tools/index.d.ts +3 -8
- package/build/core/tools/index.js +6 -22
- package/build/core/tools/index.js.map +1 -1
- package/build/core/tools/types.d.ts +0 -1
- package/build/core/tools/wallet.js +5 -6
- package/build/core/tools/wallet.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -36,9 +36,9 @@ Key capabilities:
|
|
|
36
36
|
- **Smart Contracts**: Interact with any TRON smart contract (Read/Write).
|
|
37
37
|
- **Tokens**: Transfer TRX and TRC20 tokens; check balances.
|
|
38
38
|
- **Address Management**: Convert between Hex (0x...) and Base58 (T...) formats.
|
|
39
|
-
- **Wallet Integration**: Agent-wallet
|
|
39
|
+
- **Wallet Integration**: Agent-wallet-managed file-backed wallets.
|
|
40
40
|
- **Multi-Network**: Seamless support for Mainnet, Nile, and Shasta.
|
|
41
|
-
- **Dynamic Access Control**:
|
|
41
|
+
- **Dynamic Access Control**: Write-capable tools stay registered; `--readonly` hides them, and wallet-dependent handlers fail at execution time if no wallet is available.
|
|
42
42
|
|
|
43
43
|
## Features
|
|
44
44
|
|
|
@@ -91,8 +91,7 @@ Key capabilities:
|
|
|
91
91
|
|
|
92
92
|
### Wallet & Security
|
|
93
93
|
|
|
94
|
-
- **Agent Wallet
|
|
95
|
-
- **Static Wallet**: Configure via `TRON_PRIVATE_KEY` or `TRON_MNEMONIC` environment variables.
|
|
94
|
+
- **Agent Wallet**: File-backed wallet storage via `agent-wallet` SDK.
|
|
96
95
|
- **HD Wallet**: Supports BIP-44 derivation path `m/44'/195'/0'/0/{index}`.
|
|
97
96
|
- **Signing**: Sign arbitrary messages and transactions.
|
|
98
97
|
|
|
@@ -122,9 +121,7 @@ npm install
|
|
|
122
121
|
|
|
123
122
|
### Environment Variables
|
|
124
123
|
|
|
125
|
-
**CRITICAL SECURITY NOTE**: For your security, **NEVER** save your private keys or mnemonics directly in the MCP configuration JSON files (like `claude_desktop_config.json` or `mcp.json`).
|
|
126
|
-
|
|
127
|
-
To enable write operations (transfers, contract calls) and ensure reliable API access, you should configure the following variables.
|
|
124
|
+
**CRITICAL SECURITY NOTE**: For your security, **NEVER** save your private keys or mnemonics directly in the MCP configuration JSON files (like `claude_desktop_config.json` or `mcp.json`). For wallet setup, follow `agent-wallet`'s file-backed configuration and the SDK-supported `AGENT_WALLET_*` settings; use environment variables only for non-secret operational settings like `TRONGRID_API_KEY`.
|
|
128
125
|
|
|
129
126
|
#### Network Configuration
|
|
130
127
|
|
|
@@ -137,37 +134,11 @@ To enable write operations (transfers, contract calls) and ensure reliable API a
|
|
|
137
134
|
|
|
138
135
|
#### Wallet Configuration
|
|
139
136
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
**Option 1: Agent-Wallet Mode (Recommended)**
|
|
143
|
-
|
|
144
|
-
Private keys are encrypted at rest and never exposed in environment variables.
|
|
137
|
+
Wallets are managed through `agent-wallet` file-backed configuration. This repository no longer reads or maps legacy `TRON_PRIVATE_KEY` / `TRON_MNEMONIC` / `TRON_ACCOUNT_INDEX` wallet variables.
|
|
145
138
|
|
|
146
139
|
> **Prerequisites**: Install and configure [agent-wallet](https://github.com/BofAI/agent-wallet/blob/main/doc/getting-started.md)
|
|
147
140
|
|
|
148
|
-
|
|
149
|
-
export AGENT_WALLET_PASSWORD="<YOUR_MASTER_PASSWORD>"
|
|
150
|
-
export AGENT_WALLET_DIR="<YOUR_WALLET_DIR>" # Optional, default: ~/.agent-wallet
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
> `AGENT_WALLET_PASSWORD` must match the master password used during `agent-wallet`. If not set, agent-wallet mode is disabled and the server falls back to static mode or read-only mode.
|
|
154
|
-
|
|
155
|
-
**Option 2: Private Key**
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
export TRON_PRIVATE_KEY="<YOUR_PRIVATE_KEY_HERE>"
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**Option 3: Mnemonic Phrase**
|
|
162
|
-
|
|
163
|
-
```bash
|
|
164
|
-
export TRON_MNEMONIC="<WORD1> <WORD2> ... <WORD12>"
|
|
165
|
-
export TRON_ACCOUNT_INDEX="0" # Optional, default: 0
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
> **Security Note**: Static modes expose keys in plaintext. **Only keep small amounts of funds** in these wallets — large balances carry a real **risk of theft**. Use Agent-Wallet Mode (Option 1) for any significant funds.
|
|
169
|
-
|
|
170
|
-
> See [`.env.example`](.env.example) for a complete list of all supported environment variables.
|
|
141
|
+
> See [`agent-wallet`](https://github.com/BofAI/agent-wallet) for wallet file formats, local setup, and the SDK-supported `AGENT_WALLET_*` settings.
|
|
171
142
|
|
|
172
143
|
### Server Configuration
|
|
173
144
|
|
|
@@ -228,14 +199,14 @@ npx vitest tests/core/services/contracts.test.ts # Contract services
|
|
|
228
199
|
npx vitest tests/core/services/account-resource.test.ts # Account resource services
|
|
229
200
|
npx vitest tests/core/services/staking.test.ts # Staking services
|
|
230
201
|
|
|
231
|
-
# Integration tests (real Nile RPC; write
|
|
202
|
+
# Integration tests (real Nile RPC; write-operation coverage is skipped unless wallet support is explicitly enabled)
|
|
232
203
|
npx vitest tests/core/tools_integration.test.ts # Full tool flow on Nile
|
|
233
204
|
npx vitest tests/core/services/multicall.test.ts # Multicall integration
|
|
234
205
|
npx vitest tests/core/services/services.test.ts # Services integration
|
|
235
206
|
```
|
|
236
207
|
|
|
237
208
|
- **Unit tests** use mocks and do not need network or wallet.
|
|
238
|
-
- **Integration tests** (`tools_integration.test.ts`) call Nile RPC; most cases are read-only.
|
|
209
|
+
- **Integration tests** (`tools_integration.test.ts`) call Nile RPC; most cases are read-only. Wallet-dependent handlers are exercised as runtime failures by default, while write-success paths require an explicit wallet fixture or equivalent setup.
|
|
239
210
|
|
|
240
211
|
### Client Configuration
|
|
241
212
|
|
|
@@ -249,12 +220,6 @@ Runs the latest version directly from npm via stdio transport.
|
|
|
249
220
|
claude mcp add mcp-server-tron -- npx -y @bankofai/mcp-server-tron
|
|
250
221
|
```
|
|
251
222
|
|
|
252
|
-
With environment variables:
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
claude mcp add -e AGENT_WALLET_PASSWORD=xxx -e TRONGRID_API_KEY=xxx mcp-server-tron -- npx -y @bankofai/mcp-server-tron
|
|
256
|
-
```
|
|
257
|
-
|
|
258
223
|
**Cursor** (`.cursor/mcp.json`):
|
|
259
224
|
|
|
260
225
|
```json
|
|
@@ -264,8 +229,7 @@ claude mcp add -e AGENT_WALLET_PASSWORD=xxx -e TRONGRID_API_KEY=xxx mcp-server-t
|
|
|
264
229
|
"command": "npx",
|
|
265
230
|
"args": ["-y", "@bankofai/mcp-server-tron"],
|
|
266
231
|
"env": {
|
|
267
|
-
"
|
|
268
|
-
"TRONGRID_API_KEY": "YOUR_KEY_HERE (Or set in system env)"
|
|
232
|
+
"TRONGRID_API_KEY": "YOUR_KEY_HERE"
|
|
269
233
|
}
|
|
270
234
|
}
|
|
271
235
|
}
|
|
@@ -496,9 +460,8 @@ claude mcp add -transport http mcp-server-tron https://tron-mcp-server.bankofai.
|
|
|
496
460
|
|
|
497
461
|
## Security Considerations
|
|
498
462
|
|
|
499
|
-
- **Private Keys & Mnemonics**:
|
|
500
|
-
- **
|
|
501
|
-
- **Shared Machines**: Be aware that on shared systems, environment variables might be visible to other users via `/proc` or system monitoring tools.
|
|
463
|
+
- **Private Keys & Mnemonics**: Keep wallet material inside `agent-wallet` file-backed configuration instead of plain text MCP config files. This repository no longer maps legacy `TRON_*` wallet variables; use `AGENT_WALLET_*` only when following the `agent-wallet` SDK documentation.
|
|
464
|
+
- **Shared Machines**: Be aware that plain environment variables can be visible to other users via `/proc` or system monitoring tools.
|
|
502
465
|
- **Testnets**: Always test on Nile or Shasta before performing operations on Mainnet.
|
|
503
466
|
- **Approvals**: Be cautious when approving token allowances via `write_contract`. Only approve what is necessary.
|
|
504
467
|
|
package/build/core/prompts.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import * as services from "./services/index.js";
|
|
3
2
|
/**
|
|
4
3
|
* Register task-oriented prompts with the MCP server
|
|
5
4
|
*
|
|
@@ -17,24 +16,19 @@ import * as services from "./services/index.js";
|
|
|
17
16
|
*/
|
|
18
17
|
export function registerTRONPrompts(server, options = {}) {
|
|
19
18
|
/**
|
|
20
|
-
* Helper to register a prompt with
|
|
21
|
-
* Prompts
|
|
22
|
-
*
|
|
19
|
+
* Helper to register a prompt with read-only gating.
|
|
20
|
+
* Prompts are registered up front; write guidance is hidden only in readonly
|
|
21
|
+
* mode and wallet availability is checked when the underlying tools run.
|
|
23
22
|
*/
|
|
24
23
|
const registerPrompt = (name, definition, handler, extra = {}) => {
|
|
25
24
|
// Default to true: most prompts are informational and safe in readonly mode.
|
|
26
25
|
// This differs from tools.ts where the default is false (write-capable) because
|
|
27
26
|
// unregistered tools could mutate state, while prompts only guide the LLM.
|
|
28
27
|
const isReadOnly = extra.isReadOnly !== false;
|
|
29
|
-
const walletNeeded = extra.requiresWallet === true;
|
|
30
28
|
// 1. Skip if in read-only mode and the prompt is for write operations
|
|
31
29
|
if (options.readOnly && !isReadOnly) {
|
|
32
30
|
return;
|
|
33
31
|
}
|
|
34
|
-
// 2. Skip if the prompt needs a wallet but none is configured
|
|
35
|
-
if (walletNeeded && services.getActiveWalletId() === null) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
32
|
server.registerPrompt(name, definition, handler);
|
|
39
33
|
};
|
|
40
34
|
// ============================================================================
|
|
@@ -99,7 +93,7 @@ ${tokenType === "trx"
|
|
|
99
93
|
},
|
|
100
94
|
},
|
|
101
95
|
],
|
|
102
|
-
}), {
|
|
96
|
+
}), { isReadOnly: false });
|
|
103
97
|
registerPrompt("interact_with_contract", {
|
|
104
98
|
description: "Safely execute write operations on a smart contract with validation and confirmation",
|
|
105
99
|
argsSchema: {
|
|
@@ -222,7 +216,7 @@ After execution:
|
|
|
222
216
|
},
|
|
223
217
|
],
|
|
224
218
|
};
|
|
225
|
-
}, {
|
|
219
|
+
}, { isReadOnly: false });
|
|
226
220
|
registerPrompt("diagnose_transaction", {
|
|
227
221
|
description: "Analyze transaction status, failures, and provide debugging insights",
|
|
228
222
|
argsSchema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/core/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/core/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,UAAkC,EAAE;IACzF;;;;OAIG;IACH,MAAM,cAAc,GAAG,CACrB,IAAY,EACZ,UAGC,EACD,OAA+C,EAC/C,QAAkC,EAAE,EACpC,EAAE;QACF,6EAA6E;QAC7E,gFAAgF;QAChF,2EAA2E;QAC3E,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC;QAE9C,sEAAsE;QACtE,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QAED,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAiB,EAAE,OAAc,CAAC,CAAC;IACjE,CAAC,CAAC;IAEF,+EAA+E;IAC/E,sBAAsB;IACtB,+EAA+E;IAE/E,cAAc,CACZ,kBAAkB,EAClB;QACE,WAAW,EAA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,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;4BAChG,CAAC,CAAC,oEACN;;;;;;;;;;;;;;;;;;;;;;;;CAwBC;qBACY;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,+EAA+E;IAC/E,8BAA8B;IAC9B,+EAA+E;IAE/E,cAAc,CACZ,sBAAsB,EACtB;QACE,WAAW,EAAE,6CAA6C;QAC1D,UAAU,EAAE;YACV,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;SAC3E;KACF,EACD,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5B,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;yDAEuC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA2BrC,OAAO;;;;;;;;;;;;;;;;CAgBjC;iBACU;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
* Agent-wallet integration layer for mcp-server-tron.
|
|
3
3
|
*
|
|
4
4
|
* Provides a unified signing interface via agent-wallet SDK.
|
|
5
|
-
* Supports:
|
|
6
|
-
* - **Encrypted Storage mode**: Keys encrypted at rest (password-protected).
|
|
7
|
-
* - **Static/Env mode**: Keys provided via environment variables.
|
|
8
5
|
*/
|
|
9
6
|
import { type Wallet } from "@bankofai/agent-wallet";
|
|
10
7
|
/**
|
|
@@ -16,7 +13,7 @@ export declare function getActiveWallet(): Promise<Wallet>;
|
|
|
16
13
|
*/
|
|
17
14
|
export declare function getOwnerAddress(): Promise<string>;
|
|
18
15
|
/**
|
|
19
|
-
* Switch the active wallet at runtime
|
|
16
|
+
* Switch the active wallet at runtime when the provider supports multi-wallet selection.
|
|
20
17
|
*/
|
|
21
18
|
export declare function selectWallet(walletId: string): Promise<{
|
|
22
19
|
id: string;
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
* Agent-wallet integration layer for mcp-server-tron.
|
|
3
3
|
*
|
|
4
4
|
* Provides a unified signing interface via agent-wallet SDK.
|
|
5
|
-
* Supports:
|
|
6
|
-
* - **Encrypted Storage mode**: Keys encrypted at rest (password-protected).
|
|
7
|
-
* - **Static/Env mode**: Keys provided via environment variables.
|
|
8
5
|
*/
|
|
9
6
|
import { resolveWalletProvider, } from "@bankofai/agent-wallet";
|
|
10
7
|
import { TronWeb } from "tronweb";
|
|
@@ -16,29 +13,10 @@ let provider = null;
|
|
|
16
13
|
let activeWallet = null;
|
|
17
14
|
let activeAddress = null;
|
|
18
15
|
// ---------------------------------------------------------------------------
|
|
19
|
-
// Provider initialization (lazy)
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
/**
|
|
22
|
-
* Configure environment variables for backward compatibility.
|
|
23
|
-
* Maps TRON_PRIVATE_KEY -> AGENT_WALLET_PRIVATE_KEY etc.
|
|
24
|
-
*/
|
|
25
|
-
function ensureEnvMapping() {
|
|
26
|
-
if (process.env.TRON_PRIVATE_KEY && !process.env.AGENT_WALLET_PRIVATE_KEY) {
|
|
27
|
-
process.env.AGENT_WALLET_PRIVATE_KEY = process.env.TRON_PRIVATE_KEY;
|
|
28
|
-
}
|
|
29
|
-
if (process.env.TRON_MNEMONIC && !process.env.AGENT_WALLET_MNEMONIC) {
|
|
30
|
-
process.env.AGENT_WALLET_MNEMONIC = process.env.TRON_MNEMONIC;
|
|
31
|
-
}
|
|
32
|
-
if (process.env.TRON_MNEMONIC_ACCOUNT_INDEX && !process.env.AGENT_WALLET_MNEMONIC_ACCOUNT_INDEX) {
|
|
33
|
-
process.env.AGENT_WALLET_MNEMONIC_ACCOUNT_INDEX = process.env.TRON_MNEMONIC_ACCOUNT_INDEX;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
16
|
function getProvider() {
|
|
37
17
|
if (provider)
|
|
38
18
|
return provider;
|
|
39
|
-
ensureEnvMapping();
|
|
40
19
|
try {
|
|
41
|
-
// resolveWalletProvider detects mode from AGENT_WALLET_* env vars
|
|
42
20
|
provider = resolveWalletProvider({ network: "tron" });
|
|
43
21
|
return provider;
|
|
44
22
|
}
|
|
@@ -58,7 +36,7 @@ export async function getActiveWallet() {
|
|
|
58
36
|
return activeWallet;
|
|
59
37
|
const p = getProvider();
|
|
60
38
|
if (!p) {
|
|
61
|
-
throw new Error("Wallet not configured.
|
|
39
|
+
throw new Error("Wallet not configured.");
|
|
62
40
|
}
|
|
63
41
|
activeWallet = await p.getActiveWallet();
|
|
64
42
|
activeAddress = await activeWallet.getAddress();
|
|
@@ -70,22 +48,19 @@ export async function getActiveWallet() {
|
|
|
70
48
|
export async function getOwnerAddress() {
|
|
71
49
|
if (activeAddress)
|
|
72
50
|
return activeAddress;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (address == null) {
|
|
51
|
+
await getActiveWallet();
|
|
52
|
+
if (activeAddress == null) {
|
|
76
53
|
throw new Error("Failed to resolve active wallet address");
|
|
77
54
|
}
|
|
78
|
-
activeAddress
|
|
79
|
-
return address;
|
|
55
|
+
return activeAddress;
|
|
80
56
|
}
|
|
81
57
|
/**
|
|
82
|
-
* Switch the active wallet at runtime
|
|
58
|
+
* Switch the active wallet at runtime when the provider supports multi-wallet selection.
|
|
83
59
|
*/
|
|
84
60
|
export async function selectWallet(walletId) {
|
|
85
61
|
const p = getProvider();
|
|
86
62
|
if (!p || typeof p.setActive !== "function") {
|
|
87
|
-
throw new Error("select_wallet is not available.
|
|
88
|
-
"Ensure AGENT_WALLET_PASSWORD is configured for encrypted storage mode.");
|
|
63
|
+
throw new Error("select_wallet is not available.");
|
|
89
64
|
}
|
|
90
65
|
const lp = p;
|
|
91
66
|
lp.setActive(walletId);
|
|
@@ -121,7 +96,8 @@ export async function listAgentWallets() {
|
|
|
121
96
|
walletType = (w.type ?? "unknown");
|
|
122
97
|
}
|
|
123
98
|
if (!walletId) {
|
|
124
|
-
|
|
99
|
+
// Skip malformed entries so one bad import does not hide all wallets.
|
|
100
|
+
continue;
|
|
125
101
|
}
|
|
126
102
|
const wallet = await lp.getWallet(walletId);
|
|
127
103
|
const address = await wallet.getAddress();
|
|
@@ -129,10 +105,13 @@ export async function listAgentWallets() {
|
|
|
129
105
|
}
|
|
130
106
|
return result;
|
|
131
107
|
}
|
|
132
|
-
//
|
|
108
|
+
// Single-wallet mode
|
|
133
109
|
const wallet = await p.getActiveWallet();
|
|
134
110
|
const address = await wallet.getAddress();
|
|
135
|
-
|
|
111
|
+
if (address == null) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
return [{ id: "single", type: "single", address }];
|
|
136
115
|
}
|
|
137
116
|
/**
|
|
138
117
|
* Get the currently active wallet ID.
|
|
@@ -144,7 +123,7 @@ export function getActiveWalletId() {
|
|
|
144
123
|
if (typeof p.getActiveId === "function") {
|
|
145
124
|
return p.getActiveId();
|
|
146
125
|
}
|
|
147
|
-
return
|
|
126
|
+
return null;
|
|
148
127
|
}
|
|
149
128
|
// ---------------------------------------------------------------------------
|
|
150
129
|
// Signing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-wallet.js","sourceRoot":"","sources":["../../../src/core/services/agent-wallet.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent-wallet.js","sourceRoot":"","sources":["../../../src/core/services/agent-wallet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAE9E,IAAI,Q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Ae,EAAE,CAAC;IACvC,MAAM,YAAY,GAAG,MAAkC,CAAC;IACxD,IAAI,OAAO,YAAY,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAM,YAAY,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAS,CAAC,CAAC;AAC3E,CAAC;AAED,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAK1C,+BAA+B;IAC/B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC;IAE9C,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM;QAC/B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,OAAO,EACL,0GAA0G;KAC7G,CAAC;AACJ,CAAC"}
|
|
@@ -2,14 +2,9 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Register all TRON-related tools with the MCP server
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* Private keys and mnemonics are never passed as
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Configuration options:
|
|
10
|
-
* - TRON_PRIVATE_KEY: Hex private key (with or without 0x prefix)
|
|
11
|
-
* - TRON_MNEMONIC: BIP-39 mnemonic phrase (12 or 24 words)
|
|
12
|
-
* - TRON_ACCOUNT_INDEX: Optional account index for HD wallet derivation (default: 0)
|
|
5
|
+
* Write operations are registered up front and validate wallet availability
|
|
6
|
+
* when the tool handler runs. Private keys and mnemonics are never passed as
|
|
7
|
+
* tool arguments for security reasons.
|
|
13
8
|
*
|
|
14
9
|
* @param server The MCP server instance
|
|
15
10
|
* @param options Registration options (e.g., readOnly mode)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as services from "../services/index.js";
|
|
2
1
|
import { registerWalletTools } from "./wallet.js";
|
|
3
2
|
import { registerNetworkTools } from "./network.js";
|
|
4
3
|
import { registerAddressTools } from "./address.js";
|
|
@@ -22,23 +21,18 @@ import { registerAccountResourceTools } from "./account-resource.js";
|
|
|
22
21
|
/**
|
|
23
22
|
* Register all TRON-related tools with the MCP server
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
* Private keys and mnemonics are never passed as
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* Configuration options:
|
|
30
|
-
* - TRON_PRIVATE_KEY: Hex private key (with or without 0x prefix)
|
|
31
|
-
* - TRON_MNEMONIC: BIP-39 mnemonic phrase (12 or 24 words)
|
|
32
|
-
* - TRON_ACCOUNT_INDEX: Optional account index for HD wallet derivation (default: 0)
|
|
24
|
+
* Write operations are registered up front and validate wallet availability
|
|
25
|
+
* when the tool handler runs. Private keys and mnemonics are never passed as
|
|
26
|
+
* tool arguments for security reasons.
|
|
33
27
|
*
|
|
34
28
|
* @param server The MCP server instance
|
|
35
29
|
* @param options Registration options (e.g., readOnly mode)
|
|
36
30
|
*/
|
|
37
31
|
export function registerTRONTools(server, options = {}) {
|
|
38
32
|
/**
|
|
39
|
-
* Helper to register a tool with
|
|
40
|
-
*
|
|
41
|
-
*
|
|
33
|
+
* Helper to register a tool with read-only gating.
|
|
34
|
+
* Write tools (`readOnlyHint` not true) are omitted when `options.readOnly` is set;
|
|
35
|
+
* wallet availability is validated inside handlers when invoked.
|
|
42
36
|
*/
|
|
43
37
|
const registerTool = (name, definition, handler) => {
|
|
44
38
|
const annotations = definition.annotations || {};
|
|
@@ -46,20 +40,10 @@ export function registerTRONTools(server, options = {}) {
|
|
|
46
40
|
// for safety. This is stricter than prompts.ts (which defaults to read-only) because
|
|
47
41
|
// tools can directly mutate blockchain state.
|
|
48
42
|
const isReadOnly = annotations.readOnlyHint === true;
|
|
49
|
-
const walletNeeded = annotations.requiresWallet === true || !isReadOnly;
|
|
50
43
|
// 1. Skip if in read-only mode and the tool is a write operation
|
|
51
44
|
if (options.readOnly && !isReadOnly) {
|
|
52
45
|
return;
|
|
53
46
|
}
|
|
54
|
-
// 2. Skip if the tool needs a wallet but none is configured
|
|
55
|
-
if (walletNeeded && services.getActiveWalletId() === null) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
// Strip custom `requiresWallet` before passing to SDK (not a standard MCP annotation)
|
|
59
|
-
if (definition.annotations?.requiresWallet !== undefined) {
|
|
60
|
-
const { requiresWallet: _, ...standardAnnotations } = definition.annotations;
|
|
61
|
-
definition = { ...definition, annotations: standardAnnotations };
|
|
62
|
-
}
|
|
63
47
|
server.registerTool(name, definition, handler);
|
|
64
48
|
};
|
|
65
49
|
registerWalletTools(registerTool);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAA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,YAAY,CAAC,CAAC;IACpC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACpC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,4BAA4B,CAAC,YAAY,CAAC,CAAC;IAC3C,kBAAkB,CAAC,YAAY,CAAC,CAAC;IACjC,sBAAsB,CAAC,YAAY,CAAC,CAAC;IACrC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAChC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,kBAAkB,CAAC,YAAY,CAAC,CAAC;IACjC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,uBAAuB,CAAC,YAAY,CAAC,CAAC;IACtC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACpC,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACvC,yBAAyB,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -7,7 +7,6 @@ export function registerWalletTools(registerTool) {
|
|
|
7
7
|
annotations: {
|
|
8
8
|
title: "Get Wallet Address",
|
|
9
9
|
readOnlyHint: true,
|
|
10
|
-
requiresWallet: true,
|
|
11
10
|
destructiveHint: false,
|
|
12
11
|
idempotentHint: true,
|
|
13
12
|
openWorldHint: false,
|
|
@@ -49,7 +48,6 @@ export function registerWalletTools(registerTool) {
|
|
|
49
48
|
annotations: {
|
|
50
49
|
title: "List Wallets",
|
|
51
50
|
readOnlyHint: true,
|
|
52
|
-
requiresWallet: true,
|
|
53
51
|
destructiveHint: false,
|
|
54
52
|
idempotentHint: true,
|
|
55
53
|
openWorldHint: false,
|
|
@@ -65,9 +63,11 @@ export function registerWalletTools(registerTool) {
|
|
|
65
63
|
text: JSON.stringify({
|
|
66
64
|
activeWalletId: activeId,
|
|
67
65
|
wallets,
|
|
68
|
-
message: wallets.length ===
|
|
69
|
-
? "
|
|
70
|
-
:
|
|
66
|
+
message: wallets.length === 0
|
|
67
|
+
? "No wallet is currently configured."
|
|
68
|
+
: wallets.length === 1
|
|
69
|
+
? "Using the configured single wallet."
|
|
70
|
+
: `Found ${wallets.length} wallet(s). Use select_wallet to switch the active wallet.`,
|
|
71
71
|
}, null, 2),
|
|
72
72
|
},
|
|
73
73
|
],
|
|
@@ -93,7 +93,6 @@ export function registerWalletTools(registerTool) {
|
|
|
93
93
|
annotations: {
|
|
94
94
|
title: "Select Wallet",
|
|
95
95
|
readOnlyHint: false,
|
|
96
|
-
requiresWallet: true,
|
|
97
96
|
destructiveHint: false,
|
|
98
97
|
idempotentHint: true,
|
|
99
98
|
openWorldHint: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/core/tools/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAGjD,MAAM,UAAU,mBAAmB,CAAC,YAA4B;IAC9D,YAAY,CACV,oBAAoB,EACpB;QACE,WAAW,EACT,sFAAsF;QACxF,WAAW,EAAE,EAAE;QACf,WAAW,EAAE;YACX,KAAK,EAAE,oBAAoB;YAC3B,YAAY,EAAE,IAAI;YAClB,
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/core/tools/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAGjD,MAAM,UAAU,mBAAmB,CAAC,YAA4B;IAC9D,YAAY,CACV,oBAAoB,EACpB;QACE,WAAW,EACT,sFAAsF;QACxF,WAAW,EAAE,EAAE;QACf,WAAW,EAAE;YACX,KAAK,EAAE,oBAAoB;YAC3B,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,KAAK;SACrB;KACF,EACD,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,M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AAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACzF;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"mcpName": "io.github.bankofai/mcp-server-tron",
|
|
4
4
|
"module": "build/index.js",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "1.1.7
|
|
6
|
+
"version": "1.1.7",
|
|
7
7
|
"description": "MCP server for TRON blockchain. Supports TRX/TRC20 transfers, smart contracts, and AI prompts.",
|
|
8
8
|
"bin": {
|
|
9
9
|
"mcp-server-tron": "./bin/cli.js"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"typescript": "^5.8.2"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@bankofai/agent-wallet": "^2.3.0
|
|
56
|
+
"@bankofai/agent-wallet": "^2.3.0",
|
|
57
57
|
"@modelcontextprotocol/sdk": "^1.22.0",
|
|
58
58
|
"@scure/bip32": "^2.0.1",
|
|
59
59
|
"@scure/bip39": "^2.0.1",
|