@truecarry/mcp 0.1.0

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -0
  3. package/dist/adapters/InMemoryStorageAdapter.d.ts +49 -0
  4. package/dist/adapters/InMemoryStorageAdapter.d.ts.map +1 -0
  5. package/dist/adapters/LocalSignerAdapter.d.ts +107 -0
  6. package/dist/adapters/LocalSignerAdapter.d.ts.map +1 -0
  7. package/dist/adapters/SqliteSignerAdapter.d.ts +119 -0
  8. package/dist/adapters/SqliteSignerAdapter.d.ts.map +1 -0
  9. package/dist/adapters/SqliteStorageAdapter.d.ts +81 -0
  10. package/dist/adapters/SqliteStorageAdapter.d.ts.map +1 -0
  11. package/dist/adapters/TelegramUserContextProvider.d.ts +70 -0
  12. package/dist/adapters/TelegramUserContextProvider.d.ts.map +1 -0
  13. package/dist/adapters/index.d.ts +19 -0
  14. package/dist/adapters/index.d.ts.map +1 -0
  15. package/dist/cli.d.ts +9 -0
  16. package/dist/cli.d.ts.map +1 -0
  17. package/dist/cli.js +90209 -0
  18. package/dist/core/LimitsManager.d.ts +59 -0
  19. package/dist/core/LimitsManager.d.ts.map +1 -0
  20. package/dist/core/PendingTransactionManager.d.ts +122 -0
  21. package/dist/core/PendingTransactionManager.d.ts.map +1 -0
  22. package/dist/core/UserScopedSigner.d.ts +96 -0
  23. package/dist/core/UserScopedSigner.d.ts.map +1 -0
  24. package/dist/core/UserScopedStorage.d.ts +59 -0
  25. package/dist/core/UserScopedStorage.d.ts.map +1 -0
  26. package/dist/core/index.d.ts +15 -0
  27. package/dist/core/index.d.ts.map +1 -0
  28. package/dist/factory.d.ts +53 -0
  29. package/dist/factory.d.ts.map +1 -0
  30. package/dist/index.cjs +91029 -0
  31. package/dist/index.d.ts +30 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +91015 -0
  34. package/dist/services/McpWalletService.d.ts +253 -0
  35. package/dist/services/McpWalletService.d.ts.map +1 -0
  36. package/dist/services/WalletService.d.ts +144 -0
  37. package/dist/services/WalletService.d.ts.map +1 -0
  38. package/dist/storage/SecureStorage.d.ts +79 -0
  39. package/dist/storage/SecureStorage.d.ts.map +1 -0
  40. package/dist/tools/balance.d.ts +167 -0
  41. package/dist/tools/balance.d.ts.map +1 -0
  42. package/dist/tools/index.d.ts +15 -0
  43. package/dist/tools/index.d.ts.map +1 -0
  44. package/dist/tools/mcp-tools.d.ts +439 -0
  45. package/dist/tools/mcp-tools.d.ts.map +1 -0
  46. package/dist/tools/swap.d.ts +110 -0
  47. package/dist/tools/swap.d.ts.map +1 -0
  48. package/dist/tools/transfer.d.ts +146 -0
  49. package/dist/tools/transfer.d.ts.map +1 -0
  50. package/dist/tools/wallet.d.ts +138 -0
  51. package/dist/tools/wallet.d.ts.map +1 -0
  52. package/dist/types/config.d.ts +65 -0
  53. package/dist/types/config.d.ts.map +1 -0
  54. package/dist/types/contacts.d.ts +61 -0
  55. package/dist/types/contacts.d.ts.map +1 -0
  56. package/dist/types/index.d.ts +16 -0
  57. package/dist/types/index.d.ts.map +1 -0
  58. package/dist/types/signer.d.ts +120 -0
  59. package/dist/types/signer.d.ts.map +1 -0
  60. package/dist/types/storage.d.ts +41 -0
  61. package/dist/types/storage.d.ts.map +1 -0
  62. package/dist/types/user-context.d.ts +48 -0
  63. package/dist/types/user-context.d.ts.map +1 -0
  64. package/package.json +76 -0
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * LimitsManager - Enforces transaction, daily, and wallet count limits
10
+ */
11
+ import type { LimitsConfig } from '../types/config.js';
12
+ import type { UserScopedStorage } from './UserScopedStorage.js';
13
+ /**
14
+ * Result of a limit check
15
+ */
16
+ export interface LimitCheckResult {
17
+ allowed: boolean;
18
+ reason?: string;
19
+ }
20
+ /**
21
+ * LimitsManager enforces safety limits on transactions and wallet counts.
22
+ */
23
+ export declare class LimitsManager {
24
+ private readonly limits;
25
+ constructor(limits?: LimitsConfig);
26
+ /**
27
+ * Check if a transaction amount is within limits
28
+ */
29
+ checkTransactionLimit(storage: UserScopedStorage, amountTon: number): Promise<LimitCheckResult>;
30
+ /**
31
+ * Record a transaction for daily limit tracking
32
+ */
33
+ recordTransaction(storage: UserScopedStorage, amountTon: number): Promise<void>;
34
+ /**
35
+ * Check if user can create another wallet
36
+ */
37
+ checkWalletCountLimit(currentWalletCount: number): Promise<LimitCheckResult>;
38
+ /**
39
+ * Get the configured limits
40
+ */
41
+ getLimits(): Required<LimitsConfig>;
42
+ /**
43
+ * Get today's date as ISO string (YYYY-MM-DD)
44
+ */
45
+ private getTodayDate;
46
+ /**
47
+ * Get daily usage for a specific date
48
+ */
49
+ private getDailyUsage;
50
+ /**
51
+ * Convert TON to nanoTON string
52
+ */
53
+ private tonToNano;
54
+ /**
55
+ * Convert nanoTON string to TON
56
+ */
57
+ private nanoToTon;
58
+ }
59
+ //# sourceMappingURL=LimitsManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimitsManager.d.ts","sourceRoot":"","sources":["../../src/core/LimitsManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAehE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;gBAEpC,MAAM,CAAC,EAAE,YAAY;IASjC;;OAEG;IACG,qBAAqB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0BrG;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBrF;;OAEG;IACG,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAUlF;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,YAAY,CAAC;IAInC;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;YACW,aAAa;IAK3B;;OAEG;IACH,OAAO,CAAC,SAAS;IAKjB;;OAEG;IACH,OAAO,CAAC,SAAS;CAGpB"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * PendingTransactionManager - Manages two-step transaction confirmation flow
10
+ *
11
+ * When requireConfirmation is enabled:
12
+ * 1. send_ton/send_jetton/execute_swap creates a pending transaction
13
+ * 2. User must call confirm_transaction to execute
14
+ * 3. Or cancel_transaction to abort
15
+ */
16
+ import type { UserScopedStorage } from './UserScopedStorage.js';
17
+ /**
18
+ * Pending transaction types
19
+ */
20
+ export type PendingTransactionType = 'send_ton' | 'send_jetton' | 'swap';
21
+ /**
22
+ * Pending transaction data stored in storage
23
+ */
24
+ export interface PendingTransaction {
25
+ /** Unique transaction ID */
26
+ id: string;
27
+ /** Transaction type */
28
+ type: PendingTransactionType;
29
+ /** Wallet name to send from */
30
+ walletName: string;
31
+ /** ISO timestamp when created */
32
+ createdAt: string;
33
+ /** ISO timestamp when expires */
34
+ expiresAt: string;
35
+ /** Human-readable description for confirmation */
36
+ description: string;
37
+ /** Transaction-specific data */
38
+ data: PendingTonTransfer | PendingJettonTransfer | PendingSwap;
39
+ }
40
+ /**
41
+ * Pending TON transfer data
42
+ */
43
+ export interface PendingTonTransfer {
44
+ type: 'send_ton';
45
+ toAddress: string;
46
+ /** Amount in nanoTON */
47
+ amountNano: string;
48
+ /** Human-readable amount */
49
+ amountTon: string;
50
+ comment?: string;
51
+ }
52
+ /**
53
+ * Pending Jetton transfer data
54
+ */
55
+ export interface PendingJettonTransfer {
56
+ type: 'send_jetton';
57
+ toAddress: string;
58
+ jettonAddress: string;
59
+ /** Raw amount */
60
+ amountRaw: string;
61
+ /** Human-readable amount */
62
+ amountHuman: string;
63
+ symbol?: string;
64
+ decimals: number;
65
+ comment?: string;
66
+ }
67
+ /**
68
+ * Pending swap data
69
+ */
70
+ export interface PendingSwap {
71
+ type: 'swap';
72
+ fromToken: string;
73
+ toToken: string;
74
+ fromAmount: string;
75
+ toAmount: string;
76
+ minReceived: string;
77
+ provider: string;
78
+ /** Serialized quote for execution */
79
+ quoteJson: string;
80
+ }
81
+ /**
82
+ * PendingTransactionManager handles the confirmation flow for transactions.
83
+ */
84
+ export declare class PendingTransactionManager {
85
+ private readonly ttlSeconds;
86
+ constructor(ttlSeconds?: number);
87
+ /**
88
+ * Generate a unique transaction ID
89
+ */
90
+ generateId(): string;
91
+ /**
92
+ * Create a pending transaction
93
+ */
94
+ createPending(storage: UserScopedStorage, params: {
95
+ type: PendingTransactionType;
96
+ walletName: string;
97
+ description: string;
98
+ data: PendingTonTransfer | PendingJettonTransfer | PendingSwap;
99
+ }): Promise<PendingTransaction>;
100
+ /**
101
+ * Get a pending transaction by ID
102
+ */
103
+ getPending(storage: UserScopedStorage, transactionId: string): Promise<PendingTransaction | null>;
104
+ /**
105
+ * List all pending transactions for the user
106
+ */
107
+ listPending(storage: UserScopedStorage): Promise<PendingTransaction[]>;
108
+ /**
109
+ * Delete a pending transaction
110
+ */
111
+ deletePending(storage: UserScopedStorage, transactionId: string): Promise<boolean>;
112
+ /**
113
+ * Mark a pending transaction as confirmed (delete it)
114
+ * The actual execution is handled by the caller
115
+ */
116
+ confirmPending(storage: UserScopedStorage, transactionId: string): Promise<PendingTransaction | null>;
117
+ /**
118
+ * Cancel a pending transaction
119
+ */
120
+ cancelPending(storage: UserScopedStorage, transactionId: string): Promise<boolean>;
121
+ }
122
+ //# sourceMappingURL=PendingTransactionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PendingTransactionManager.d.ts","sourceRoot":"","sources":["../../src/core/PendingTransactionManager.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * UserScopedSigner - Wraps ISignerAdapter with user ownership verification
10
+ *
11
+ * All wallet IDs are prefixed with userId to ensure User A cannot
12
+ * access User B's wallets. Returns generic "not found" error for both
13
+ * missing and unauthorized wallets to prevent enumeration attacks.
14
+ */
15
+ import type { ISignerAdapter, WalletInfo, CreateWalletParams, ImportWalletParams } from '../types/signer.js';
16
+ /**
17
+ * User-scoped signer wrapper.
18
+ * Ensures all operations are scoped to the authenticated user.
19
+ */
20
+ export declare class UserScopedSigner {
21
+ private readonly signer;
22
+ private readonly userId;
23
+ private readonly userPrefix;
24
+ constructor(signer: ISignerAdapter, userId: string);
25
+ /**
26
+ * Get the user ID this signer is scoped to
27
+ */
28
+ getUserId(): string;
29
+ /**
30
+ * Build user-scoped wallet ID from wallet name
31
+ */
32
+ private scopedId;
33
+ /**
34
+ * Extract wallet name from scoped ID
35
+ */
36
+ private extractName;
37
+ /**
38
+ * Check if a wallet ID belongs to this user
39
+ */
40
+ private isOwnedByUser;
41
+ /**
42
+ * Transform wallet info to expose wallet name instead of internal ID
43
+ */
44
+ private transformWalletInfo;
45
+ /**
46
+ * Create a new wallet (user-scoped)
47
+ */
48
+ createWallet(params: Omit<CreateWalletParams, 'walletId'> & {
49
+ name: string;
50
+ }): Promise<WalletInfo & {
51
+ name: string;
52
+ }>;
53
+ /**
54
+ * Import a wallet from mnemonic (user-scoped)
55
+ * Note: Mnemonic is passed to signer and stored securely, never returned
56
+ */
57
+ importWallet(params: Omit<ImportWalletParams, 'walletId'> & {
58
+ name: string;
59
+ }): Promise<WalletInfo & {
60
+ name: string;
61
+ }>;
62
+ /**
63
+ * Get wallet by name (user-scoped)
64
+ * Returns null for both "not found" and "not owned" to prevent enumeration
65
+ */
66
+ getWallet(walletName: string): Promise<(WalletInfo & {
67
+ name: string;
68
+ }) | null>;
69
+ /**
70
+ * List all wallets for this user
71
+ */
72
+ listWallets(): Promise<(WalletInfo & {
73
+ name: string;
74
+ })[]>;
75
+ /**
76
+ * Delete a wallet (user-scoped)
77
+ * Returns false for both "not found" and "not owned"
78
+ */
79
+ deleteWallet(walletName: string): Promise<boolean>;
80
+ /**
81
+ * Sign a transaction (user-scoped)
82
+ * Verifies ownership before signing
83
+ */
84
+ signTransaction(walletName: string, unsignedBoc: string): Promise<string>;
85
+ /**
86
+ * Sign a message (user-scoped)
87
+ * Verifies ownership before signing
88
+ */
89
+ signMessage(walletName: string, message: Buffer): Promise<Buffer>;
90
+ /**
91
+ * Get the underlying signer adapter.
92
+ * Use with caution - bypasses user isolation.
93
+ */
94
+ getUnderlyingSigner(): ISignerAdapter;
95
+ }
96
+ //# sourceMappingURL=UserScopedSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserScopedSigner.d.ts","sourceRoot":"","sources":["../../src/core/UserScopedSigner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7G;;;GAGG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM;IAMlD;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACG,YAAY,CACd,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IASzC;;;OAGG;IACG,YAAY,CACd,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAUzC;;;OAGG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IAgBpF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAc/D;;;OAGG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYxD;;;OAGG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAY/E;;;OAGG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYvE;;;OAGG;IACH,mBAAmB,IAAI,cAAc;CAGxC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * UserScopedStorage - Wraps IStorageAdapter with user namespace isolation
10
+ *
11
+ * All storage keys are prefixed with user:{userId}: to ensure
12
+ * User A cannot access User B's data.
13
+ */
14
+ import type { IStorageAdapter } from '../types/storage.js';
15
+ /**
16
+ * User-scoped storage wrapper.
17
+ * Automatically prefixes all keys with user namespace.
18
+ */
19
+ export declare class UserScopedStorage {
20
+ private readonly storage;
21
+ private readonly userId;
22
+ private readonly prefix;
23
+ constructor(storage: IStorageAdapter, userId: string);
24
+ /**
25
+ * Get the user ID this storage is scoped to
26
+ */
27
+ getUserId(): string;
28
+ /**
29
+ * Build full key with user prefix
30
+ */
31
+ private buildKey;
32
+ /**
33
+ * Strip user prefix from a key
34
+ */
35
+ private stripPrefix;
36
+ /**
37
+ * Get a value by key (user-scoped)
38
+ */
39
+ get<T>(key: string): Promise<T | null>;
40
+ /**
41
+ * Set a value (user-scoped)
42
+ */
43
+ set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
44
+ /**
45
+ * Delete a key (user-scoped)
46
+ */
47
+ delete(key: string): Promise<boolean>;
48
+ /**
49
+ * List keys matching prefix (user-scoped)
50
+ * Returns keys with user prefix stripped.
51
+ */
52
+ list(subPrefix: string): Promise<string[]>;
53
+ /**
54
+ * Get the underlying storage adapter.
55
+ * Use with caution - bypasses user isolation.
56
+ */
57
+ getUnderlyingStorage(): IStorageAdapter;
58
+ }
59
+ //# sourceMappingURL=UserScopedStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserScopedStorage.d.ts","sourceRoot":"","sources":["../../src/core/UserScopedStorage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM;IAMpD;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAI5C;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3C;;;OAGG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAMhD;;;OAGG;IACH,oBAAoB,IAAI,eAAe;CAG1C"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * Core module exports
10
+ */
11
+ export { UserScopedStorage } from './UserScopedStorage.js';
12
+ export { UserScopedSigner } from './UserScopedSigner.js';
13
+ export { LimitsManager } from './LimitsManager.js';
14
+ export { PendingTransactionManager } from './PendingTransactionManager.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * Factory function for creating configured MCP server instances
10
+ */
11
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
12
+ import type { TonMcpConfig } from './types/config.js';
13
+ import type { RequestContext } from './types/user-context.js';
14
+ import { McpWalletService } from './services/McpWalletService.js';
15
+ /**
16
+ * Tool handler context with authenticated user
17
+ */
18
+ export interface ToolContext {
19
+ userId: string;
20
+ requestContext: RequestContext;
21
+ }
22
+ /**
23
+ * Create a configured TON Wallet MCP server
24
+ *
25
+ * @param config - Configuration with adapters and limits
26
+ * @returns Configured McpServer instance
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { createTonWalletMCP, InMemoryStorageAdapter, LocalSignerAdapter } from '@ton/mcp';
31
+ *
32
+ * const server = createTonWalletMCP({
33
+ * storage: new InMemoryStorageAdapter(),
34
+ * signer: new LocalSignerAdapter(),
35
+ * userContext: {
36
+ * getUserId: async (ctx) => ctx.headers?.['x-user-id'] ?? null,
37
+ * },
38
+ * limits: {
39
+ * maxTransactionTon: 100,
40
+ * dailyLimitTon: 1000,
41
+ * maxWalletsPerUser: 10,
42
+ * },
43
+ * requireConfirmation: true,
44
+ * });
45
+ * ```
46
+ */
47
+ export declare function createTonWalletMCP(config: TonMcpConfig): McpServer;
48
+ /**
49
+ * Get the wallet service shutdown handler
50
+ * Call this to properly cleanup when shutting down
51
+ */
52
+ export declare function createShutdownHandler(walletService: McpWalletService): () => Promise<void>;
53
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAYlE;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,cAAc,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAqFlE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,gBAAgB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAE1F"}