@truecarry/mcp 0.1.7 → 0.1.8
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 +153 -66
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,23 +4,26 @@ A Model Context Protocol (MCP) server for TON blockchain wallet operations. Buil
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **Transfers**: Send TON
|
|
10
|
-
- **Swaps**: Get quotes and execute token swaps
|
|
7
|
+
- **Balance Queries**: Check TON and Jetton balances, list all tokens
|
|
8
|
+
- **Transaction History**: View recent transactions with detailed info
|
|
9
|
+
- **Transfers**: Send TON, Jettons, and NFTs
|
|
10
|
+
- **Swaps**: Get quotes and execute token swaps via DEX
|
|
11
|
+
- **NFT Support**: List, view details, and transfer NFTs
|
|
12
|
+
- **DNS Resolution**: Resolve .ton domains and reverse lookup addresses
|
|
11
13
|
- **Dual Transport**: Stdio (default) and HTTP server modes
|
|
14
|
+
- **Serverless Support**: Deploy to AWS Lambda, Vercel, etc.
|
|
12
15
|
|
|
13
16
|
## Quick Start
|
|
14
17
|
|
|
15
18
|
```bash
|
|
16
|
-
# Run
|
|
17
|
-
npx @ton/mcp
|
|
19
|
+
# Run with mnemonic (full control)
|
|
20
|
+
MNEMONIC="word1 word2 ... word24" npx @ton/mcp
|
|
18
21
|
|
|
19
|
-
# Run as HTTP server
|
|
20
|
-
npx @ton/mcp --http
|
|
22
|
+
# Run as HTTP server
|
|
23
|
+
MNEMONIC="word1 word2 ... word24" npx @ton/mcp --http
|
|
21
24
|
|
|
22
|
-
# Run
|
|
23
|
-
npx @ton/mcp --http 8080
|
|
25
|
+
# Run on custom port and host
|
|
26
|
+
MNEMONIC="word1 word2 ... word24" npx @ton/mcp --http 8080 --host 127.0.0.1
|
|
24
27
|
```
|
|
25
28
|
|
|
26
29
|
## Usage with MCP Clients
|
|
@@ -34,79 +37,75 @@ Add to your MCP configuration:
|
|
|
34
37
|
"mcpServers": {
|
|
35
38
|
"ton": {
|
|
36
39
|
"command": "npx",
|
|
37
|
-
"args": ["@ton/mcp"]
|
|
40
|
+
"args": ["@ton/mcp"],
|
|
41
|
+
"env": {
|
|
42
|
+
"MNEMONIC": "word1 word2 ... word24",
|
|
43
|
+
"NETWORK": "mainnet"
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
```
|
|
42
49
|
|
|
43
|
-
### HTTP
|
|
50
|
+
### HTTP Mode
|
|
44
51
|
|
|
45
52
|
Start the server and point your MCP client to the endpoint:
|
|
46
53
|
|
|
47
54
|
```bash
|
|
48
|
-
npx @ton/mcp --http 3000
|
|
55
|
+
MNEMONIC="..." npx @ton/mcp --http 3000
|
|
49
56
|
# MCP endpoint: http://localhost:3000/mcp
|
|
50
57
|
```
|
|
51
58
|
|
|
52
59
|
## Environment Variables
|
|
53
60
|
|
|
54
|
-
| Variable
|
|
55
|
-
|
|
61
|
+
| Variable | Default | Description |
|
|
62
|
+
|----------|---------|-------------|
|
|
63
|
+
| `MNEMONIC` | - | 24-word mnemonic phrase (required for mnemonic mode) |
|
|
56
64
|
| `NETWORK` | `mainnet` | TON network (`mainnet` / `testnet`) |
|
|
65
|
+
| `WALLET_VERSION` | `v5r1` | Wallet version (`v5r1` / `v4r2`) |
|
|
66
|
+
| `WALLET_ADDRESS` | - | User's wallet address (for controlled wallet mode) |
|
|
67
|
+
| `TONCENTER_API_KEY` | - | Optional TonCenter API key for higher rate limits |
|
|
57
68
|
|
|
58
|
-
##
|
|
59
|
-
|
|
60
|
-
### Wallet Management
|
|
61
|
-
|
|
62
|
-
#### `create_wallet`
|
|
63
|
-
Create a new TON wallet with a generated 24-word mnemonic.
|
|
64
|
-
|
|
65
|
-
**Parameters:**
|
|
66
|
-
- `name` (required): Unique name for the wallet
|
|
67
|
-
- `version` (optional): Wallet version - `v5r1` (default, recommended) or `v4r2`
|
|
68
|
-
|
|
69
|
-
**Returns:** Wallet address and mnemonic (save securely!)
|
|
70
|
-
|
|
71
|
-
#### `import_wallet`
|
|
72
|
-
Import an existing wallet using a mnemonic phrase.
|
|
69
|
+
## Wallet Modes
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- `mnemonic` (required): 24-word mnemonic phrase (space-separated)
|
|
77
|
-
- `version` (optional): Wallet version - `v5r1` (default) or `v4r2`
|
|
78
|
-
|
|
79
|
-
#### `list_wallets`
|
|
80
|
-
List all stored wallets with their addresses and metadata.
|
|
71
|
+
### Mnemonic Mode (Default)
|
|
72
|
+
Provide a `MNEMONIC` environment variable to use traditional wallet control with full signing capabilities.
|
|
81
73
|
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
### Controlled Wallet Mode
|
|
75
|
+
When `MNEMONIC` is not provided, the MCP operates in controlled wallet mode:
|
|
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)
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
- `name` (required): Name of the wallet to remove
|
|
81
|
+
## Available Tools
|
|
87
82
|
|
|
88
|
-
### Balance
|
|
83
|
+
### Balance & Info
|
|
89
84
|
|
|
90
85
|
#### `get_balance`
|
|
91
|
-
Get the TON balance
|
|
86
|
+
Get the TON balance of the wallet.
|
|
92
87
|
|
|
93
|
-
**
|
|
94
|
-
- `wallet` (required): Name of the wallet
|
|
95
|
-
|
|
96
|
-
**Returns:** Balance in nanoTON and TON
|
|
88
|
+
**Returns:** Balance in TON and nanoTON
|
|
97
89
|
|
|
98
90
|
#### `get_jetton_balance`
|
|
99
91
|
Get the balance of a specific Jetton.
|
|
100
92
|
|
|
101
93
|
**Parameters:**
|
|
102
|
-
- `wallet` (required): Name of the wallet
|
|
103
94
|
- `jettonAddress` (required): Jetton master contract address
|
|
104
95
|
|
|
105
96
|
#### `get_jettons`
|
|
106
|
-
List all Jettons
|
|
97
|
+
List all Jettons in the wallet with balances and metadata.
|
|
98
|
+
|
|
99
|
+
#### `get_transactions`
|
|
100
|
+
Get recent transaction history.
|
|
107
101
|
|
|
108
102
|
**Parameters:**
|
|
109
|
-
- `
|
|
103
|
+
- `limit` (optional): Max transactions to return (default: 20, max: 100)
|
|
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.
|
|
110
109
|
|
|
111
110
|
### Transfers
|
|
112
111
|
|
|
@@ -114,28 +113,101 @@ List all Jettons held by a wallet.
|
|
|
114
113
|
Send TON to an address.
|
|
115
114
|
|
|
116
115
|
**Parameters:**
|
|
117
|
-
- `wallet` (required): Name of the wallet to send from
|
|
118
116
|
- `toAddress` (required): Recipient TON address
|
|
119
|
-
- `amount` (required): Amount in
|
|
117
|
+
- `amount` (required): Amount in TON (e.g., "1.5" for 1.5 TON)
|
|
120
118
|
- `comment` (optional): Transaction comment/memo
|
|
121
119
|
|
|
122
120
|
#### `send_jetton`
|
|
123
121
|
Send Jettons to an address.
|
|
124
122
|
|
|
125
123
|
**Parameters:**
|
|
126
|
-
- `wallet` (required): Name of the wallet to send from
|
|
127
124
|
- `toAddress` (required): Recipient TON address
|
|
128
125
|
- `jettonAddress` (required): Jetton master contract address
|
|
129
|
-
- `amount` (required): Amount in
|
|
126
|
+
- `amount` (required): Amount in human-readable format
|
|
130
127
|
- `comment` (optional): Transaction comment/memo
|
|
131
128
|
|
|
129
|
+
#### `send_raw_transaction`
|
|
130
|
+
Send a raw transaction with full control over messages.
|
|
131
|
+
|
|
132
|
+
**Parameters:**
|
|
133
|
+
- `messages` (required): Array of messages with `address`, `amount` (nanoTON), optional `stateInit` and `payload` (Base64)
|
|
134
|
+
- `validUntil` (optional): Unix timestamp for transaction expiry
|
|
135
|
+
- `fromAddress` (optional): Sender wallet address
|
|
136
|
+
|
|
132
137
|
### Swaps
|
|
133
138
|
|
|
134
139
|
#### `get_swap_quote`
|
|
135
|
-
Get a quote for
|
|
140
|
+
Get a quote for swapping tokens.
|
|
141
|
+
|
|
142
|
+
**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 to swap in raw units
|
|
146
|
+
- `slippageBps` (optional): Slippage tolerance in basis points (default: 100 = 1%)
|
|
147
|
+
|
|
148
|
+
**Returns:** Quote details and transaction params for `send_raw_transaction`
|
|
149
|
+
|
|
150
|
+
### NFTs
|
|
151
|
+
|
|
152
|
+
#### `get_nfts`
|
|
153
|
+
List all NFTs in the wallet.
|
|
154
|
+
|
|
155
|
+
**Parameters:**
|
|
156
|
+
- `limit` (optional): Max NFTs to return (default: 20, max: 100)
|
|
157
|
+
- `offset` (optional): Pagination offset (default: 0)
|
|
158
|
+
|
|
159
|
+
#### `get_nft`
|
|
160
|
+
Get detailed information about a specific NFT.
|
|
136
161
|
|
|
137
|
-
|
|
138
|
-
|
|
162
|
+
**Parameters:**
|
|
163
|
+
- `nftAddress` (required): NFT item contract address
|
|
164
|
+
|
|
165
|
+
#### `send_nft`
|
|
166
|
+
Transfer an NFT to another address.
|
|
167
|
+
|
|
168
|
+
**Parameters:**
|
|
169
|
+
- `nftAddress` (required): NFT item contract address
|
|
170
|
+
- `toAddress` (required): Recipient TON address
|
|
171
|
+
- `comment` (optional): Transaction comment/memo
|
|
172
|
+
|
|
173
|
+
### DNS
|
|
174
|
+
|
|
175
|
+
#### `resolve_dns`
|
|
176
|
+
Resolve a TON DNS domain to a wallet address.
|
|
177
|
+
|
|
178
|
+
**Parameters:**
|
|
179
|
+
- `domain` (required): TON DNS domain (e.g., "foundation.ton")
|
|
180
|
+
|
|
181
|
+
#### `back_resolve_dns`
|
|
182
|
+
Reverse resolve a wallet address to its DNS domain.
|
|
183
|
+
|
|
184
|
+
**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
|
+
```
|
|
200
|
+
|
|
201
|
+
### Serverless Headers
|
|
202
|
+
|
|
203
|
+
Pass credentials via request headers:
|
|
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 |
|
|
139
211
|
|
|
140
212
|
## Development
|
|
141
213
|
|
|
@@ -156,18 +228,33 @@ node packages/mcp/dist/cli.js --http 8080
|
|
|
156
228
|
|
|
157
229
|
## Library Usage
|
|
158
230
|
|
|
159
|
-
The package
|
|
231
|
+
The package exports a programmatic API for building custom MCP servers:
|
|
160
232
|
|
|
161
233
|
```typescript
|
|
162
|
-
import { createTonWalletMCP
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
234
|
+
import { createTonWalletMCP } from '@ton/mcp';
|
|
235
|
+
import { Signer, WalletV5R1Adapter, TonWalletKit, Network, MemoryStorageAdapter } from '@ton/walletkit';
|
|
236
|
+
|
|
237
|
+
// Initialize kit
|
|
238
|
+
const kit = new TonWalletKit({
|
|
239
|
+
networks: { [Network.mainnet().chainId]: {} },
|
|
240
|
+
storage: new MemoryStorageAdapter(),
|
|
241
|
+
});
|
|
242
|
+
await kit.waitForReady();
|
|
243
|
+
|
|
244
|
+
// Create wallet adapter
|
|
245
|
+
const signer = await Signer.fromMnemonic(mnemonic, { type: 'ton' });
|
|
246
|
+
const walletAdapter = await WalletV5R1Adapter.create(signer, {
|
|
247
|
+
client: kit.getApiClient(Network.mainnet()),
|
|
248
|
+
network: Network.mainnet(),
|
|
170
249
|
});
|
|
250
|
+
const wallet = await kit.addWallet(walletAdapter);
|
|
251
|
+
|
|
252
|
+
// Create MCP server
|
|
253
|
+
const server = await createTonWalletMCP({ wallet });
|
|
254
|
+
|
|
255
|
+
// Connect to transport
|
|
256
|
+
const transport = new StdioServerTransport();
|
|
257
|
+
await server.connect(transport);
|
|
171
258
|
```
|
|
172
259
|
|
|
173
260
|
## License
|