@ton/mcp 0.1.15-alpha.7 → 0.1.15-alpha.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 CHANGED
@@ -20,6 +20,8 @@ A Model Context Protocol (MCP) server for TON blockchain wallet operations. Buil
20
20
  - **Agentic Wallets mode**: Server starts from local config registry at `~/.config/ton/config.json` or `TON_CONFIG_PATH`
21
21
  - **Single-wallet mode**: if `MNEMONIC` or `PRIVATE_KEY` is set, the server starts with one in-memory wallet
22
22
 
23
+ Choose one control path per task: either run `@ton/mcp` as an MCP server (stdio or HTTP) or call tools through raw CLI. Agents must not mix MCP server mode and raw CLI against the same workflow/session, because that creates competing control paths over the same wallet/config state.
24
+
23
25
  ### Agentic Wallets mode
24
26
 
25
27
  Self-custody wallets for autonomous agents. Your AI agent gets TON wallet capabilities — transfers, swaps, NFTs. User keeps the master key, agent keeps the operator key.
@@ -106,6 +108,10 @@ npx @ton/mcp@alpha --http 3000
106
108
 
107
109
  HTTP mode keeps a separate MCP session/transport per client session id, so multiple clients can initialize and reconnect independently.
108
110
 
111
+ ## Usage Examples
112
+
113
+ Examples of user requests, approximate corresponding raw CLI commands via `npx @ton/mcp@alpha`, and expected agent responses are collected in [USAGE_EXAMPLES.md](./USAGE_EXAMPLES.md).
114
+
109
115
  ## Environment Variables
110
116
 
111
117
  | Variable | Default | Description |
