@sun-protocol/tron-mcp-server 1.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +282 -0
- package/bin/cli.js +51 -0
- package/build/core/chains.d.ts +17 -0
- package/build/core/chains.js +55 -0
- package/build/core/chains.js.map +1 -0
- package/build/core/prompts.d.ts +16 -0
- package/build/core/prompts.js +268 -0
- package/build/core/prompts.js.map +1 -0
- package/build/core/resources.d.ts +14 -0
- package/build/core/resources.js +42 -0
- package/build/core/resources.js.map +1 -0
- package/build/core/services/address.d.ts +8 -0
- package/build/core/services/address.js +52 -0
- package/build/core/services/address.js.map +1 -0
- package/build/core/services/balance.d.ts +26 -0
- package/build/core/services/balance.js +60 -0
- package/build/core/services/balance.js.map +1 -0
- package/build/core/services/blocks.d.ts +16 -0
- package/build/core/services/blocks.js +46 -0
- package/build/core/services/blocks.js.map +1 -0
- package/build/core/services/clients.d.ts +9 -0
- package/build/core/services/clients.js +46 -0
- package/build/core/services/clients.js.map +1 -0
- package/build/core/services/contracts.d.ts +50 -0
- package/build/core/services/contracts.js +225 -0
- package/build/core/services/contracts.js.map +1 -0
- package/build/core/services/index.d.ts +119 -0
- package/build/core/services/index.js +39 -0
- package/build/core/services/index.js.map +1 -0
- package/build/core/services/multicall-abi.d.ts +55 -0
- package/build/core/services/multicall-abi.js +61 -0
- package/build/core/services/multicall-abi.js.map +1 -0
- package/build/core/services/tokens.d.ts +22 -0
- package/build/core/services/tokens.js +68 -0
- package/build/core/services/tokens.js.map +1 -0
- package/build/core/services/transactions.d.ts +16 -0
- package/build/core/services/transactions.js +42 -0
- package/build/core/services/transactions.js.map +1 -0
- package/build/core/services/transfer.d.ts +24 -0
- package/build/core/services/transfer.js +70 -0
- package/build/core/services/transfer.js.map +1 -0
- package/build/core/services/utils.d.ts +13 -0
- package/build/core/services/utils.js +39 -0
- package/build/core/services/utils.js.map +1 -0
- package/build/core/services/wallet.d.ts +33 -0
- package/build/core/services/wallet.js +113 -0
- package/build/core/services/wallet.js.map +1 -0
- package/build/core/tools.d.ts +16 -0
- package/build/core/tools.js +792 -0
- package/build/core/tools.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +20 -0
- package/build/index.js.map +1 -0
- package/build/server/http-server.d.ts +1 -0
- package/build/server/http-server.js +197 -0
- package/build/server/http-server.js.map +1 -0
- package/build/server/server.d.ts +3 -0
- package/build/server/server.js +46 -0
- package/build/server/server.js.map +1 -0
- package/package.json +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 mcpdotdirect
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# TRON MCP Server
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
A comprehensive Model Context Protocol (MCP) server that provides blockchain services for the TRON network. This server enables AI agents to interact with TRON blockchain with a unified interface through tools and AI-guided prompts for TRX, TRC20 tokens and smart contracts.
|
|
10
|
+
|
|
11
|
+
## Contents
|
|
12
|
+
|
|
13
|
+
- [Overview](#overview)
|
|
14
|
+
- [Features](#features)
|
|
15
|
+
- [Supported Networks](#supported-networks)
|
|
16
|
+
- [Prerequisites](#prerequisites)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Configuration](#configuration)
|
|
19
|
+
- [Environment Variables](#environment-variables)
|
|
20
|
+
- [Server Configuration](#server-configuration)
|
|
21
|
+
- [Usage](#usage)
|
|
22
|
+
- [API Reference](#api-reference)
|
|
23
|
+
- [Tools](#tools)
|
|
24
|
+
- [Prompts](#prompts)
|
|
25
|
+
- [Security Considerations](#security-considerations)
|
|
26
|
+
- [Project Structure](#project-structure)
|
|
27
|
+
- [License](#license)
|
|
28
|
+
|
|
29
|
+
## Overview
|
|
30
|
+
|
|
31
|
+
The MCP TRON Server leverages the Model Context Protocol to provide blockchain services to AI agents. It fully supports the TRON ecosystem using `tronweb`.
|
|
32
|
+
|
|
33
|
+
Key capabilities:
|
|
34
|
+
|
|
35
|
+
- **Blockchain Data**: Read blocks, transactions, and chain parameters (Energy/Bandwidth costs).
|
|
36
|
+
- **Smart Contracts**: Interact with any TRON smart contract (Read/Write).
|
|
37
|
+
- **Tokens**: Transfer TRX and TRC20 tokens; check balances.
|
|
38
|
+
- **Address Management**: Convert between Hex (0x...) and Base58 (T...) formats.
|
|
39
|
+
- **Wallet Integration**: Support for Private Key and Mnemonic (BIP-39) wallets.
|
|
40
|
+
- **Multi-Network**: Seamless support for Mainnet, Nile, and Shasta.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
### Blockchain Data Access
|
|
45
|
+
|
|
46
|
+
- **TRON network support**: Mainnet, Nile, Shasta.
|
|
47
|
+
- **Chain information**: Block number, Chain ID, RPC endpoints.
|
|
48
|
+
- **Block data**: Access by number or hash.
|
|
49
|
+
- **Transaction details**: Detailed info including resource usage (Energy/Bandwidth).
|
|
50
|
+
- **Resource Costs**: Query current chain parameters for Energy and Bandwidth prices.
|
|
51
|
+
|
|
52
|
+
### Token Services
|
|
53
|
+
|
|
54
|
+
- **Native TRX**: Check balance and transfer.
|
|
55
|
+
- **TRC20 Tokens**:
|
|
56
|
+
- Check balances.
|
|
57
|
+
- Transfer tokens.
|
|
58
|
+
- Get token metadata (name, symbol, decimals).
|
|
59
|
+
|
|
60
|
+
### Address Services
|
|
61
|
+
|
|
62
|
+
- **Format Conversion**: Convert between Hex (`41...` or `0x...`) and Base58 (`T...`) formats.
|
|
63
|
+
- **Validation**: Verify if an address is valid on TRON.
|
|
64
|
+
|
|
65
|
+
### Smart Contract Interactions
|
|
66
|
+
|
|
67
|
+
- **Read Contract**: Call `view` and `pure` functions.
|
|
68
|
+
- **Write Contract**: Execute state-changing functions.
|
|
69
|
+
- **ABI Fetching**: Automatically fetches ABI from the blockchain for verified contracts.
|
|
70
|
+
|
|
71
|
+
### Wallet & Security
|
|
72
|
+
|
|
73
|
+
- **Flexible Wallet**: Configure via `TRON_PRIVATE_KEY` or `TRON_MNEMONIC`.
|
|
74
|
+
- **HD Wallet**: Supports BIP-44 derivation path `m/44'/195'/0'/0/{index}`.
|
|
75
|
+
- **Signing**: Sign arbitrary messages.
|
|
76
|
+
|
|
77
|
+
## Supported Networks
|
|
78
|
+
|
|
79
|
+
- **Mainnet**: `mainnet` (Default)
|
|
80
|
+
- **Nile Testnet**: `nile`
|
|
81
|
+
- **Shasta Testnet**: `shasta`
|
|
82
|
+
|
|
83
|
+
## Prerequisites
|
|
84
|
+
|
|
85
|
+
- [Node.js](https://nodejs.org/) 20.0.0 or higher
|
|
86
|
+
- Optional: [TronGrid API key](https://www.trongrid.io/) to avoid rate limiting on Mainnet.
|
|
87
|
+
|
|
88
|
+
## Installation
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Clone the repository
|
|
92
|
+
git clone https://github.com/sun-protocol/tron-mcp-server.git
|
|
93
|
+
cd tron-mcp-server
|
|
94
|
+
|
|
95
|
+
# Install dependencies
|
|
96
|
+
npm install
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Configuration
|
|
100
|
+
|
|
101
|
+
### Environment Variables
|
|
102
|
+
|
|
103
|
+
**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`). Instead, set them as environment variables in your operating system or shell configuration.
|
|
104
|
+
|
|
105
|
+
To enable write operations (transfers, contract calls) and ensure reliable API access, you should configure the following variables.
|
|
106
|
+
|
|
107
|
+
#### Network Configuration
|
|
108
|
+
|
|
109
|
+
- `TRONGRID_API_KEY`: (Optional) Your TronGrid API key.
|
|
110
|
+
- **Why**: TRON mainnet RPCs have strict rate limits. Using an API key from [TronGrid](https://www.trongrid.io/) ensures reliable performance and higher throughput.
|
|
111
|
+
- **Usage**:
|
|
112
|
+
```bash
|
|
113
|
+
export TRONGRID_API_KEY="<YOUR_TRONGRID_API_KEY_HERE>"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Wallet Configuration (Use Environment Variables)
|
|
117
|
+
|
|
118
|
+
**Option 1: Private Key**
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Recommended: Add this to your ~/.zshrc or ~/.bashrc
|
|
122
|
+
export TRON_PRIVATE_KEY="<YOUR_PRIVATE_KEY_HERE>"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Option 2: Mnemonic Phrase**
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Recommended: Add this to your ~/.zshrc or ~/.bashrc
|
|
129
|
+
export TRON_MNEMONIC="<WORD1> <WORD2> ... <WORD12>"
|
|
130
|
+
export TRON_ACCOUNT_INDEX="0" # Optional, default: 0
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Server Configuration
|
|
134
|
+
|
|
135
|
+
The server runs on port **3001** by default in HTTP mode.
|
|
136
|
+
|
|
137
|
+
## Usage
|
|
138
|
+
|
|
139
|
+
### Running Locally
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Start in stdio mode (for MCP clients like Claude Desktop/Cursor)
|
|
143
|
+
npm start
|
|
144
|
+
|
|
145
|
+
# Start in HTTP mode (Server-Sent Events)
|
|
146
|
+
npm run start:http
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Testing
|
|
150
|
+
|
|
151
|
+
The project includes a comprehensive test suite with unit tests and integration tests (using the Nile network).
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Run all tests
|
|
155
|
+
npm test
|
|
156
|
+
|
|
157
|
+
# Run specific test suites
|
|
158
|
+
npx vitest tests/core/tools.test.ts # Unit tests for tools
|
|
159
|
+
npx vitest tests/core/services/multicall.test.ts # Multicall integration
|
|
160
|
+
npx vitest tests/core/services/services.test.ts # Services integration
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Connecting from Cursor / Claude Desktop
|
|
164
|
+
|
|
165
|
+
Add the following to your MCP configuration file (e.g., `~/.config/Claude/claude_desktop_config.json` or `.cursor/mcp.json`).
|
|
166
|
+
|
|
167
|
+
**Important**: We recommend omitting the `env` section if you have already set these variables in your system environment. If your MCP client doesn't inherit system variables, use placeholders or ensure the config file is not shared or committed to version control.
|
|
168
|
+
|
|
169
|
+
**For local development (running from source):**
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"mcpServers": {
|
|
174
|
+
"tron-mcp-server": {
|
|
175
|
+
"command": "npx",
|
|
176
|
+
"args": ["tsx", "/ABSOLUTE/PATH/TO/tron-mcp-server/src/index.ts"],
|
|
177
|
+
"env": {
|
|
178
|
+
"TRON_PRIVATE_KEY": "<YOUR_PRIVATE_KEY_HERE>",
|
|
179
|
+
"TRONGRID_API_KEY": "<YOUR_TRONGRID_API_KEY_HERE>"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**For using the built package (if installed globally or via npx):**
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"mcpServers": {
|
|
191
|
+
"tron-mcp-server": {
|
|
192
|
+
"command": "npx",
|
|
193
|
+
"args": ["-y", "@sun-protocol/tron-mcp-server"],
|
|
194
|
+
"env": {
|
|
195
|
+
"TRON_PRIVATE_KEY": "<YOUR_PRIVATE_KEY_HERE>",
|
|
196
|
+
"TRONGRID_API_KEY": "<YOUR_TRONGRID_API_KEY_HERE>"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## API Reference
|
|
204
|
+
|
|
205
|
+
### Tools
|
|
206
|
+
|
|
207
|
+
#### Wallet & Address
|
|
208
|
+
|
|
209
|
+
- `get_wallet_address`: Get the configured wallet's address (Base58 & Hex).
|
|
210
|
+
- `convert_address`: Convert between Hex and Base58 formats.
|
|
211
|
+
|
|
212
|
+
#### Network & Resources
|
|
213
|
+
|
|
214
|
+
- `get_chain_info`: Get current block and chain ID.
|
|
215
|
+
- `get_chain_parameters`: Get current Energy and Bandwidth costs.
|
|
216
|
+
- `get_supported_networks`: List available networks.
|
|
217
|
+
|
|
218
|
+
#### Blocks & Transactions
|
|
219
|
+
|
|
220
|
+
- `get_block`: Fetch block by number or hash.
|
|
221
|
+
- `get_latest_block`: Get the latest block.
|
|
222
|
+
- `get_transaction`: Get transaction details.
|
|
223
|
+
- `get_transaction_info`: Get transaction receipt/info (including resource usage).
|
|
224
|
+
|
|
225
|
+
#### Balances
|
|
226
|
+
|
|
227
|
+
- `get_balance`: Get TRX balance.
|
|
228
|
+
- `get_token_balance`: Get TRC20 token balance.
|
|
229
|
+
|
|
230
|
+
#### Transfers (Write)
|
|
231
|
+
|
|
232
|
+
- `transfer_trx`: Send TRX.
|
|
233
|
+
- `transfer_trc20`: Send TRC20 tokens.
|
|
234
|
+
|
|
235
|
+
#### Smart Contracts
|
|
236
|
+
|
|
237
|
+
- `read_contract`: Call read-only contract functions.
|
|
238
|
+
- `multicall`: Execute multiple read-only functions in a single batch call.
|
|
239
|
+
- `write_contract`: Call state-changing contract functions.
|
|
240
|
+
|
|
241
|
+
#### Signing
|
|
242
|
+
|
|
243
|
+
- `sign_message`: Sign a text message with the configured wallet.
|
|
244
|
+
|
|
245
|
+
### Prompts
|
|
246
|
+
|
|
247
|
+
- `prepare_transfer`: Interactive guide to prepare TRX/TRC20 transfers.
|
|
248
|
+
- `diagnose_transaction`: Analyze a transaction hash for status and errors.
|
|
249
|
+
- `analyze_wallet`: Comprehensive report of wallet assets.
|
|
250
|
+
- `check_network_status`: Report on network health and resource costs.
|
|
251
|
+
|
|
252
|
+
## Security Considerations
|
|
253
|
+
|
|
254
|
+
- **Private Keys & Mnemonics**: **NEVER** save your sensitive wallet information in plain text configuration files (like `mcp.json`). These files are often unencrypted and can be accidentally shared or committed to git. Use system environment variables which are more secure.
|
|
255
|
+
- **Exposure**: If you are using a shared machine, be aware that environment variables might be visible to other users.
|
|
256
|
+
- **Testnets**: Always test on Nile or Shasta before performing operations on Mainnet.
|
|
257
|
+
- **Approvals**: Be cautious when approving token allowances via `write_contract`. Only approve what is necessary.
|
|
258
|
+
|
|
259
|
+
## Project Structure
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
tron-mcp-server/
|
|
263
|
+
├── src/
|
|
264
|
+
│ ├── core/
|
|
265
|
+
│ │ ├── chains.ts # Network definitions
|
|
266
|
+
│ │ ├── tools.ts # MCP Tool definitions
|
|
267
|
+
│ │ ├── prompts.ts # MCP Prompt definitions
|
|
268
|
+
│ │ └── services/ # Business logic (TronWeb integration)
|
|
269
|
+
│ │ ├── wallet.ts # Wallet management
|
|
270
|
+
│ │ ├── transfer.ts # Transfer logic
|
|
271
|
+
│ │ ├── contracts.ts # Contract logic
|
|
272
|
+
│ │ ├── address.ts # Address conversion
|
|
273
|
+
│ │ └── ...
|
|
274
|
+
│ ├── server/ # HTTP/Stdio server setup
|
|
275
|
+
│ └── index.ts # Entry point
|
|
276
|
+
├── tests/ # Unit tests
|
|
277
|
+
└── package.json
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## License
|
|
281
|
+
|
|
282
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { dirname, resolve } from "path";
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
|
|
12
|
+
// Parse command line arguments
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
const httpMode = args.includes("--http") || args.includes("-h");
|
|
15
|
+
|
|
16
|
+
console.error(`Starting TRON MCP Server in ${httpMode ? "HTTP" : "stdio"} mode...`);
|
|
17
|
+
|
|
18
|
+
// Determine which file to execute
|
|
19
|
+
const scriptPath = resolve(__dirname, "../build", httpMode ? "server/http-server.js" : "index.js");
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// Check if the built files exist
|
|
23
|
+
require.resolve(scriptPath);
|
|
24
|
+
|
|
25
|
+
// Execute the server
|
|
26
|
+
const server = spawn("node", [scriptPath], {
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
shell: false,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
server.on("error", (err) => {
|
|
32
|
+
console.error("Failed to start server:", err);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Handle clean shutdown
|
|
37
|
+
const cleanup = () => {
|
|
38
|
+
if (!server.killed) {
|
|
39
|
+
server.kill();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
process.on("SIGINT", cleanup);
|
|
44
|
+
process.on("SIGTERM", cleanup);
|
|
45
|
+
process.on("exit", cleanup);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error("Error: Server files not found. The package may not be built correctly.");
|
|
48
|
+
console.error("Please try reinstalling the package or contact the maintainers.");
|
|
49
|
+
console.error(error);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum TronNetwork {
|
|
2
|
+
Mainnet = "mainnet",
|
|
3
|
+
Nile = "nile",
|
|
4
|
+
Shasta = "shasta"
|
|
5
|
+
}
|
|
6
|
+
export interface NetworkConfig {
|
|
7
|
+
name: string;
|
|
8
|
+
fullNode: string;
|
|
9
|
+
solidityNode: string;
|
|
10
|
+
eventServer: string;
|
|
11
|
+
explorer: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const NETWORKS: Record<TronNetwork, NetworkConfig>;
|
|
14
|
+
export declare const DEFAULT_NETWORK = TronNetwork.Mainnet;
|
|
15
|
+
export declare function getNetworkConfig(network?: string): NetworkConfig;
|
|
16
|
+
export declare function getSupportedNetworks(): string[];
|
|
17
|
+
export declare function getRpcUrl(network?: string): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Tron Network Definitions
|
|
2
|
+
export var TronNetwork;
|
|
3
|
+
(function (TronNetwork) {
|
|
4
|
+
TronNetwork["Mainnet"] = "mainnet";
|
|
5
|
+
TronNetwork["Nile"] = "nile";
|
|
6
|
+
TronNetwork["Shasta"] = "shasta";
|
|
7
|
+
})(TronNetwork || (TronNetwork = {}));
|
|
8
|
+
export const NETWORKS = {
|
|
9
|
+
[TronNetwork.Mainnet]: {
|
|
10
|
+
name: "Mainnet",
|
|
11
|
+
fullNode: "https://api.trongrid.io",
|
|
12
|
+
solidityNode: "https://api.trongrid.io",
|
|
13
|
+
eventServer: "https://api.trongrid.io",
|
|
14
|
+
explorer: "https://tronscan.org",
|
|
15
|
+
},
|
|
16
|
+
[TronNetwork.Nile]: {
|
|
17
|
+
name: "Nile",
|
|
18
|
+
fullNode: "https://nile.trongrid.io",
|
|
19
|
+
solidityNode: "https://nile.trongrid.io",
|
|
20
|
+
eventServer: "https://nile.trongrid.io",
|
|
21
|
+
explorer: "https://nile.tronscan.org",
|
|
22
|
+
},
|
|
23
|
+
[TronNetwork.Shasta]: {
|
|
24
|
+
name: "Shasta",
|
|
25
|
+
fullNode: "https://api.shasta.trongrid.io",
|
|
26
|
+
solidityNode: "https://api.shasta.trongrid.io",
|
|
27
|
+
eventServer: "https://api.shasta.trongrid.io",
|
|
28
|
+
explorer: "https://shasta.tronscan.org",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export const DEFAULT_NETWORK = TronNetwork.Mainnet;
|
|
32
|
+
export function getNetworkConfig(network = DEFAULT_NETWORK) {
|
|
33
|
+
const normalizedNetwork = network.toLowerCase();
|
|
34
|
+
// Direct match
|
|
35
|
+
if (Object.values(TronNetwork).includes(normalizedNetwork)) {
|
|
36
|
+
return NETWORKS[normalizedNetwork];
|
|
37
|
+
}
|
|
38
|
+
// Aliases
|
|
39
|
+
if (normalizedNetwork === "tron" ||
|
|
40
|
+
normalizedNetwork === "trx" ||
|
|
41
|
+
normalizedNetwork === "mainnet") {
|
|
42
|
+
return NETWORKS[TronNetwork.Mainnet];
|
|
43
|
+
}
|
|
44
|
+
if (normalizedNetwork === "testnet") {
|
|
45
|
+
return NETWORKS[TronNetwork.Nile]; // Default testnet to Nile
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
48
|
+
}
|
|
49
|
+
export function getSupportedNetworks() {
|
|
50
|
+
return Object.values(TronNetwork);
|
|
51
|
+
}
|
|
52
|
+
export function getRpcUrl(network = DEFAULT_NETWORK) {
|
|
53
|
+
return getNetworkConfig(network).fullNode;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=chains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/core/chains.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,4BAAa,CAAA;IACb,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAUD,MAAM,CAAC,MAAM,QAAQ,GAAuC;IAC1D,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;QACrB,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,yBAAyB;QACnC,YAAY,EAAE,yBAAyB;QACvC,WAAW,EAAE,yBAAyB;QACtC,QAAQ,EAAE,sBAAsB;KACjC;IACD,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;QAClB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,0BAA0B;QACpC,YAAY,EAAE,0BAA0B;QACxC,WAAW,EAAE,0BAA0B;QACvC,QAAQ,EAAE,2BAA2B;KACtC;IACD,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,gCAAgC;QAC1C,YAAY,EAAE,gCAAgC;QAC9C,WAAW,EAAE,gCAAgC;QAC7C,QAAQ,EAAE,6BAA6B;KACxC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,CAAC;AAEnD,MAAM,UAAU,gBAAgB,CAAC,UAAkB,eAAe;IAChE,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAEhD,eAAe;IACf,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,iBAAgC,CAAC,EAAE,CAAC;QAC1E,OAAO,QAAQ,CAAC,iBAAgC,CAAC,CAAC;IACpD,CAAC;IAED,UAAU;IACV,IACE,iBAAiB,KAAK,MAAM;QAC5B,iBAAiB,KAAK,KAAK;QAC3B,iBAAiB,KAAK,SAAS,EAC/B,CAAC;QACD,OAAO,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B;IAC/D,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,UAAkB,eAAe;IACzD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
/**
|
|
3
|
+
* Register task-oriented prompts with the MCP server
|
|
4
|
+
*
|
|
5
|
+
* All prompts follow a consistent structure:
|
|
6
|
+
* - Clear objective statement
|
|
7
|
+
* - Step-by-step instructions
|
|
8
|
+
* - Expected outputs
|
|
9
|
+
* - Safety/security considerations
|
|
10
|
+
*
|
|
11
|
+
* Prompts guide the model through complex workflows that would otherwise
|
|
12
|
+
* require multiple tool calls in the correct sequence.
|
|
13
|
+
*
|
|
14
|
+
* @param server The MCP server instance
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerTRONPrompts(server: McpServer): void;
|