@ton/mcp 0.1.10
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/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +89425 -0
- package/dist/contracts/w5_ownable/WalletOwnable.d.ts +87 -0
- package/dist/contracts/w5_ownable/WalletOwnable.d.ts.map +1 -0
- package/dist/contracts/w5_ownable/WalletOwnable.source.d.ts +11 -0
- package/dist/contracts/w5_ownable/WalletOwnable.source.d.ts.map +1 -0
- package/dist/contracts/w5_ownable/WalletOwnableAdapter.d.ts +111 -0
- package/dist/contracts/w5_ownable/WalletOwnableAdapter.d.ts.map +1 -0
- package/dist/contracts/w5_ownable/actions.d.ts +43 -0
- package/dist/contracts/w5_ownable/actions.d.ts.map +1 -0
- package/dist/contracts/w5_ownable/index.d.ts +12 -0
- package/dist/contracts/w5_ownable/index.d.ts.map +1 -0
- package/dist/factory.d.ts +67 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/index.cjs +89134 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +89131 -0
- package/dist/serverless.cjs +108356 -0
- package/dist/serverless.d.ts +38 -0
- package/dist/serverless.d.ts.map +1 -0
- package/dist/serverless.js +108355 -0
- package/dist/services/KeyManager.d.ts +57 -0
- package/dist/services/KeyManager.d.ts.map +1 -0
- package/dist/services/McpWalletService.d.ts +202 -0
- package/dist/services/McpWalletService.d.ts.map +1 -0
- package/dist/tools/balance-tools.d.ts +61 -0
- package/dist/tools/balance-tools.d.ts.map +1 -0
- package/dist/tools/dns-tools.d.ts +49 -0
- package/dist/tools/dns-tools.d.ts.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/known-jettons-tools.d.ts +44 -0
- package/dist/tools/known-jettons-tools.d.ts.map +1 -0
- package/dist/tools/nft-tools.d.ts +85 -0
- package/dist/tools/nft-tools.d.ts.map +1 -0
- package/dist/tools/swap-tools.d.ts +49 -0
- package/dist/tools/swap-tools.d.ts.map +1 -0
- package/dist/tools/transfer-tools.d.ts +159 -0
- package/dist/tools/transfer-tools.d.ts.map +1 -0
- package/dist/tools/types.d.ts +21 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/types/config.d.ts +41 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/contacts.d.ts +61 -0
- package/dist/types/contacts.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/llms.txt +114 -0
- package/package.json +86 -0
- package/skills/SKILL.md +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 TonTech
|
|
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
|
+
# @ton/mcp - TON MCP Server
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server for TON blockchain wallet operations. Built on top of `@ton/walletkit`.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
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
|
|
13
|
+
- **Dual Transport**: Stdio (default) and HTTP server modes
|
|
14
|
+
- **Serverless Support**: Deploy to AWS Lambda, Vercel, etc.
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Run with mnemonic (full control)
|
|
20
|
+
MNEMONIC="word1 word2 ... word24" npx @ton/mcp
|
|
21
|
+
|
|
22
|
+
# Run as HTTP server
|
|
23
|
+
MNEMONIC="word1 word2 ... word24" npx @ton/mcp --http
|
|
24
|
+
|
|
25
|
+
# Run on custom port and host
|
|
26
|
+
MNEMONIC="word1 word2 ... word24" npx @ton/mcp --http 8080 --host 127.0.0.1
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage with MCP Clients
|
|
30
|
+
|
|
31
|
+
### Claude Desktop / Cursor
|
|
32
|
+
|
|
33
|
+
Add to your MCP configuration:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"ton": {
|
|
39
|
+
"command": "npx",
|
|
40
|
+
"args": ["@ton/mcp"],
|
|
41
|
+
"env": {
|
|
42
|
+
"MNEMONIC": "word1 word2 ... word24",
|
|
43
|
+
"NETWORK": "mainnet"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### HTTP Mode
|
|
51
|
+
|
|
52
|
+
Start the server and point your MCP client to the endpoint:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
MNEMONIC="..." npx @ton/mcp --http 3000
|
|
56
|
+
# MCP endpoint: http://localhost:3000/mcp
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Environment Variables
|
|
60
|
+
|
|
61
|
+
| Variable | Default | Description |
|
|
62
|
+
|----------|---------|-------------|
|
|
63
|
+
| `MNEMONIC` | - | 24-word mnemonic phrase (required for mnemonic mode) |
|
|
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 |
|
|
68
|
+
|
|
69
|
+
## Wallet Modes
|
|
70
|
+
|
|
71
|
+
### Mnemonic Mode (Default)
|
|
72
|
+
Provide a `MNEMONIC` environment variable to use traditional wallet control with full signing capabilities.
|
|
73
|
+
|
|
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)
|
|
80
|
+
|
|
81
|
+
## Available Tools
|
|
82
|
+
|
|
83
|
+
### Balance & Info
|
|
84
|
+
|
|
85
|
+
#### `get_balance`
|
|
86
|
+
Get the TON balance of the wallet.
|
|
87
|
+
|
|
88
|
+
**Returns:** Balance in TON and nanoTON
|
|
89
|
+
|
|
90
|
+
#### `get_jetton_balance`
|
|
91
|
+
Get the balance of a specific Jetton.
|
|
92
|
+
|
|
93
|
+
**Parameters:**
|
|
94
|
+
- `jettonAddress` (required): Jetton master contract address
|
|
95
|
+
|
|
96
|
+
#### `get_jettons`
|
|
97
|
+
List all Jettons in the wallet with balances and metadata.
|
|
98
|
+
|
|
99
|
+
#### `get_transactions`
|
|
100
|
+
Get recent transaction history.
|
|
101
|
+
|
|
102
|
+
**Parameters:**
|
|
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.
|
|
109
|
+
|
|
110
|
+
### Transfers
|
|
111
|
+
|
|
112
|
+
#### `send_ton`
|
|
113
|
+
Send TON to an address.
|
|
114
|
+
|
|
115
|
+
**Parameters:**
|
|
116
|
+
- `toAddress` (required): Recipient TON address
|
|
117
|
+
- `amount` (required): Amount in TON (e.g., "1.5" for 1.5 TON)
|
|
118
|
+
- `comment` (optional): Transaction comment/memo
|
|
119
|
+
|
|
120
|
+
#### `send_jetton`
|
|
121
|
+
Send Jettons to an address.
|
|
122
|
+
|
|
123
|
+
**Parameters:**
|
|
124
|
+
- `toAddress` (required): Recipient TON address
|
|
125
|
+
- `jettonAddress` (required): Jetton master contract address
|
|
126
|
+
- `amount` (required): Amount in human-readable format
|
|
127
|
+
- `comment` (optional): Transaction comment/memo
|
|
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
|
+
|
|
137
|
+
### Swaps
|
|
138
|
+
|
|
139
|
+
#### `get_swap_quote`
|
|
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.
|
|
161
|
+
|
|
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 |
|
|
211
|
+
|
|
212
|
+
## Development
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Run from source (stdio)
|
|
216
|
+
pnpm --filter @ton/mcp dev:cli
|
|
217
|
+
|
|
218
|
+
# Run from source (HTTP)
|
|
219
|
+
pnpm --filter @ton/mcp dev:cli:http
|
|
220
|
+
|
|
221
|
+
# Build
|
|
222
|
+
pnpm --filter @ton/mcp build
|
|
223
|
+
|
|
224
|
+
# Run built version
|
|
225
|
+
node packages/mcp/dist/cli.js
|
|
226
|
+
node packages/mcp/dist/cli.js --http 8080
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Library Usage
|
|
230
|
+
|
|
231
|
+
The package exports a programmatic API for building custom MCP servers:
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
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(),
|
|
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);
|
|
258
|
+
```
|
|
259
|
+
|
|
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
|
+
## License
|
|
281
|
+
|
|
282
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|