@@ -0,0 +1,342 @@
1
+ # Usage Examples
2
+
3
+ These examples show how `@ton/mcp` can be used in raw CLI mode. They are illustrative rather than literal agent logs: each example includes a representative user request, the `npx @ton/mcp@alpha` commands an agent would typically run, and the kind of response it would usually return.
4
+
5
+ ## Agentic Wallets
6
+
7
+ ### Create an agentic wallet
8
+
9
+ **User request**
10
+
11
+ `Create an agentic wallet`
12
+
13
+ **Approximate command list**
14
+
15
+ ```bash
16
+ npx @ton/mcp@alpha agentic_start_root_wallet_setup --name "My Agent" --network mainnet
17
+ open <DASHBOARD_URL>
18
+ npx @ton/mcp@alpha agentic_complete_root_wallet_setup --setupId <SETUP_ID> --walletAddress <WALLET_ADDRESS>
19
+ npx @ton/mcp@alpha get_current_wallet
20
+ ```
21
+
22
+ **Approximate agent response**
23
+
24
+ > A new agentic wallet setup was started, and the dashboard link was opened. After the dashboard step was completed, wallet `EQ...` was added and set as the active wallet.
25
+
26
+ ### Import an existing agentic wallet
27
+
28
+ **User request**
29
+
30
+ `Import my existing agentic wallet EQ...`
31
+
32
+ **Approximate command list**
33
+
34
+ ```bash
35
+ npx @ton/mcp@alpha agentic_validate_wallet --address EQ...
36
+ npx @ton/mcp@alpha agentic_import_wallet --address EQ... --name "Imported wallet"
37
+ npx @ton/mcp@alpha agentic_rotate_operator_key --walletSelector "Imported wallet"
38
+ open <DASHBOARD_URL>
39
+ npx @ton/mcp@alpha list_wallets
40
+ ```
41
+
42
+ **Approximate agent response**
43
+
44
+ > Wallet `EQ...` was validated and imported into the local registry under the name `Imported wallet`. The dashboard link for the `Public Key` update was opened. Until that on-chain confirmation is completed, the wallet is available in read-only mode.
45
+
46
+ ### Rotate the operator key
47
+
48
+ **User request**
49
+
50
+ `Rotate the operator key for the active agentic wallet`
51
+
52
+ **Approximate command list**
53
+
54
+ ```bash
55
+ npx @ton/mcp@alpha agentic_rotate_operator_key
56
+ open <DASHBOARD_URL>
57
+ npx @ton/mcp@alpha agentic_get_pending_operator_key_rotation --rotationId <ROTATION_ID>
58
+ npx @ton/mcp@alpha agentic_complete_rotate_operator_key --rotationId <ROTATION_ID>
59
+ ```
60
+
61
+ **Approximate agent response**
62
+
63
+ > The dashboard link for the `Public Key` update was opened. After the main wallet confirms the change, write access is restored.
64
+
65
+ ### List agentic wallets by owner
66
+
67
+ **User request**
68
+
69
+ `Which agentic wallets belong to owner address EQ...?`
70
+
71
+ **Approximate command list**
72
+
73
+ ```bash
74
+ npx @ton/mcp@alpha agentic_list_wallets_by_owner --ownerAddress EQ...
75
+ ```
76
+
77
+ **Approximate agent response**
78
+
79
+ > Several agentic wallets were found for owner address `EQ...`. For each wallet, the agent typically shows the wallet address and basic metadata.
80
+
81
+ ## Wallet Registry and Balances
82
+
83
+ ### List wallets in the registry
84
+
85
+ **User request**
86
+
87
+ `Which wallets do I have?`
88
+
89
+ **Approximate command list**
90
+
91
+ ```bash
92
+ npx @ton/mcp@alpha list_wallets
93
+ npx @ton/mcp@alpha get_current_wallet
94
+ ```
95
+
96
+ **Approximate agent response**
97
+
98
+ > Several wallets were found. The active wallet is `EQ...`. The others can be selected by `id`, name, or address via `set_active_wallet`.
99
+
100
+ ### Switch the active wallet
101
+
102
+ **User request**
103
+
104
+ `Make wallet "treasury" active`
105
+
106
+ **Approximate command list**
107
+
108
+ ```bash
109
+ npx @ton/mcp@alpha set_active_wallet --walletSelector treasury
110
+ npx @ton/mcp@alpha get_current_wallet
111
+ ```
112
+
113
+ **Approximate agent response**
114
+
115
+ > The active wallet was switched to `treasury`. Current address: `UQ...`. Network: `mainnet`.
116
+
117
+ ### Show the active wallet balance
118
+
119
+ **User request**
120
+
121
+ `Show my balance in TON and jettons`
122
+
123
+ **Approximate command list**
124
+
125
+ ```bash
126
+ npx @ton/mcp@alpha get_balance
127
+ npx @ton/mcp@alpha get_jettons
128
+ ```
129
+
130
+ **Approximate agent response**
131
+
132
+ > Active wallet balance: `12.84 TON`. Jetton balances include `USDT 53.2`, `NOT 1400`, and `STON 18.05`.
133
+
134
+ ### Show the balance of any address
135
+
136
+ **User request**
137
+
138
+ `Show the balance of address EQ...`
139
+
140
+ **Approximate command list**
141
+
142
+ ```bash
143
+ npx @ton/mcp@alpha get_balance_by_address --address EQ...
144
+ npx @ton/mcp@alpha get_jettons_by_address --address EQ...
145
+ ```
146
+
147
+ **Approximate agent response**
148
+
149
+ > Address `EQ...` has a balance of `3.21 TON`. No jettons were found for that address.
150
+
151
+ ### Find a known jetton address
152
+
153
+ **User request**
154
+
155
+ `Show the address of USDT`
156
+
157
+ **Approximate command list**
158
+
159
+ ```bash
160
+ npx @ton/mcp@alpha get_known_jettons
161
+ ```
162
+
163
+ **Approximate agent response**
164
+
165
+ > `USDT` was found in the list of known jettons with master contract address `EQ...`. That address can be used with `send_jetton` or `get_swap_quote`.
166
+
167
+ ## Transfers and Swaps
168
+
169
+ ### Send TON to a TON DNS name
170
+
171
+ **User request**
172
+
173
+ `Send 1 TON to foundation.ton`
174
+
175
+ **Approximate command list**
176
+
177
+ ```bash
178
+ npx @ton/mcp@alpha resolve_dns --domain foundation.ton
179
+ npx @ton/mcp@alpha send_ton --toAddress EQ... --amount 1
180
+ npx @ton/mcp@alpha get_transaction_status --normalizedHash <NORMALIZED_HASH>
181
+ ```
182
+
183
+ **Approximate agent response**
184
+
185
+ > `foundation.ton` was resolved to TON address `EQ...`. The `1 TON` transfer was sent with `normalizedHash: <NORMALIZED_HASH>`. Transaction status: `completed`.
186
+
187
+ ### Send a jetton
188
+
189
+ **User request**
190
+
191
+ `Send 25 USDT to UQAbc...`
192
+
193
+ **Approximate command list**
194
+
195
+ ```bash
196
+ npx @ton/mcp@alpha get_jettons
197
+ npx @ton/mcp@alpha send_jetton --jettonAddress EQ... --toAddress UQAbc... --amount 25
198
+ npx @ton/mcp@alpha get_transaction_status --normalizedHash <NORMALIZED_HASH>
199
+ ```
200
+
201
+ **Approximate agent response**
202
+
203
+ > `USDT` was found in the wallet, and the `25 USDT` transfer to `UQAbc...` was sent. `normalizedHash: <NORMALIZED_HASH>`. Current status: `completed`.
204
+
205
+ ### Swap TON for a jetton
206
+
207
+ **User request**
208
+
209
+ `Swap 2 TON to USDT`
210
+
211
+ **Approximate command list**
212
+
213
+ ```bash
214
+ npx @ton/mcp@alpha get_known_jettons
215
+ # quote
216
+ npx @ton/mcp@alpha get_swap_quote --fromToken TON --toToken EQ... --amount 2 --slippageBps 100
217
+ # pass messages from quote if user approved
218
+ npx @ton/mcp@alpha send_raw_transaction --messages '<quote.transaction.messages>'
219
+ # If the quote includes transaction.validUntil, add --validUntil to the send_raw_transaction invocation above
220
+ npx @ton/mcp@alpha get_transaction_status --normalizedHash <NORMALIZED_HASH>
221
+ ```
222
+
223
+ **Approximate agent response**
224
+
225
+ > A quote was received for swapping `2 TON` to `USDT`. After confirmation, the swap was executed with an expected output of about `X USDT` after slippage. `normalizedHash: <NORMALIZED_HASH>`.
226
+
227
+ ### Show recent transactions
228
+
229
+ **User request**
230
+
231
+ `Show my last 5 transactions`
232
+
233
+ **Approximate command list**
234
+
235
+ ```bash
236
+ npx @ton/mcp@alpha get_transactions --limit 5
237
+ ```
238
+
239
+ **Approximate agent response**
240
+
241
+ > The last 5 operations were shown, including incoming and outgoing TON transfers, jetton transfers, and swaps. For each transaction, the agent typically shows the time, action type, amount, and final status.
242
+
243
+ ## TON DNS
244
+
245
+ ### Resolve a TON DNS name
246
+
247
+ **User request**
248
+
249
+ `What does foundation.ton resolve to?`
250
+
251
+ **Approximate command list**
252
+
253
+ ```bash
254
+ npx @ton/mcp@alpha resolve_dns --domain foundation.ton
255
+ ```
256
+
257
+ **Approximate agent response**
258
+
259
+ > Domain `foundation.ton` resolves to address `EQ...`.
260
+
261
+ ### Reverse-resolve an address
262
+
263
+ **User request**
264
+
265
+ `Does address EQ... have a TON DNS name?`
266
+
267
+ **Approximate command list**
268
+
269
+ ```bash
270
+ npx @ton/mcp@alpha back_resolve_dns --address EQ...
271
+ ```
272
+
273
+ **Approximate agent response**
274
+
275
+ > If reverse resolution succeeds, address `EQ...` maps to a DNS name such as `foundation.ton`. Otherwise, the agent reports that no DNS name was found.
276
+
277
+ ## NFTs
278
+
279
+ ### List NFTs in the active wallet
280
+
281
+ **User request**
282
+
283
+ `Show my NFTs`
284
+
285
+ **Approximate command list**
286
+
287
+ ```bash
288
+ npx @ton/mcp@alpha get_nfts --limit 20
289
+ ```
290
+
291
+ **Approximate agent response**
292
+
293
+ > A list of NFTs from the active wallet was shown, including addresses, collection names, preview metadata, and key attributes.
294
+
295
+ ### Show NFT details
296
+
297
+ **User request**
298
+
299
+ `Show details for NFT EQ...`
300
+
301
+ **Approximate command list**
302
+
303
+ ```bash
304
+ npx @ton/mcp@alpha get_nft --nftAddress EQ...
305
+ ```
306
+
307
+ **Approximate agent response**
308
+
309
+ > For NFT `EQ...`, the agent shows metadata, collection information, owner, content URI, and attributes.
310
+
311
+ ### Send an NFT
312
+
313
+ **User request**
314
+
315
+ `Send NFT EQ... to UQReceiver...`
316
+
317
+ **Approximate command list**
318
+
319
+ ```bash
320
+ npx @ton/mcp@alpha send_nft --nftAddress EQ... --toAddress UQReceiver...
321
+ npx @ton/mcp@alpha get_transaction_status --normalizedHash <NORMALIZED_HASH>
322
+ ```
323
+
324
+ **Approximate agent response**
325
+
326
+ > NFT `EQ...` was sent to `UQReceiver...`. `normalizedHash: <NORMALIZED_HASH>`. Transaction status: `completed`.
327
+
328
+ ### Show NFTs owned by any address
329
+
330
+ **User request**
331
+
332
+ `Show NFTs owned by address EQ...`
333
+
334
+ **Approximate command list**
335
+
336
+ ```bash
337
+ npx @ton/mcp@alpha get_nfts_by_address --address EQ... --limit 10
338
+ ```
339
+
340
+ **Approximate agent response**
341
+
342
+ > NFTs owned by address `EQ...` were shown, even though that address is not one of the saved wallets.
package/dist/cli.js CHANGED
@@ -89480,16 +89480,29 @@ var TonWalletKit = class {
89480
89480
  this.eventRouter.removeErrorCallback();
89481
89481
  }
