@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 @@
1
+ {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../src/tools/transfer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED;;;;;;GAMG;AACH,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMlE;AAED,+DAA+D;AAC/D,QAAA,MAAM,YAAY,IAAI,CAAC;AAEvB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAKxB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;EAW3B,CAAC;AAEH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa;;;;;;;;;;;;;;;;;;;wBAM9B,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkD7B,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC;;;;;;;;;;;;;;EAgGjE;AAED,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,138 @@
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
+ * Wallet management MCP tools
10
+ */
11
+ import { z } from 'zod';
12
+ import type { WalletService } from '../services/WalletService.js';
13
+ export declare const createWalletSchema: z.ZodObject<{
14
+ name: z.ZodString;
15
+ version: z.ZodOptional<z.ZodEnum<["v5r1", "v4r2"]>>;
16
+ network: z.ZodOptional<z.ZodEnum<["mainnet", "testnet"]>>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ name: string;
19
+ version?: "v5r1" | "v4r2" | undefined;
20
+ network?: "mainnet" | "testnet" | undefined;
21
+ }, {
22
+ name: string;
23
+ version?: "v5r1" | "v4r2" | undefined;
24
+ network?: "mainnet" | "testnet" | undefined;
25
+ }>;
26
+ export declare const importWalletSchema: z.ZodObject<{
27
+ name: z.ZodString;
28
+ mnemonic: z.ZodString;
29
+ version: z.ZodOptional<z.ZodEnum<["v5r1", "v4r2"]>>;
30
+ network: z.ZodOptional<z.ZodEnum<["mainnet", "testnet"]>>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ name: string;
33
+ mnemonic: string;
34
+ version?: "v5r1" | "v4r2" | undefined;
35
+ network?: "mainnet" | "testnet" | undefined;
36
+ }, {
37
+ name: string;
38
+ mnemonic: string;
39
+ version?: "v5r1" | "v4r2" | undefined;
40
+ network?: "mainnet" | "testnet" | undefined;
41
+ }>;
42
+ export declare const removeWalletSchema: z.ZodObject<{
43
+ name: z.ZodString;
44
+ }, "strip", z.ZodTypeAny, {
45
+ name: string;
46
+ }, {
47
+ name: string;
48
+ }>;
49
+ export declare function createWalletTools(walletService: WalletService): {
50
+ create_wallet: {
51
+ description: string;
52
+ inputSchema: z.ZodObject<{
53
+ name: z.ZodString;
54
+ version: z.ZodOptional<z.ZodEnum<["v5r1", "v4r2"]>>;
55
+ network: z.ZodOptional<z.ZodEnum<["mainnet", "testnet"]>>;
56
+ }, "strip", z.ZodTypeAny, {
57
+ name: string;
58
+ version?: "v5r1" | "v4r2" | undefined;
59
+ network?: "mainnet" | "testnet" | undefined;
60
+ }, {
61
+ name: string;
62
+ version?: "v5r1" | "v4r2" | undefined;
63
+ network?: "mainnet" | "testnet" | undefined;
64
+ }>;
65
+ handler: (args: z.infer<typeof createWalletSchema>) => Promise<{
66
+ content: {
67
+ type: "text";
68
+ text: string;
69
+ }[];
70
+ }>;
71
+ };
72
+ import_wallet: {
73
+ description: string;
74
+ inputSchema: z.ZodObject<{
75
+ name: z.ZodString;
76
+ mnemonic: z.ZodString;
77
+ version: z.ZodOptional<z.ZodEnum<["v5r1", "v4r2"]>>;
78
+ network: z.ZodOptional<z.ZodEnum<["mainnet", "testnet"]>>;
79
+ }, "strip", z.ZodTypeAny, {
80
+ name: string;
81
+ mnemonic: string;
82
+ version?: "v5r1" | "v4r2" | undefined;
83
+ network?: "mainnet" | "testnet" | undefined;
84
+ }, {
85
+ name: string;
86
+ mnemonic: string;
87
+ version?: "v5r1" | "v4r2" | undefined;
88
+ network?: "mainnet" | "testnet" | undefined;
89
+ }>;
90
+ handler: (args: z.infer<typeof importWalletSchema>) => Promise<{
91
+ content: {
92
+ type: "text";
93
+ text: string;
94
+ }[];
95
+ isError: boolean;
96
+ } | {
97
+ content: {
98
+ type: "text";
99
+ text: string;
100
+ }[];
101
+ isError?: undefined;
102
+ }>;
103
+ };
104
+ list_wallets: {
105
+ description: string;
106
+ inputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
107
+ handler: () => Promise<{
108
+ content: {
109
+ type: "text";
110
+ text: string;
111
+ }[];
112
+ }>;
113
+ };
114
+ remove_wallet: {
115
+ description: string;
116
+ inputSchema: z.ZodObject<{
117
+ name: z.ZodString;
118
+ }, "strip", z.ZodTypeAny, {
119
+ name: string;
120
+ }, {
121
+ name: string;
122
+ }>;
123
+ handler: (args: z.infer<typeof removeWalletSchema>) => Promise<{
124
+ content: {
125
+ type: "text";
126
+ text: string;
127
+ }[];
128
+ isError: boolean;
129
+ } | {
130
+ content: {
131
+ type: "text";
132
+ text: string;
133
+ }[];
134
+ isError?: undefined;
135
+ }>;
136
+ };
137
+ };
138
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/tools/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAU7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAW7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;EAE7B,CAAC;AAEH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,aAAa;;;;;;;;;;;;;;;;wBAM5B,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BlC,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0ElC,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;;;;;;;EA8BnE"}
@@ -0,0 +1,65 @@
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
+ * Configuration types for createTonWalletMCP factory
10
+ */
11
+ import type { IStorageAdapter } from './storage.js';
12
+ import type { ISignerAdapter } from './signer.js';
13
+ import type { IUserContextProvider } from './user-context.js';
14
+ import type { IContactResolver } from './contacts.js';
15
+ /**
16
+ * Safety limits configuration
17
+ */
18
+ export interface LimitsConfig {
19
+ /** Maximum TON amount per single transaction */
20
+ maxTransactionTon?: number;
21
+ /** Maximum TON amount per day per user */
22
+ dailyLimitTon?: number;
23
+ /** Maximum number of wallets per user */
24
+ maxWalletsPerUser?: number;
25
+ }
26
+ /**
27
+ * Configuration for createTonWalletMCP factory
28
+ */
29
+ export interface TonMcpConfig {
30
+ /**
31
+ * Storage adapter for wallet metadata, contacts, pending transactions.
32
+ * Required.
33
+ */
34
+ storage: IStorageAdapter;
35
+ /**
36
+ * Signer adapter for secure key management and signing.
37
+ * Required.
38
+ */
39
+ signer: ISignerAdapter;
40
+ /**
41
+ * User context provider for extracting authenticated user ID.
42
+ * Required.
43
+ */
44
+ userContext: IUserContextProvider;
45
+ /**
46
+ * Optional contact resolver for name-to-address resolution.
47
+ */
48
+ contacts?: IContactResolver;
49
+ /**
50
+ * Default network for new wallets.
51
+ * @default 'mainnet'
52
+ */
53
+ network?: 'mainnet' | 'testnet';
54
+ /**
55
+ * Safety limits for transactions and wallets.
56
+ */
57
+ limits?: LimitsConfig;
58
+ /**
59
+ * If true, transactions require explicit confirmation via confirm_transaction tool.
60
+ * Recommended for Telegram bots and other user-facing applications.
61
+ * @default false
62
+ */
63
+ requireConfirmation?: boolean;
64
+ }
65
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0CAA0C;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,OAAO,EAAE,eAAe,CAAC;IAEzB;;;OAGG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;;OAGG;IACH,WAAW,EAAE,oBAAoB,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAE5B;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAEhC;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC"}
@@ -0,0 +1,61 @@
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
+ * IContactResolver - Optional interface for resolving friend names to TON addresses
10
+ *
11
+ * Purpose: Allow users to send to "Alice" instead of raw addresses.
12
+ * Contacts are scoped to the user who created them.
13
+ */
14
+ /**
15
+ * Contact information
16
+ */
17
+ export interface Contact {
18
+ /** Human-readable name for the contact */
19
+ name: string;
20
+ /** TON address */
21
+ address: string;
22
+ /** Optional network specification (defaults to any) */
23
+ network?: 'mainnet' | 'testnet';
24
+ }
25
+ /**
26
+ * Interface for contact resolution.
27
+ * All operations are scoped to a specific user.
28
+ */
29
+ export interface IContactResolver {
30
+ /**
31
+ * Resolve a contact name to an address.
32
+ *
33
+ * @param userId - The user's ID
34
+ * @param name - The contact name to resolve
35
+ * @returns The TON address or null if not found
36
+ */
37
+ resolve(userId: string, name: string): Promise<string | null>;
38
+ /**
39
+ * Add a new contact for a user.
40
+ *
41
+ * @param userId - The user's ID
42
+ * @param contact - The contact to add
43
+ */
44
+ addContact(userId: string, contact: Contact): Promise<void>;
45
+ /**
46
+ * List all contacts for a user.
47
+ *
48
+ * @param userId - The user's ID
49
+ * @returns Array of contacts
50
+ */
51
+ listContacts(userId: string): Promise<Contact[]>;
52
+ /**
53
+ * Remove a contact by name.
54
+ *
55
+ * @param userId - The user's ID
56
+ * @param name - The contact name to remove
57
+ * @returns true if removed, false if not found
58
+ */
59
+ removeContact(userId: string, name: string): Promise<boolean>;
60
+ }
61
+ //# sourceMappingURL=contacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contacts.d.ts","sourceRoot":"","sources":["../../src/types/contacts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE9D;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEjD;;;;;;OAMG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjE"}
@@ -0,0 +1,16 @@
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
+ * Type exports for @ton/mcp package
10
+ */
11
+ export type { IStorageAdapter } from './storage.js';
12
+ export type { ISignerAdapter, WalletInfo, CreateWalletParams, ImportWalletParams } from './signer.js';
13
+ export type { IUserContextProvider, RequestContext } from './user-context.js';
14
+ export type { IContactResolver, Contact } from './contacts.js';
15
+ export type { TonMcpConfig, LimitsConfig } from './config.js';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAGH,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtG,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG9E,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG/D,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,120 @@
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
+ * ISignerAdapter - Interface for secure key management and signing operations
10
+ *
11
+ * Critical: This adapter NEVER returns private keys or seed phrases.
12
+ * Seed phrases are accepted as input but stored securely by the adapter implementation.
13
+ */
14
+ /**
15
+ * Wallet information returned by signer operations.
16
+ * Contains only public data - no private keys or seed phrases.
17
+ */
18
+ export interface WalletInfo {
19
+ /** Internal wallet ID (may be user-prefixed internally by the adapter) */
20
+ walletId: string;
21
+ /** Hex-encoded public key */
22
+ publicKey: string;
23
+ /** TON address (user-friendly format) */
24
+ address: string;
25
+ /** Network the wallet is configured for */
26
+ network: 'mainnet' | 'testnet';
27
+ /** Wallet contract version */
28
+ version: 'v5r1' | 'v4r2';
29
+ /** ISO timestamp when wallet was created */
30
+ createdAt: string;
31
+ }
32
+ /**
33
+ * Parameters for creating a new wallet
34
+ */
35
+ export interface CreateWalletParams {
36
+ /** Unique wallet ID (should be user-scoped externally) */
37
+ walletId: string;
38
+ /** Wallet contract version */
39
+ version: 'v5r1' | 'v4r2';
40
+ /** Network to create the wallet on */
41
+ network: 'mainnet' | 'testnet';
42
+ }
43
+ /**
44
+ * Parameters for importing a wallet from mnemonic
45
+ */
46
+ export interface ImportWalletParams {
47
+ /** Unique wallet ID (should be user-scoped externally) */
48
+ walletId: string;
49
+ /** 24-word mnemonic phrase (stored securely, never returned) */
50
+ mnemonic: string[];
51
+ /** Wallet contract version */
52
+ version: 'v5r1' | 'v4r2';
53
+ /** Network to import the wallet on */
54
+ network: 'mainnet' | 'testnet';
55
+ }
56
+ /**
57
+ * Interface for secure key management and signing operations.
58
+ *
59
+ * Implementations should:
60
+ * - Store keys encrypted (e.g., AES-256-GCM with master key derived via PBKDF2/Argon2)
61
+ * - Never expose private keys or seed phrases through any method
62
+ * - Support user isolation if operating in multi-tenant mode
63
+ */
64
+ export interface ISignerAdapter {
65
+ /**
66
+ * Create a new wallet with generated keys.
67
+ * The mnemonic is generated and stored securely - NEVER returned.
68
+ *
69
+ * @param params - Wallet creation parameters
70
+ * @returns Wallet info (address, public key) - NO private data
71
+ */
72
+ createWallet(params: CreateWalletParams): Promise<WalletInfo>;
73
+ /**
74
+ * Import a wallet from mnemonic.
75
+ * The mnemonic is stored securely by the adapter - NEVER returned.
76
+ *
77
+ * @param params - Import parameters including mnemonic
78
+ * @returns Wallet info (address, public key) - NO private data
79
+ */
80
+ importWallet(params: ImportWalletParams): Promise<WalletInfo>;
81
+ /**
82
+ * Get wallet info by ID.
83
+ *
84
+ * @param walletId - The wallet ID
85
+ * @returns Wallet info or null if not found
86
+ */
87
+ getWallet(walletId: string): Promise<WalletInfo | null>;
88
+ /**
89
+ * List all wallet IDs managed by this adapter.
90
+ * For user isolation, the wrapper should filter by user prefix.
91
+ *
92
+ * @returns Array of wallet IDs
93
+ */
94
+ listWalletIds(): Promise<string[]>;
95
+ /**
96
+ * Delete a wallet and its keys.
97
+ *
98
+ * @param walletId - The wallet ID to delete
99
+ * @returns true if deleted, false if not found
100
+ */
101
+ deleteWallet(walletId: string): Promise<boolean>;
102
+ /**
103
+ * Sign a transaction.
104
+ * The adapter loads the private key internally and signs.
105
+ *
106
+ * @param walletId - The wallet ID to sign with
107
+ * @param unsignedBoc - Base64-encoded unsigned transaction BOC
108
+ * @returns Base64-encoded signed transaction BOC
109
+ */
110
+ signTransaction(walletId: string, unsignedBoc: string): Promise<string>;
111
+ /**
112
+ * Sign an arbitrary message.
113
+ *
114
+ * @param walletId - The wallet ID to sign with
115
+ * @param message - The message bytes to sign
116
+ * @returns The signature bytes
117
+ */
118
+ signMessage(walletId: string, message: Buffer): Promise<Buffer>;
119
+ }
120
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,UAAU;IACvB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,8BAA8B;IAC9B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,sCAAsC;IACtC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,sCAAsC;IACtC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC3B;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9D;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAExD;;;;;OAKG;IACH,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAEnC;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjD;;;;;;;OAOG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnE"}
@@ -0,0 +1,41 @@
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
+ * IStorageAdapter - Interface for persistent key-value storage
10
+ *
11
+ * Purpose: Store wallet metadata, contacts, transaction history, pending transactions.
12
+ * Does NOT store: private keys, seed phrases (that's ISignerAdapter's responsibility)
13
+ */
14
+ export interface IStorageAdapter {
15
+ /**
16
+ * Get a value by key
17
+ * @param key - The storage key
18
+ * @returns The stored value or null if not found
19
+ */
20
+ get<T>(key: string): Promise<T | null>;
21
+ /**
22
+ * Set a value with optional TTL
23
+ * @param key - The storage key
24
+ * @param value - The value to store
25
+ * @param ttlSeconds - Optional time-to-live in seconds (for pending transactions, etc.)
26
+ */
27
+ set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
28
+ /**
29
+ * Delete a key
30
+ * @param key - The storage key
31
+ * @returns true if the key existed and was deleted, false otherwise
32
+ */
33
+ delete(key: string): Promise<boolean>;
34
+ /**
35
+ * List all keys matching a prefix
36
+ * @param prefix - The key prefix to match
37
+ * @returns Array of matching keys
38
+ */
39
+ list(prefix: string): Promise<string[]>;
40
+ }
41
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/types/storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;OAIG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAEvC;;;;;OAKG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElE;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC3C"}
@@ -0,0 +1,48 @@
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
+ * IUserContextProvider - Interface for extracting authenticated user identity
10
+ *
11
+ * Purpose: Identify the current user from MCP request context.
12
+ * Returns null if user cannot be authenticated (request should be rejected).
13
+ */
14
+ /**
15
+ * Request context passed to the user context provider.
16
+ * Contains headers and metadata from the MCP request.
17
+ */
18
+ export interface RequestContext {
19
+ /** HTTP headers (e.g., x-telegram-user-id, authorization) */
20
+ headers?: Record<string, string>;
21
+ /** Additional metadata from the transport */
22
+ metadata?: Record<string, unknown>;
23
+ }
24
+ /**
25
+ * Interface for extracting user identity from request context.
26
+ *
27
+ * Implementations should:
28
+ * - Extract user ID from appropriate header or metadata
29
+ * - Return null if user cannot be authenticated
30
+ * - Optionally provide user metadata for auditing
31
+ */
32
+ export interface IUserContextProvider {
33
+ /**
34
+ * Extract user ID from request context.
35
+ *
36
+ * @param context - The request context with headers and metadata
37
+ * @returns User ID string or null if unauthenticated
38
+ */
39
+ getUserId(context: RequestContext): Promise<string | null>;
40
+ /**
41
+ * Optional: Get additional user metadata for logging/auditing.
42
+ *
43
+ * @param userId - The user ID
44
+ * @returns User metadata or null if not available
45
+ */
46
+ getUserMetadata?(userId: string): Promise<Record<string, unknown> | null>;
47
+ }
48
+ //# sourceMappingURL=user-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-context.d.ts","sourceRoot":"","sources":["../../src/types/user-context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACjC;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,eAAe,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;CAC7E"}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@truecarry/mcp",
3
+ "version": "0.1.0",
4
+ "description": "TON MCP Server - Model Context Protocol server for TON blockchain wallet operations",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.cjs",
8
+ "module": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "bin": {
11
+ "ton-mcp": "./dist/cli.js"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "import": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "require": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.cjs"
22
+ }
23
+ }
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md"
31
+ ],
32
+ "keywords": [
33
+ "ton",
34
+ "mcp",
35
+ "wallet",
36
+ "model-context-protocol",
37
+ "blockchain"
38
+ ],
39
+ "author": "TON Tech",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/ton-connect/kit"
43
+ },
44
+ "dependencies": {
45
+ "@modelcontextprotocol/sdk": "^1.25.1",
46
+ "zod": "^3.25.76",
47
+ "@ton/walletkit": "0.0.6"
48
+ },
49
+ "peerDependencies": {
50
+ "@modelcontextprotocol/sdk": "^1.25.1"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^22.15.29",
54
+ "@vitest/coverage-v8": "^4.0.17",
55
+ "rimraf": "^6.1.0",
56
+ "rolldown": "1.0.0-rc.2",
57
+ "typescript": "~5.9.3",
58
+ "vitest": "^4.0.17"
59
+ },
60
+ "engines": {
61
+ "node": ">=18.0.0"
62
+ },
63
+ "scripts": {
64
+ "build": "pnpm build:clean && rolldown -c && pnpm build:types && pnpm build:chmod",
65
+ "build:clean": "rimraf dist",
66
+ "build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
67
+ "build:chmod": "chmod +x dist/cli.js",
68
+ "dev": "rolldown -c --watch",
69
+ "dev:cli": "node --import tsx/esm src/cli.ts",
70
+ "dev:cli:http": "node --import tsx/esm src/cli.ts --http",
71
+ "lint": "eslint src --max-warnings 0",
72
+ "lint:fix": "eslint src --max-warnings 0 --fix",
73
+ "test": "vitest run",
74
+ "typecheck": "tsc --noEmit"
75
+ }
76
+ }