@ton/mcp 0.1.10 → 0.1.11
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 +72 -122
- package/dist/cli.js +753 -436
- package/dist/factory.d.ts.map +1 -1
- package/dist/index.cjs +656 -326
- package/dist/index.js +656 -326
- package/dist/serverless.cjs +31387 -23963
- package/dist/serverless.js +31387 -23963
- package/dist/services/McpWalletService.d.ts +7 -0
- package/dist/services/McpWalletService.d.ts.map +1 -1
- package/dist/tools/balance-tools.d.ts +6 -0
- package/dist/tools/balance-tools.d.ts.map +1 -1
- package/llms.txt +7 -4
- package/package.json +2 -2
- package/skills/SKILL.md +8 -7
package/README.md
CHANGED
|
@@ -4,26 +4,27 @@ A Model Context Protocol (MCP) server for TON blockchain wallet operations. Buil
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Balance Queries**: Check TON and Jetton balances,
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
7
|
+
- **Balance Queries**: Check TON and Jetton balances, view transaction history
|
|
8
|
+
- **Transfers**: Send TON, Jettons, and NFTs to any address
|
|
9
|
+
- **Swaps**: Get quotes for token swaps via DEX aggregators
|
|
10
|
+
- **NFTs**: List, inspect, and transfer NFTs
|
|
11
|
+
- **DNS**: Resolve `.ton` domains and reverse-lookup addresses
|
|
12
|
+
- **Known Jettons**: Built-in directory of popular tokens
|
|
13
13
|
- **Dual Transport**: Stdio (default) and HTTP server modes
|
|
14
|
-
- **Serverless Support**: Deploy to AWS Lambda, Vercel, etc.
|
|
15
14
|
|
|
16
15
|
## Quick Start
|
|
17
16
|
|
|
17
|
+
> **Note:** We currently do not support launch without a mnemonic or private key.
|
|
18
|
+
|
|
18
19
|
```bash
|
|
19
|
-
# Run
|
|
20
|
-
MNEMONIC="word1 word2 ...
|
|
20
|
+
# Run as stdio MCP server
|
|
21
|
+
MNEMONIC="word1 word2 ..." npx @ton/mcp
|
|
21
22
|
|
|
22
|
-
# Run as HTTP server
|
|
23
|
-
MNEMONIC="word1 word2 ...
|
|
23
|
+
# Run as HTTP server (port 3000)
|
|
24
|
+
MNEMONIC="word1 word2 ..." npx @ton/mcp --http
|
|
24
25
|
|
|
25
|
-
# Run on custom port
|
|
26
|
-
MNEMONIC="word1 word2 ...
|
|
26
|
+
# Run as HTTP server on custom port
|
|
27
|
+
MNEMONIC="word1 word2 ..." npx @ton/mcp --http 8080
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
## Usage with MCP Clients
|
|
@@ -37,50 +38,45 @@ Add to your MCP configuration:
|
|
|
37
38
|
"mcpServers": {
|
|
38
39
|
"ton": {
|
|
39
40
|
"command": "npx",
|
|
40
|
-
"args": ["@ton/mcp"],
|
|
41
|
+
"args": ["-y", "@ton/mcp"],
|
|
41
42
|
"env": {
|
|
42
|
-
"MNEMONIC": "word1 word2 ...
|
|
43
|
-
"
|
|
43
|
+
"MNEMONIC": "word1 word2 word3 ...",
|
|
44
|
+
"PRIVATE_KEY": "0xyour_private_key_here (optional, alternative to MNEMONIC)"
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
### HTTP
|
|
51
|
+
### HTTP mode
|
|
51
52
|
|
|
52
53
|
Start the server and point your MCP client to the endpoint:
|
|
53
54
|
|
|
54
55
|
```bash
|
|
55
|
-
MNEMONIC="..." npx @ton/mcp --http 3000
|
|
56
|
+
MNEMONIC="word1 word2 ..." npx @ton/mcp --http 3000
|
|
56
57
|
# MCP endpoint: http://localhost:3000/mcp
|
|
57
58
|
```
|
|
58
59
|
|
|
59
60
|
## Environment Variables
|
|
60
61
|
|
|
61
|
-
| Variable
|
|
62
|
-
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `TONCENTER_API_KEY
|
|
62
|
+
| Variable | Default | Description |
|
|
63
|
+
|-------------------|-----------|-------------------------------------------------------|
|
|
64
|
+
| `NETWORK` | `mainnet` | TON network (`mainnet` / `testnet`) |
|
|
65
|
+
| `MNEMONIC` | | Space-separated 24-word mnemonic phrase for wallet |
|
|
66
|
+
| `PRIVATE_KEY` | | Hex-encoded private key (alternative to mnemonic) |
|
|
67
|
+
| `WALLET_VERSION` | `v5r1` | Wallet version to use (`v5r1` or `v4r2`) |
|
|
68
|
+
| `TONCENTER_API_KEY`| | API key for Toncenter (optional, for higher rate limits)|
|
|
68
69
|
|
|
69
|
-
##
|
|
70
|
+
## Available Tools
|
|
70
71
|
|
|
71
|
-
###
|
|
72
|
-
Provide a `MNEMONIC` environment variable to use traditional wallet control with full signing capabilities.
|
|
72
|
+
### Wallet Info
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
1. Checks for existing keypair in `~/.ton/key.json`
|
|
77
|
-
2. If not found, requires `WALLET_ADDRESS` and generates a new keypair
|
|
78
|
-
3. Stores the keypair for future use
|
|
79
|
-
4. Uses this keypair to sign transactions (requires wallet to authorize the public key)
|
|
74
|
+
#### `get_wallet`
|
|
75
|
+
Get the current wallet address and network information.
|
|
80
76
|
|
|
81
|
-
|
|
77
|
+
**Returns:** Wallet address and network (`mainnet` or `testnet`)
|
|
82
78
|
|
|
83
|
-
### Balance &
|
|
79
|
+
### Balance & History
|
|
84
80
|
|
|
85
81
|
#### `get_balance`
|
|
86
82
|
Get the TON balance of the wallet.
|
|
@@ -88,126 +84,103 @@ Get the TON balance of the wallet.
|
|
|
88
84
|
**Returns:** Balance in TON and nanoTON
|
|
89
85
|
|
|
90
86
|
#### `get_jetton_balance`
|
|
91
|
-
Get the balance of a specific Jetton.
|
|
87
|
+
Get the balance of a specific Jetton in the wallet.
|
|
92
88
|
|
|
93
89
|
**Parameters:**
|
|
94
90
|
- `jettonAddress` (required): Jetton master contract address
|
|
95
91
|
|
|
96
92
|
#### `get_jettons`
|
|
97
|
-
List all Jettons
|
|
93
|
+
List all Jettons held by the wallet with balances and metadata.
|
|
98
94
|
|
|
99
95
|
#### `get_transactions`
|
|
100
|
-
Get recent transaction history.
|
|
96
|
+
Get recent transaction history for the wallet (TON transfers, Jetton transfers, swaps, etc.).
|
|
101
97
|
|
|
102
98
|
**Parameters:**
|
|
103
|
-
- `limit` (optional):
|
|
104
|
-
|
|
105
|
-
**Returns:** Transaction events including TON transfers, Jetton transfers, swaps
|
|
106
|
-
|
|
107
|
-
#### `get_known_jettons`
|
|
108
|
-
Get a list of known/popular Jettons on TON with their addresses and metadata.
|
|
99
|
+
- `limit` (optional): Maximum number of transactions to return (default: 20, max: 100)
|
|
109
100
|
|
|
110
101
|
### Transfers
|
|
111
102
|
|
|
112
103
|
#### `send_ton`
|
|
113
|
-
Send TON to an address.
|
|
104
|
+
Send TON to an address. Amount is in human-readable format (e.g., `"1.5"` means 1.5 TON).
|
|
114
105
|
|
|
115
106
|
**Parameters:**
|
|
116
107
|
- `toAddress` (required): Recipient TON address
|
|
117
|
-
- `amount` (required): Amount in TON (e.g., "1.5"
|
|
108
|
+
- `amount` (required): Amount in TON (e.g., `"1.5"`)
|
|
118
109
|
- `comment` (optional): Transaction comment/memo
|
|
119
110
|
|
|
120
111
|
#### `send_jetton`
|
|
121
|
-
Send Jettons to an address.
|
|
112
|
+
Send Jettons to an address. Amount is in human-readable format.
|
|
122
113
|
|
|
123
114
|
**Parameters:**
|
|
124
115
|
- `toAddress` (required): Recipient TON address
|
|
125
116
|
- `jettonAddress` (required): Jetton master contract address
|
|
126
|
-
- `amount` (required): Amount in human-readable format
|
|
117
|
+
- `amount` (required): Amount in human-readable format (e.g., `"100"`)
|
|
127
118
|
- `comment` (optional): Transaction comment/memo
|
|
128
119
|
|
|
129
120
|
#### `send_raw_transaction`
|
|
130
|
-
Send a raw transaction with full control over messages.
|
|
121
|
+
Send a raw transaction with full control over messages. Supports multiple messages in a single transaction.
|
|
131
122
|
|
|
132
123
|
**Parameters:**
|
|
133
|
-
- `messages` (required): Array of messages
|
|
134
|
-
- `
|
|
124
|
+
- `messages` (required): Array of messages, each with:
|
|
125
|
+
- `address` (required): Recipient wallet address
|
|
126
|
+
- `amount` (required): Amount in nanotons
|
|
127
|
+
- `stateInit` (optional): Initial state for deploying a contract (Base64)
|
|
128
|
+
- `payload` (optional): Message payload data (Base64)
|
|
129
|
+
- `validUntil` (optional): Unix timestamp after which the transaction becomes invalid
|
|
135
130
|
- `fromAddress` (optional): Sender wallet address
|
|
136
131
|
|
|
137
132
|
### Swaps
|
|
138
133
|
|
|
139
134
|
#### `get_swap_quote`
|
|
140
|
-
Get a quote for swapping tokens.
|
|
135
|
+
Get a quote for swapping tokens. Returns quote details and transaction params that can be executed via `send_raw_transaction`.
|
|
141
136
|
|
|
142
137
|
**Parameters:**
|
|
143
|
-
- `fromToken` (required): Token to swap from ("TON" or jetton address)
|
|
144
|
-
- `toToken` (required): Token to swap to ("TON" or jetton address)
|
|
145
|
-
- `amount` (required): Amount
|
|
138
|
+
- `fromToken` (required): Token to swap from (`"TON"` or jetton address)
|
|
139
|
+
- `toToken` (required): Token to swap to (`"TON"` or jetton address)
|
|
140
|
+
- `amount` (required): Amount in human-readable format (e.g., `"1.5"` for 1.5 TON)
|
|
146
141
|
- `slippageBps` (optional): Slippage tolerance in basis points (default: 100 = 1%)
|
|
147
142
|
|
|
148
|
-
**Returns:** Quote details and transaction params for `send_raw_transaction`
|
|
149
|
-
|
|
150
143
|
### NFTs
|
|
151
144
|
|
|
152
145
|
#### `get_nfts`
|
|
153
|
-
List all NFTs in the wallet.
|
|
146
|
+
List all NFTs in the wallet with metadata, collection info, and attributes.
|
|
154
147
|
|
|
155
148
|
**Parameters:**
|
|
156
|
-
- `limit` (optional):
|
|
157
|
-
- `offset` (optional):
|
|
149
|
+
- `limit` (optional): Maximum number of NFTs to return (default: 20, max: 100)
|
|
150
|
+
- `offset` (optional): Offset for pagination (default: 0)
|
|
158
151
|
|
|
159
152
|
#### `get_nft`
|
|
160
|
-
Get detailed information about a specific NFT.
|
|
153
|
+
Get detailed information about a specific NFT by its address.
|
|
161
154
|
|
|
162
155
|
**Parameters:**
|
|
163
156
|
- `nftAddress` (required): NFT item contract address
|
|
164
157
|
|
|
165
158
|
#### `send_nft`
|
|
166
|
-
Transfer an NFT to another address.
|
|
159
|
+
Transfer an NFT from the wallet to another address.
|
|
167
160
|
|
|
168
161
|
**Parameters:**
|
|
169
|
-
- `nftAddress` (required): NFT item contract address
|
|
162
|
+
- `nftAddress` (required): NFT item contract address to transfer
|
|
170
163
|
- `toAddress` (required): Recipient TON address
|
|
171
164
|
- `comment` (optional): Transaction comment/memo
|
|
172
165
|
|
|
173
166
|
### DNS
|
|
174
167
|
|
|
175
168
|
#### `resolve_dns`
|
|
176
|
-
Resolve a TON DNS domain to a wallet address.
|
|
169
|
+
Resolve a TON DNS domain (e.g., `"foundation.ton"`) to a wallet address.
|
|
177
170
|
|
|
178
171
|
**Parameters:**
|
|
179
|
-
- `domain` (required): TON DNS domain
|
|
172
|
+
- `domain` (required): TON DNS domain to resolve
|
|
180
173
|
|
|
181
174
|
#### `back_resolve_dns`
|
|
182
|
-
Reverse
|
|
175
|
+
Reverse-resolve a TON wallet address to its `.ton` domain.
|
|
183
176
|
|
|
184
177
|
**Parameters:**
|
|
185
|
-
- `address` (required): TON wallet address
|
|
186
|
-
|
|
187
|
-
## Serverless Deployment
|
|
188
|
-
|
|
189
|
-
The package exports a serverless handler for deployment to AWS Lambda, Vercel, etc.
|
|
190
|
-
|
|
191
|
-
```typescript
|
|
192
|
-
// AWS Lambda
|
|
193
|
-
import { createServerlessHandler } from '@ton/mcp/serverless';
|
|
194
|
-
export const handler = createServerlessHandler();
|
|
195
|
-
|
|
196
|
-
// Vercel
|
|
197
|
-
import { createServerlessHandler } from '@ton/mcp/serverless';
|
|
198
|
-
export default createServerlessHandler();
|
|
199
|
-
```
|
|
178
|
+
- `address` (required): TON wallet address to reverse resolve
|
|
200
179
|
|
|
201
|
-
###
|
|
180
|
+
### Utility
|
|
202
181
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
| Header | Description |
|
|
206
|
-
|--------|-------------|
|
|
207
|
-
| `MNEMONIC` or `mnemonic` | 24-word mnemonic phrase |
|
|
208
|
-
| `PRIVATE_KEY` or `private-key` | Hex-encoded private key (priority over mnemonic) |
|
|
209
|
-
| `NETWORK` or `network` | Network (`mainnet` / `testnet`) |
|
|
210
|
-
| `TONCENTER_KEY` or `toncenter-key` | Optional TonCenter API key |
|
|
182
|
+
#### `get_known_jettons`
|
|
183
|
+
Get a list of known/popular Jettons on TON with their addresses and metadata. Useful for looking up token addresses for swaps or transfers.
|
|
211
184
|
|
|
212
185
|
## Development
|
|
213
186
|
|
|
@@ -228,55 +201,32 @@ node packages/mcp/dist/cli.js --http 8080
|
|
|
228
201
|
|
|
229
202
|
## Library Usage
|
|
230
203
|
|
|
231
|
-
The package exports a programmatic API for building custom MCP servers:
|
|
204
|
+
The package also exports a programmatic API for building custom MCP servers:
|
|
232
205
|
|
|
233
206
|
```typescript
|
|
234
207
|
import { createTonWalletMCP } from '@ton/mcp';
|
|
235
|
-
import { Signer, WalletV5R1Adapter, TonWalletKit,
|
|
208
|
+
import { Signer, WalletV5R1Adapter, TonWalletKit, MemoryStorageAdapter, Network } from '@ton/walletkit';
|
|
236
209
|
|
|
237
|
-
// Initialize
|
|
210
|
+
// Initialize TonWalletKit
|
|
211
|
+
const network = Network.mainnet();
|
|
238
212
|
const kit = new TonWalletKit({
|
|
239
|
-
networks: { [
|
|
213
|
+
networks: { [network.chainId]: {} },
|
|
240
214
|
storage: new MemoryStorageAdapter(),
|
|
241
215
|
});
|
|
242
216
|
await kit.waitForReady();
|
|
243
217
|
|
|
244
|
-
// Create wallet
|
|
218
|
+
// Create wallet from mnemonic
|
|
245
219
|
const signer = await Signer.fromMnemonic(mnemonic, { type: 'ton' });
|
|
246
220
|
const walletAdapter = await WalletV5R1Adapter.create(signer, {
|
|
247
|
-
client: kit.getApiClient(
|
|
248
|
-
network
|
|
221
|
+
client: kit.getApiClient(network),
|
|
222
|
+
network,
|
|
249
223
|
});
|
|
250
224
|
const wallet = await kit.addWallet(walletAdapter);
|
|
251
225
|
|
|
252
226
|
// Create MCP server
|
|
253
227
|
const server = await createTonWalletMCP({ wallet });
|
|
254
|
-
|
|
255
|
-
// Connect to transport
|
|
256
|
-
const transport = new StdioServerTransport();
|
|
257
|
-
await server.connect(transport);
|
|
258
228
|
```
|
|
259
229
|
|
|
260
|
-
## Agent Skills
|
|
261
|
-
|
|
262
|
-
This package includes skill files for AI agent integration:
|
|
263
|
-
|
|
264
|
-
- **`skills/SKILL.md`** - Concise skill description for Claude Code and compatible agents
|
|
265
|
-
- **`llms.txt`** - Detailed tool documentation for LLM context
|
|
266
|
-
|
|
267
|
-
### Using with Claude Code
|
|
268
|
-
|
|
269
|
-
Copy the skill to your project:
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
mkdir -p .claude/skills/ton-wallet
|
|
273
|
-
cp node_modules/@ton/mcp/skills/SKILL.md .claude/skills/ton-wallet/
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### Using llms.txt
|
|
277
|
-
|
|
278
|
-
The `llms.txt` file follows the [llms.txt standard](https://llmstxt.org/) and can be used to provide context to any LLM about the available tools.
|
|
279
|
-
|
|
280
230
|
## License
|
|
281
231
|
|
|
282
232
|
MIT
|