89482
89482
  /**
89483
+ * Allow to convert url to ConnectionRequestEvent to use inline way
89484
+ */
89485
+ async connectionEventFromUrl(url) {
89486
+ await this.ensureInitialized();
89487
+ try {
89488
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
89489
+ return await new ConnectHandler(() => {}, this.config, this.analyticsManager).handle(bridgeEvent);
89490
+ } catch (error) {
89491
+ log$5.error("Failed to create connection event from URL", {
89492
+ error,
89493
+ url
89494
+ });
89495
+ throw error;
89496
+ }
89497
+ }
89498
+ /**
89483
89499
  * Handle pasted TON Connect URL/link
89484
89500
  * Parses the URL and creates a connect request event
89485
89501
  */
89486
89502
  async handleTonConnectUrl(url) {
89487
89503
  await this.ensureInitialized();
89488
89504
  try {
89489
- const parsedUrl = this.parseTonConnectUrl(url);
89490
- if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
89491
- const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
89492
- if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
89505
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
89493
89506
  await this.eventRouter.routeEvent(bridgeEvent);
89494
89507
  } catch (error) {
89495
89508
  log$5.error("Failed to handle TON Connect URL", {
@@ -89517,6 +89530,16 @@ var TonWalletKit = class {
89517
89530
  await this.eventRouter.routeEvent(bridgeEvent);
89518
89531
  }
89519
89532
  /**
89533
+ * Parse and validate TON Connect URL into a RawBridgeEventConnect
89534
+ */
89535
+ parseBridgeConnectEventFromUrl(url) {
89536
+ const parsedUrl = this.parseTonConnectUrl(url);
89537
+ if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
89538
+ const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
89539
+ if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
89540
+ return bridgeEvent;
89541
+ }
89542
+ /**
89520
89543
  * Parse TON Connect URL to extract connection parameters
89521
89544
  */
89522
89545
  parseTonConnectUrl(url) {
@@ -106480,23 +106503,6 @@ const tokenToAddress = (token) => {
106480
106503
  if (token.address === "ton") return "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
106481
106504
  return import_dist$3.Address.parse(token.address).toRawString();
106482
106505
  };
106483
- const addressToToken = (address, decimals = 9) => {
106484
- if (address === "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c") return {
106485
- address: "ton",
106486
- decimals: 9
106487
- };
106488
- try {
106489
- return {
106490
- address: import_dist$3.Address.parseRaw(address).toString(),
106491
- decimals
106492
- };
106493
- } catch {
106494
- return {
106495
- address,
106496
- decimals
106497
- };
106498
- }
106499
- };
106500
106506
  const toOmnistonAddress = (address, network) => {
106501
106507
  return {
106502
106508
  address,
@@ -106711,14 +106717,6 @@ var OmnistonSwapProvider = class extends SwapProvider {
106711
106717
  mapOmnistonQuoteToSwapQuote(quote, params) {
106712
106718
  const metadata = { omnistonQuote: quote };
106713
106719
  const fee = [];
106714
- if (quote.protocolFeeAsset) fee.push({
106715
- amount: quote.protocolFeeUnits,
106716
- token: addressToToken(quote.protocolFeeAsset.address)
106717
- });
106718
- if (quote.referrerFeeAsset) fee.push({
106719
- amount: quote.referrerFeeUnits,
106720
- token: addressToToken(quote.referrerFeeAsset.address)
106721
- });
106722
106720
  return {
106723
106721
  rawFromAmount: quote.bidUnits,
106724
106722
  rawToAmount: quote.askUnits,
package/dist/index.cjs CHANGED
@@ -89849,16 +89849,29 @@ var TonWalletKit = class {
89849
89849
  this.eventRouter.removeErrorCallback();
89850
89850
  }
89851
89851
  /**
89852
+ * Allow to convert url to ConnectionRequestEvent to use inline way
89853
+ */
89854
+ async connectionEventFromUrl(url) {
89855
+ await this.ensureInitialized();
89856
+ try {
89857
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
89858
+ return await new ConnectHandler(() => {}, this.config, this.analyticsManager).handle(bridgeEvent);
89859
+ } catch (error) {
89860
+ log$4.error("Failed to create connection event from URL", {
89861
+ error,
89862
+ url
89863
+ });
89864
+ throw error;
89865
+ }
89866
+ }
89867
+ /**
89852
89868
  * Handle pasted TON Connect URL/link
89853
89869
  * Parses the URL and creates a connect request event
89854
89870
  */
89855
89871
  async handleTonConnectUrl(url) {
89856
89872
  await this.ensureInitialized();
89857
89873
  try {
89858
- const parsedUrl = this.parseTonConnectUrl(url);
89859
- if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
89860
- const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
89861
- if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
89874
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
89862
89875
  await this.eventRouter.routeEvent(bridgeEvent);
89863
89876
  } catch (error) {
89864
89877
  log$4.error("Failed to handle TON Connect URL", {
@@ -89886,6 +89899,16 @@ var TonWalletKit = class {
89886
89899
  await this.eventRouter.routeEvent(bridgeEvent);
89887
89900
  }
89888
89901
  /**
89902
+ * Parse and validate TON Connect URL into a RawBridgeEventConnect
89903
+ */
89904
+ parseBridgeConnectEventFromUrl(url) {
89905
+ const parsedUrl = this.parseTonConnectUrl(url);
89906
+ if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
89907
+ const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
89908
+ if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
89909
+ return bridgeEvent;
89910
+ }
89911
+ /**
89889
89912
  * Parse TON Connect URL to extract connection parameters
89890
89913
  */
89891
89914
  parseTonConnectUrl(url) {
@@ -105675,23 +105698,6 @@ const tokenToAddress = (token) => {
105675
105698
  if (token.address === "ton") return "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
105676
105699
  return import_dist$3.Address.parse(token.address).toRawString();
105677
105700
  };
105678
- const addressToToken = (address, decimals = 9) => {
105679
- if (address === "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c") return {
105680
- address: "ton",
105681
- decimals: 9
105682
- };
105683
- try {
105684
- return {
105685
- address: import_dist$3.Address.parseRaw(address).toString(),
105686
- decimals
105687
- };
105688
- } catch {
105689
- return {
105690
- address,
105691
- decimals
105692
- };
105693
- }
105694
- };
105695
105701
  const toOmnistonAddress = (address, network) => {
105696
105702
  return {
105697
105703
  address,
@@ -105906,14 +105912,6 @@ var OmnistonSwapProvider = class extends SwapProvider {
105906
105912
  mapOmnistonQuoteToSwapQuote(quote, params) {
105907
105913
  const metadata = { omnistonQuote: quote };
105908
105914
  const fee = [];
105909
- if (quote.protocolFeeAsset) fee.push({
105910
- amount: quote.protocolFeeUnits,
105911
- token: addressToToken(quote.protocolFeeAsset.address)
105912
- });
105913
- if (quote.referrerFeeAsset) fee.push({
105914
- amount: quote.referrerFeeUnits,
105915
- token: addressToToken(quote.referrerFeeAsset.address)
105916
- });
105917
105915
  return {
105918
105916
  rawFromAmount: quote.bidUnits,
105919
105917
  rawToAmount: quote.askUnits,
package/dist/index.js CHANGED
@@ -89849,16 +89849,29 @@ var TonWalletKit = class {
89849
89849
  this.eventRouter.removeErrorCallback();
89850
89850
  }
89851
89851
  /**
89852
+ * Allow to convert url to ConnectionRequestEvent to use inline way
89853
+ */
89854
+ async connectionEventFromUrl(url) {
89855
+ await this.ensureInitialized();
89856
+ try {
89857
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
89858
+ return await new ConnectHandler(() => {}, this.config, this.analyticsManager).handle(bridgeEvent);
89859
+ } catch (error) {
89860
+ log$4.error("Failed to create connection event from URL", {
89861
+ error,
89862
+ url
89863
+ });
89864
+ throw error;
89865
+ }
89866
+ }
89867
+ /**
89852
89868
  * Handle pasted TON Connect URL/link
89853
89869
  * Parses the URL and creates a connect request event
89854
89870
  */
89855
89871
  async handleTonConnectUrl(url) {
89856
89872
  await this.ensureInitialized();
89857
89873
  try {
89858
- const parsedUrl = this.parseTonConnectUrl(url);
89859
- if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
89860
- const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
89861
- if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
89874
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
89862
89875
  await this.eventRouter.routeEvent(bridgeEvent);
89863
89876
  } catch (error) {
89864
89877
  log$4.error("Failed to handle TON Connect URL", {
@@ -89886,6 +89899,16 @@ var TonWalletKit = class {
89886
89899
  await this.eventRouter.routeEvent(bridgeEvent);
89887
89900
  }
89888
89901
  /**
89902
+ * Parse and validate TON Connect URL into a RawBridgeEventConnect
89903
+ */
89904
+ parseBridgeConnectEventFromUrl(url) {
89905
+ const parsedUrl = this.parseTonConnectUrl(url);
89906
+ if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
89907
+ const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
89908
+ if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
89909
+ return bridgeEvent;
89910
+ }
89911
+ /**
89889
89912
  * Parse TON Connect URL to extract connection parameters
89890
89913
  */
89891
89914
  parseTonConnectUrl(url) {
@@ -105675,23 +105698,6 @@ const tokenToAddress = (token) => {
105675
105698
  if (token.address === "ton") return "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
105676
105699
  return import_dist$3.Address.parse(token.address).toRawString();
105677
105700
  };
105678
- const addressToToken = (address, decimals = 9) => {
105679
- if (address === "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c") return {
105680
- address: "ton",
105681
- decimals: 9
105682
- };
105683
- try {
105684
- return {
105685
- address: import_dist$3.Address.parseRaw(address).toString(),
105686
- decimals
105687
- };
105688
- } catch {
105689
- return {
105690
- address,
105691
- decimals
105692
- };
105693
- }
105694
- };
105695
105701
  const toOmnistonAddress = (address, network) => {
105696
105702
  return {
105697
105703
  address,
@@ -105906,14 +105912,6 @@ var OmnistonSwapProvider = class extends SwapProvider {
105906
105912
  mapOmnistonQuoteToSwapQuote(quote, params) {
105907
105913
  const metadata = { omnistonQuote: quote };
105908
105914
  const fee = [];
105909
- if (quote.protocolFeeAsset) fee.push({
105910
- amount: quote.protocolFeeUnits,
105911
- token: addressToToken(quote.protocolFeeAsset.address)
105912
- });
105913
- if (quote.referrerFeeAsset) fee.push({
105914
- amount: quote.referrerFeeUnits,
105915
- token: addressToToken(quote.referrerFeeAsset.address)
105916
- });
105917
105915
  return {
105918
105916
  rawFromAmount: quote.bidUnits,
105919
105917
  rawToAmount: quote.askUnits,
@@ -77904,16 +77904,29 @@ var TonWalletKit = class {
77904
77904
  this.eventRouter.removeErrorCallback();
77905
77905
  }
77906
77906
  /**
77907
+ * Allow to convert url to ConnectionRequestEvent to use inline way
77908
+ */
77909
+ async connectionEventFromUrl(url) {
77910
+ await this.ensureInitialized();
77911
+ try {
77912
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
77913
+ return await new ConnectHandler(() => {}, this.config, this.analyticsManager).handle(bridgeEvent);
77914
+ } catch (error) {
77915
+ log$4.error("Failed to create connection event from URL", {
77916
+ error,
77917
+ url
77918
+ });
77919
+ throw error;
77920
+ }
77921
+ }
77922
+ /**
77907
77923
  * Handle pasted TON Connect URL/link
77908
77924
  * Parses the URL and creates a connect request event
77909
77925
  */
77910
77926
  async handleTonConnectUrl(url) {
77911
77927
  await this.ensureInitialized();
77912
77928
  try {
77913
- const parsedUrl = this.parseTonConnectUrl(url);
77914
- if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
77915
- const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
77916
- if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
77929
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
77917
77930
  await this.eventRouter.routeEvent(bridgeEvent);
77918
77931
  } catch (error) {
77919
77932
  log$4.error("Failed to handle TON Connect URL", {
@@ -77941,6 +77954,16 @@ var TonWalletKit = class {
77941
77954
  await this.eventRouter.routeEvent(bridgeEvent);
77942
77955
  }
77943
77956
  /**
77957
+ * Parse and validate TON Connect URL into a RawBridgeEventConnect
77958
+ */
77959
+ parseBridgeConnectEventFromUrl(url) {
77960
+ const parsedUrl = this.parseTonConnectUrl(url);
77961
+ if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
77962
+ const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
77963
+ if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
77964
+ return bridgeEvent;
77965
+ }
77966
+ /**
77944
77967
  * Parse TON Connect URL to extract connection parameters
77945
77968
  */
77946
77969
  parseTonConnectUrl(url) {
@@ -106744,23 +106767,6 @@ const tokenToAddress = (token) => {
106744
106767
  if (token.address === "ton") return "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
106745
106768
  return import_dist$4.Address.parse(token.address).toRawString();
106746
106769
  };
106747
- const addressToToken = (address, decimals = 9) => {
106748
- if (address === "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c") return {
106749
- address: "ton",
106750
- decimals: 9
106751
- };
106752
- try {
106753
- return {
106754
- address: import_dist$4.Address.parseRaw(address).toString(),
106755
- decimals
106756
- };
106757
- } catch {
106758
- return {
106759
- address,
106760
- decimals
106761
- };
106762
- }
106763
- };
106764
106770
  const toOmnistonAddress = (address, network) => {
106765
106771
  return {
106766
106772
  address,
@@ -106975,14 +106981,6 @@ var OmnistonSwapProvider = class extends SwapProvider {
106975
106981
  mapOmnistonQuoteToSwapQuote(quote, params) {
106976
106982
  const metadata = { omnistonQuote: quote };
106977
106983
  const fee = [];
106978
- if (quote.protocolFeeAsset) fee.push({
106979
- amount: quote.protocolFeeUnits,
106980
- token: addressToToken(quote.protocolFeeAsset.address)
106981
- });
106982
- if (quote.referrerFeeAsset) fee.push({
106983
- amount: quote.referrerFeeUnits,
106984
- token: addressToToken(quote.referrerFeeAsset.address)
106985
- });
106986
106984
  return {
106987
106985
  rawFromAmount: quote.bidUnits,
106988
106986
  rawToAmount: quote.askUnits,
@@ -77904,16 +77904,29 @@ var TonWalletKit = class {
77904
77904
  this.eventRouter.removeErrorCallback();
77905
77905
  }
77906
77906
  /**
77907
+ * Allow to convert url to ConnectionRequestEvent to use inline way
77908
+ */
77909
+ async connectionEventFromUrl(url) {
77910
+ await this.ensureInitialized();
77911
+ try {
77912
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
77913
+ return await new ConnectHandler(() => {}, this.config, this.analyticsManager).handle(bridgeEvent);
77914
+ } catch (error) {
77915
+ log$4.error("Failed to create connection event from URL", {
77916
+ error,
77917
+ url
77918
+ });
77919
+ throw error;
77920
+ }
77921
+ }
77922
+ /**
77907
77923
  * Handle pasted TON Connect URL/link
77908
77924
  * Parses the URL and creates a connect request event
77909
77925
  */
77910
77926
  async handleTonConnectUrl(url) {
77911
77927
  await this.ensureInitialized();
77912
77928
  try {
77913
- const parsedUrl = this.parseTonConnectUrl(url);
77914
- if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
77915
- const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
77916
- if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
77929
+ const bridgeEvent = this.parseBridgeConnectEventFromUrl(url);
77917
77930
  await this.eventRouter.routeEvent(bridgeEvent);
77918
77931
  } catch (error) {
77919
77932
  log$4.error("Failed to handle TON Connect URL", {
@@ -77941,6 +77954,16 @@ var TonWalletKit = class {
77941
77954
  await this.eventRouter.routeEvent(bridgeEvent);
77942
77955
  }
77943
77956
  /**
77957
+ * Parse and validate TON Connect URL into a RawBridgeEventConnect
77958
+ */
77959
+ parseBridgeConnectEventFromUrl(url) {
77960
+ const parsedUrl = this.parseTonConnectUrl(url);
77961
+ if (!parsedUrl) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL format", void 0, { url });
77962
+ const bridgeEvent = this.createConnectEventFromUrl(parsedUrl);
77963
+ if (!bridgeEvent) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Invalid TON Connect URL - unable to create bridge event", void 0, { parsedUrl });
77964
+ return bridgeEvent;
77965
+ }
77966
+ /**
77944
77967
  * Parse TON Connect URL to extract connection parameters
77945
77968
  */
77946
77969
  parseTonConnectUrl(url) {
@@ -106744,23 +106767,6 @@ const tokenToAddress = (token) => {
106744
106767
  if (token.address === "ton") return "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
106745
106768
  return import_dist$4.Address.parse(token.address).toRawString();
106746
106769
  };
106747
- const addressToToken = (address, decimals = 9) => {
106748
- if (address === "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c") return {
106749
- address: "ton",
106750
- decimals: 9
106751
- };
106752
- try {
106753
- return {
106754
- address: import_dist$4.Address.parseRaw(address).toString(),
106755
- decimals
106756
- };
106757
- } catch {
106758
- return {
106759
- address,
106760
- decimals
106761
- };
106762
- }
106763
- };
106764
106770
  const toOmnistonAddress = (address, network) => {
106765
106771
  return {
106766
106772
  address,
@@ -106975,14 +106981,6 @@ var OmnistonSwapProvider = class extends SwapProvider {
106975
106981
  mapOmnistonQuoteToSwapQuote(quote, params) {
106976
106982
  const metadata = { omnistonQuote: quote };
106977
106983
  const fee = [];
106978
- if (quote.protocolFeeAsset) fee.push({
106979
- amount: quote.protocolFeeUnits,
106980
- token: addressToToken(quote.protocolFeeAsset.address)
106981
- });
106982
- if (quote.referrerFeeAsset) fee.push({
106983
- amount: quote.referrerFeeUnits,
106984
- token: addressToToken(quote.referrerFeeAsset.address)
106985
- });
106986
106984
  return {
106987
106985
  rawFromAmount: quote.bidUnits,
106988
106986
  rawToAmount: quote.askUnits,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ton/mcp",
3
- "version": "0.1.15-alpha.7",
3
+ "version": "0.1.15-alpha.8",
4
4
  "description": "TON MCP Server - Model Context Protocol server for TON blockchain wallet operations",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,6 +38,7 @@
38
38
  "dist",
39
39
  "skills",
40
40
  "llms.txt",
41
+ "USAGE_EXAMPLES.md",
41
42
  "README.md"
42
43
  ],
43
44
  "keywords": [
@@ -59,7 +60,7 @@
59
60
  "undici": "^7.16.0",
60
61
  "ws": "^8.18.3",
61
62
  "zod": "^3.25.76",
62
- "@ton/walletkit": "0.0.11-alpha.2"
63
+ "@ton/walletkit": "0.0.11"
63
64
  },
64
65
  "peerDependencies": {
65
66
  "@modelcontextprotocol/sdk": "^1.25.1"
@@ -18,6 +18,8 @@ Run any TON wallet MCP tool directly from the command line. The binary invokes t
18
18
  | `npx @ton/mcp@alpha --http [port]` | HTTP MCP server |
19
19
  | `npx @ton/mcp@alpha <tool_name> [--arg value ...]` | **Raw CLI: call one tool and exit** |
20
20
 
21
+ Use exactly one mode for a given workflow: either MCP server mode (`stdio`/`--http`) or raw CLI. Do not combine them in the same task/session.
22
+
21
23
  ## Raw CLI Usage
22
24
 
23
25
  ```bash