@missionsquad/mcp-server-tron 1.2.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 (193) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +537 -0
  3. package/bin/cli.js +51 -0
  4. package/build/core/chains.d.ts +17 -0
  5. package/build/core/chains.js +87 -0
  6. package/build/core/chains.js.map +1 -0
  7. package/build/core/prompts.d.ts +19 -0
  8. package/build/core/prompts.js +485 -0
  9. package/build/core/prompts.js.map +1 -0
  10. package/build/core/resources.d.ts +14 -0
  11. package/build/core/resources.js +42 -0
  12. package/build/core/resources.js.map +1 -0
  13. package/build/core/services/account-data.d.ts +144 -0
  14. package/build/core/services/account-data.js +228 -0
  15. package/build/core/services/account-data.js.map +1 -0
  16. package/build/core/services/account-resource.d.ts +56 -0
  17. package/build/core/services/account-resource.js +133 -0
  18. package/build/core/services/account-resource.js.map +1 -0
  19. package/build/core/services/account.d.ts +141 -0
  20. package/build/core/services/account.js +191 -0
  21. package/build/core/services/account.js.map +1 -0
  22. package/build/core/services/address.d.ts +8 -0
  23. package/build/core/services/address.js +52 -0
  24. package/build/core/services/address.js.map +1 -0
  25. package/build/core/services/agent-wallet.d.ts +62 -0
  26. package/build/core/services/agent-wallet.js +234 -0
  27. package/build/core/services/agent-wallet.js.map +1 -0
  28. package/build/core/services/balance.d.ts +26 -0
  29. package/build/core/services/balance.js +60 -0
  30. package/build/core/services/balance.js.map +1 -0
  31. package/build/core/services/blocks.d.ts +25 -0
  32. package/build/core/services/blocks.js +65 -0
  33. package/build/core/services/blocks.js.map +1 -0
  34. package/build/core/services/broadcast.d.ts +13 -0
  35. package/build/core/services/broadcast.js +24 -0
  36. package/build/core/services/broadcast.js.map +1 -0
  37. package/build/core/services/clients.d.ts +5 -0
  38. package/build/core/services/clients.js +29 -0
  39. package/build/core/services/clients.js.map +1 -0
  40. package/build/core/services/contract-data.d.ts +31 -0
  41. package/build/core/services/contract-data.js +54 -0
  42. package/build/core/services/contract-data.js.map +1 -0
  43. package/build/core/services/contracts.d.ts +108 -0
  44. package/build/core/services/contracts.js +482 -0
  45. package/build/core/services/contracts.js.map +1 -0
  46. package/build/core/services/events.d.ts +56 -0
  47. package/build/core/services/events.js +99 -0
  48. package/build/core/services/events.js.map +1 -0
  49. package/build/core/services/governance.d.ts +78 -0
  50. package/build/core/services/governance.js +207 -0
  51. package/build/core/services/governance.js.map +1 -0
  52. package/build/core/services/index.d.ts +28 -0
  53. package/build/core/services/index.js +81 -0
  54. package/build/core/services/index.js.map +1 -0
  55. package/build/core/services/mempool.d.ts +12 -0
  56. package/build/core/services/mempool.js +32 -0
  57. package/build/core/services/mempool.js.map +1 -0
  58. package/build/core/services/multicall-abi.d.ts +55 -0
  59. package/build/core/services/multicall-abi.js +61 -0
  60. package/build/core/services/multicall-abi.js.map +1 -0
  61. package/build/core/services/nodes.d.ts +8 -0
  62. package/build/core/services/nodes.js +18 -0
  63. package/build/core/services/nodes.js.map +1 -0
  64. package/build/core/services/proposals.d.ts +33 -0
  65. package/build/core/services/proposals.js +95 -0
  66. package/build/core/services/proposals.js.map +1 -0
  67. package/build/core/services/query.d.ts +34 -0
  68. package/build/core/services/query.js +60 -0
  69. package/build/core/services/query.js.map +1 -0
  70. package/build/core/services/staking.d.ts +40 -0
  71. package/build/core/services/staking.js +113 -0
  72. package/build/core/services/staking.js.map +1 -0
  73. package/build/core/services/tokens.d.ts +22 -0
  74. package/build/core/services/tokens.js +68 -0
  75. package/build/core/services/tokens.js.map +1 -0
  76. package/build/core/services/transactions.d.ts +16 -0
  77. package/build/core/services/transactions.js +42 -0
  78. package/build/core/services/transactions.js.map +1 -0
  79. package/build/core/services/transfer.d.ts +24 -0
  80. package/build/core/services/transfer.js +84 -0
  81. package/build/core/services/transfer.js.map +1 -0
  82. package/build/core/services/trongrid-client.d.ts +14 -0
  83. package/build/core/services/trongrid-client.js +19 -0
  84. package/build/core/services/trongrid-client.js.map +1 -0
  85. package/build/core/services/utils.d.ts +13 -0
  86. package/build/core/services/utils.js +39 -0
  87. package/build/core/services/utils.js.map +1 -0
  88. package/build/core/services/wallet.d.ts +13 -0
  89. package/build/core/services/wallet.js +18 -0
  90. package/build/core/services/wallet.js.map +1 -0
  91. package/build/core/tools/account-data.d.ts +2 -0
  92. package/build/core/tools/account-data.js +253 -0
  93. package/build/core/tools/account-data.js.map +1 -0
  94. package/build/core/tools/account-resource.d.ts +2 -0
  95. package/build/core/tools/account-resource.js +269 -0
  96. package/build/core/tools/account-resource.js.map +1 -0
  97. package/build/core/tools/account.d.ts +2 -0
  98. package/build/core/tools/account.js +451 -0
  99. package/build/core/tools/account.js.map +1 -0
  100. package/build/core/tools/address.d.ts +2 -0
  101. package/build/core/tools/address.js +45 -0
  102. package/build/core/tools/address.js.map +1 -0
  103. package/build/core/tools/balance.d.ts +2 -0
  104. package/build/core/tools/balance.js +94 -0
  105. package/build/core/tools/balance.js.map +1 -0
  106. package/build/core/tools/block.d.ts +2 -0
  107. package/build/core/tools/block.js +74 -0
  108. package/build/core/tools/block.js.map +1 -0
  109. package/build/core/tools/broadcast.d.ts +2 -0
  110. package/build/core/tools/broadcast.js +102 -0
  111. package/build/core/tools/broadcast.js.map +1 -0
  112. package/build/core/tools/contract-data.d.ts +2 -0
  113. package/build/core/tools/contract-data.js +159 -0
  114. package/build/core/tools/contract-data.js.map +1 -0
  115. package/build/core/tools/contract.d.ts +2 -0
  116. package/build/core/tools/contract.js +600 -0
  117. package/build/core/tools/contract.js.map +1 -0
  118. package/build/core/tools/event.d.ts +2 -0
  119. package/build/core/tools/event.js +159 -0
  120. package/build/core/tools/event.js.map +1 -0
  121. package/build/core/tools/governance.d.ts +6 -0
  122. package/build/core/tools/governance.js +424 -0
  123. package/build/core/tools/governance.js.map +1 -0
  124. package/build/core/tools/index.d.ts +15 -0
  125. package/build/core/tools/index.js +93 -0
  126. package/build/core/tools/index.js.map +1 -0
  127. package/build/core/tools/mempool.d.ts +2 -0
  128. package/build/core/tools/mempool.js +116 -0
  129. package/build/core/tools/mempool.js.map +1 -0
  130. package/build/core/tools/network.d.ts +2 -0
  131. package/build/core/tools/network.js +114 -0
  132. package/build/core/tools/network.js.map +1 -0
  133. package/build/core/tools/node.d.ts +2 -0
  134. package/build/core/tools/node.js +75 -0
  135. package/build/core/tools/node.js.map +1 -0
  136. package/build/core/tools/proposals.d.ts +6 -0
  137. package/build/core/tools/proposals.js +219 -0
  138. package/build/core/tools/proposals.js.map +1 -0
  139. package/build/core/tools/query.d.ts +2 -0
  140. package/build/core/tools/query.js +399 -0
  141. package/build/core/tools/query.js.map +1 -0
  142. package/build/core/tools/staking.d.ts +2 -0
  143. package/build/core/tools/staking.js +281 -0
  144. package/build/core/tools/staking.js.map +1 -0
  145. package/build/core/tools/transaction.d.ts +2 -0
  146. package/build/core/tools/transaction.js +65 -0
  147. package/build/core/tools/transaction.js.map +1 -0
  148. package/build/core/tools/transfer.d.ts +2 -0
  149. package/build/core/tools/transfer.js +101 -0
  150. package/build/core/tools/transfer.js.map +1 -0
  151. package/build/core/tools/types.d.ts +13 -0
  152. package/build/core/tools/types.js +2 -0
  153. package/build/core/tools/types.js.map +1 -0
  154. package/build/core/tools/wallet.d.ts +2 -0
  155. package/build/core/tools/wallet.js +172 -0
  156. package/build/core/tools/wallet.js.map +1 -0
  157. package/build/index.d.ts +1 -0
  158. package/build/index.js +21 -0
  159. package/build/index.js.map +1 -0
  160. package/build/middleware/auth.d.ts +16 -0
  161. package/build/middleware/auth.js +44 -0
  162. package/build/middleware/auth.js.map +1 -0
  163. package/build/oauth/OAuthService.d.ts +100 -0
  164. package/build/oauth/OAuthService.js +507 -0
  165. package/build/oauth/OAuthService.js.map +1 -0
  166. package/build/oauth/page.d.ts +1 -0
  167. package/build/oauth/page.js +255 -0
  168. package/build/oauth/page.js.map +1 -0
  169. package/build/oauth/types.d.ts +65 -0
  170. package/build/oauth/types.js +2 -0
  171. package/build/oauth/types.js.map +1 -0
  172. package/build/server/http-app.d.ts +9 -0
  173. package/build/server/http-app.js +128 -0
  174. package/build/server/http-app.js.map +1 -0
  175. package/build/server/http-server.d.ts +1 -0
  176. package/build/server/http-server.js +35 -0
  177. package/build/server/http-server.js.map +1 -0
  178. package/build/server/oauth-routes.d.ts +7 -0
  179. package/build/server/oauth-routes.js +157 -0
  180. package/build/server/oauth-routes.js.map +1 -0
  181. package/build/server/server.d.ts +9 -0
  182. package/build/server/server.js +54 -0
  183. package/build/server/server.js.map +1 -0
  184. package/build/tenant/TenantManager.d.ts +35 -0
  185. package/build/tenant/TenantManager.js +167 -0
  186. package/build/tenant/TenantManager.js.map +1 -0
  187. package/build/tenant/context.d.ts +11 -0
  188. package/build/tenant/context.js +23 -0
  189. package/build/tenant/context.js.map +1 -0
  190. package/build/tenant/types.d.ts +16 -0
  191. package/build/tenant/types.js +2 -0
  192. package/build/tenant/types.js.map +1 -0
  193. package/package.json +95 -0
@@ -0,0 +1,93 @@
1
+ import { requireTenantAuthContext } from "../../tenant/context.js";
2
+ import { registerWalletTools } from "./wallet.js";
3
+ import { registerNetworkTools } from "./network.js";
4
+ import { registerAddressTools } from "./address.js";
5
+ import { registerBlockTools } from "./block.js";
6
+ import { registerBalanceTools } from "./balance.js";
7
+ import { registerTransactionTools } from "./transaction.js";
8
+ import { registerContractTools } from "./contract.js";
9
+ import { registerTransferTools } from "./transfer.js";
10
+ import { registerStakingTools } from "./staking.js";
11
+ import { registerQueryTools } from "./query.js";
12
+ import { registerBroadcastTools } from "./broadcast.js";
13
+ import { registerNodeTools } from "./node.js";
14
+ import { registerMempoolTools } from "./mempool.js";
15
+ import { registerEventTools } from "./event.js";
16
+ import { registerAccountTools } from "./account.js";
17
+ import { registerGovernanceTools } from "./governance.js";
18
+ import { registerProposalTools } from "./proposals.js";
19
+ import { registerAccountDataTools } from "./account-data.js";
20
+ import { registerContractDataTools } from "./contract-data.js";
21
+ import { registerAccountResourceTools } from "./account-resource.js";
22
+ /**
23
+ * Register all TRON-related tools with the MCP server
24
+ *
25
+ * Write operations are registered up front and validate wallet availability
26
+ * when the tool handler runs. Private keys and mnemonics are never passed as
27
+ * tool arguments for security reasons.
28
+ *
29
+ * @param server The MCP server instance
30
+ * @param options Registration options (e.g., readOnly mode)
31
+ */
32
+ export function registerTRONTools(server, options = {}) {
33
+ /**
34
+ * Helper to register a tool with read-only gating.
35
+ * Write tools (`readOnlyHint` not true) are omitted when `options.readOnly` is set;
36
+ * wallet availability is validated inside handlers when invoked.
37
+ */
38
+ const registerTool = (name, definition, handler) => {
39
+ const annotations = definition.annotations || {};
40
+ // Default to false: tools without explicit readOnlyHint are treated as write-capable
41
+ // for safety. This is stricter than prompts.ts (which defaults to read-only) because
42
+ // tools can directly mutate blockchain state.
43
+ const isReadOnly = annotations.readOnlyHint === true;
44
+ // 1. Skip if in read-only mode and the tool is a write operation
45
+ if (options.readOnly && !isReadOnly) {
46
+ return;
47
+ }
48
+ if (options.transport === "http" && definition.legacyOnly === true) {
49
+ return;
50
+ }
51
+ const wrappedHandler = async (args) => {
52
+ try {
53
+ if (options.transport === "http") {
54
+ requireTenantAuthContext();
55
+ }
56
+ return await handler(args);
57
+ }
58
+ catch (error) {
59
+ return {
60
+ content: [
61
+ {
62
+ type: "text",
63
+ text: error instanceof Error ? error.message : String(error),
64
+ },
65
+ ],
66
+ isError: true,
67
+ };
68
+ }
69
+ };
70
+ server.registerTool(name, definition, wrappedHandler);
71
+ };
72
+ registerWalletTools(registerTool);
73
+ registerNetworkTools(registerTool);
74
+ registerAddressTools(registerTool);
75
+ registerBlockTools(registerTool);
76
+ registerBalanceTools(registerTool);
77
+ registerTransactionTools(registerTool);
78
+ registerContractTools(registerTool);
79
+ registerTransferTools(registerTool);
80
+ registerStakingTools(registerTool);
81
+ registerAccountResourceTools(registerTool);
82
+ registerQueryTools(registerTool);
83
+ registerBroadcastTools(registerTool);
84
+ registerNodeTools(registerTool);
85
+ registerMempoolTools(registerTool);
86
+ registerEventTools(registerTool);
87
+ registerAccountTools(registerTool);
88
+ registerGovernanceTools(registerTool);
89
+ registerProposalTools(registerTool);
90
+ registerAccountDataTools(registerTool);
91
+ registerContractDataTools(registerTool);
92
+ }
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAA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,CAAC,CAAC;IAClC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,kBAAkB,CAAC,YAAY,CAAC,CAAC;IACjC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACvC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACpC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACpC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,4BAA4B,CAAC,YAAY,CAAC,CAAC;IAC3C,kBAAkB,CAAC,YAAY,CAAC,CAAC;IACjC,sBAAsB,CAAC,YAAY,CAAC,CAAC;IACrC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAChC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,kBAAkB,CAAC,YAAY,CAAC,CAAC;IACjC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACnC,uBAAuB,CAAC,YAAY,CAAC,CAAC;IACtC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACpC,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACvC,yBAAyB,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RegisterToolFn } from "./types.js";
2
+ export declare function registerMempoolTools(registerTool: RegisterToolFn): void;
@@ -0,0 +1,116 @@
1
+ import { z } from "zod";
2
+ import * as services from "../services/index.js";
3
+ export function registerMempoolTools(registerTool) {
4
+ registerTool("get_pending_transactions", {
5
+ description: "Get the list of transaction IDs currently in the pending pool (mempool).",
6
+ inputSchema: {
7
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
8
+ },
9
+ annotations: {
10
+ title: "Get Pending Transactions",
11
+ readOnlyHint: true,
12
+ destructiveHint: false,
13
+ idempotentHint: false,
14
+ openWorldHint: true,
15
+ },
16
+ }, async ({ network = "mainnet" }) => {
17
+ try {
18
+ const txIds = await services.getTransactionListFromPending(network);
19
+ return {
20
+ content: [
21
+ {
22
+ type: "text",
23
+ text: services.helpers.formatJson({
24
+ pendingCount: txIds.length,
25
+ transactionIds: txIds,
26
+ }),
27
+ },
28
+ ],
29
+ };
30
+ }
31
+ catch (error) {
32
+ return {
33
+ content: [
34
+ {
35
+ type: "text",
36
+ text: `Error fetching pending transactions: ${error instanceof Error ? error.message : String(error)}`,
37
+ },
38
+ ],
39
+ isError: true,
40
+ };
41
+ }
42
+ });
43
+ registerTool("get_transaction_from_pending", {
44
+ description: "Get the details of a specific transaction from the pending pool by its transaction ID.",
45
+ inputSchema: {
46
+ txId: z
47
+ .string()
48
+ .length(64, "Transaction ID must be a 64-character hex string")
49
+ .regex(/^[0-9a-fA-F]{64}$/, "Transaction ID must be a valid hex string")
50
+ .describe("The transaction ID (hash) to look up in the pending pool"),
51
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
52
+ },
53
+ annotations: {
54
+ title: "Get Transaction From Pending",
55
+ readOnlyHint: true,
56
+ destructiveHint: false,
57
+ idempotentHint: true,
58
+ openWorldHint: true,
59
+ },
60
+ }, async ({ txId, network = "mainnet" }) => {
61
+ try {
62
+ const tx = await services.getTransactionFromPending(txId, network);
63
+ return {
64
+ content: [{ type: "text", text: services.helpers.formatJson(tx) }],
65
+ };
66
+ }
67
+ catch (error) {
68
+ return {
69
+ content: [
70
+ {
71
+ type: "text",
72
+ text: `Error fetching transaction from pending: ${error instanceof Error ? error.message : String(error)}`,
73
+ },
74
+ ],
75
+ isError: true,
76
+ };
77
+ }
78
+ });
79
+ registerTool("get_pending_size", {
80
+ description: "Get the number of transactions currently in the pending pool (mempool).",
81
+ inputSchema: {
82
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
83
+ },
84
+ annotations: {
85
+ title: "Get Pending Size",
86
+ readOnlyHint: true,
87
+ destructiveHint: false,
88
+ idempotentHint: false,
89
+ openWorldHint: true,
90
+ },
91
+ }, async ({ network = "mainnet" }) => {
92
+ try {
93
+ const size = await services.getPendingSize(network);
94
+ return {
95
+ content: [
96
+ {
97
+ type: "text",
98
+ text: services.helpers.formatJson({ pendingTransactionSize: size }),
99
+ },
100
+ ],
101
+ };
102
+ }
103
+ catch (error) {
104
+ return {
105
+ content: [
106
+ {
107
+ type: "text",
108
+ text: `Error fetching pending size: ${error instanceof Error ? error.message : String(error)}`,
109
+ },
110
+ ],
111
+ isError: true,
112
+ };
113
+ }
114
+ });
115
+ }
116
+ //# sourceMappingURL=mempool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mempool.js","sourceRoot":"","sources":["../../../src/core/tools/mempool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAGjD,MAAM,UAAU,oBAAoB,CAAC,YAA4B;IAC/D,YAAY,CACV,0BAA0B,EAC1B;QACE,WAAW,EAAE,0EAA0E;QACvF,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;SAC9E;QACD,WAAW,EAAE;YACX,KAAK,EAAE,0BAA0B;YACjC,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,EAAE,EAAE,OAAO,GAAG,SAAS,EAAE,EAAE,EAAE;QAChC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC;YACpE,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;4BAChC,YAAY,EAAE,KAAK,CAAC,MAAM;4BAC1B,cAAc,EAAE,KAAK;yBACtB,CAAC;qBACH;iBACF;aACF,CAAC;QACJ,CAAC;QA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js";
2
+ export declare function registerNetworkTools(registerTool: RegisterToolFn): void;
@@ -0,0 +1,114 @@
1
+ import { z } from "zod";
2
+ import { getSupportedNetworks, getRpcUrl } from "../chains.js";
3
+ import * as services from "../services/index.js";
4
+ export function registerNetworkTools(registerTool) {
5
+ registerTool("get_chain_info", {
6
+ description: "Get information about a TRON network: current block number and RPC endpoint",
7
+ inputSchema: {
8
+ network: z
9
+ .string()
10
+ .optional()
11
+ .describe("Network name (mainnet, nile, shasta). Defaults to mainnet."),
12
+ },
13
+ annotations: {
14
+ title: "Get Chain Info",
15
+ readOnlyHint: true,
16
+ destructiveHint: false,
17
+ idempotentHint: true,
18
+ openWorldHint: true,
19
+ },
20
+ }, async ({ network = "mainnet" }) => {
21
+ try {
22
+ const chainId = await services.getChainId(network);
23
+ const blockNumber = await services.getBlockNumber(network);
24
+ const rpcUrl = getRpcUrl(network);
25
+ return {
26
+ content: [
27
+ {
28
+ type: "text",
29
+ text: JSON.stringify({ network, chainId, blockNumber: blockNumber.toString(), rpcUrl }, null, 2),
30
+ },
31
+ ],
32
+ };
33
+ }
34
+ catch (error) {
35
+ return {
36
+ content: [
37
+ {
38
+ type: "text",
39
+ text: `Error fetching chain info: ${error instanceof Error ? error.message : String(error)}`,
40
+ },
41
+ ],
42
+ isError: true,
43
+ };
44
+ }
45
+ });
46
+ registerTool("get_supported_networks", {
47
+ description: "Get a list of all supported TRON networks",
48
+ inputSchema: {},
49
+ annotations: {
50
+ title: "Get Supported Networks",
51
+ readOnlyHint: true,
52
+ destructiveHint: false,
53
+ idempotentHint: true,
54
+ openWorldHint: false,
55
+ },
56
+ }, async () => {
57
+ try {
58
+ const networks = getSupportedNetworks();
59
+ return {
60
+ content: [
61
+ { type: "text", text: JSON.stringify({ supportedNetworks: networks }, null, 2) },
62
+ ],
63
+ };
64
+ }
65
+ catch (error) {
66
+ return {
67
+ content: [
68
+ {
69
+ type: "text",
70
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
71
+ },
72
+ ],
73
+ isError: true,
74
+ };
75
+ }
76
+ });
77
+ registerTool("get_chain_parameters", {
78
+ description: "Get current chain parameters including Energy and Bandwidth unit prices. Returns structured fee information similar to gas price queries.",
79
+ inputSchema: {
80
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
81
+ },
82
+ annotations: {
83
+ title: "Get Chain Parameters",
84
+ readOnlyHint: true,
85
+ destructiveHint: false,
86
+ idempotentHint: false,
87
+ openWorldHint: true,
88
+ },
89
+ }, async ({ network = "mainnet" }) => {
90
+ try {
91
+ const result = await services.getChainParameters(network);
92
+ return {
93
+ content: [
94
+ {
95
+ type: "text",
96
+ text: JSON.stringify(result, null, 2),
97
+ },
98
+ ],
99
+ };
100
+ }
101
+ catch (error) {
102
+ return {
103
+ content: [
104
+ {
105
+ type: "text",
106
+ text: `Error fetching chain parameters: ${error instanceof Error ? error.message : String(error)}`,
107
+ },
108
+ ],
109
+ isError: true,
110
+ };
111
+ }
112
+ });
113
+ }
114
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/core/tools/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAGjD,MAAM,UAAU,oBAAoB,CAAC,YAA4B;IAC/D,YAAY,CACV,gBAAgB,EAChB;QACE,WAAW,EAAE,6EAA6E;QAC1F,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;iBACP,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,4DAA4D,CAAC;SAC1E;QACD,WAAW,EAAE;YACX,KAAK,EAAE,gBAAgB;YACvB,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACpB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AK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACnG;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RegisterToolFn } from "./types.js";
2
+ export declare function registerNodeTools(registerTool: RegisterToolFn): void;
@@ -0,0 +1,75 @@
1
+ import { z } from "zod";
2
+ import * as services from "../services/index.js";
3
+ export function registerNodeTools(registerTool) {
4
+ registerTool("list_nodes", {
5
+ description: "List all connected node addresses on the TRON network. Returns an array of node IP:port strings.",
6
+ inputSchema: {
7
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
8
+ },
9
+ annotations: {
10
+ title: "List Nodes",
11
+ readOnlyHint: true,
12
+ destructiveHint: false,
13
+ idempotentHint: false,
14
+ openWorldHint: true,
15
+ },
16
+ }, async ({ network = "mainnet" }) => {
17
+ try {
18
+ const nodes = await services.listNodes(network);
19
+ return {
20
+ content: [
21
+ {
22
+ type: "text",
23
+ text: services.helpers.formatJson({
24
+ nodeCount: nodes.length,
25
+ nodes,
26
+ }),
27
+ },
28
+ ],
29
+ };
30
+ }
31
+ catch (error) {
32
+ return {
33
+ content: [
34
+ {
35
+ type: "text",
36
+ text: `Error listing nodes: ${error instanceof Error ? error.message : String(error)}`,
37
+ },
38
+ ],
39
+ isError: true,
40
+ };
41
+ }
42
+ });
43
+ registerTool("get_node_info", {
44
+ description: "Get detailed information about the current TRON node, including version, config, peers, and machine info.",
45
+ inputSchema: {
46
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
47
+ },
48
+ annotations: {
49
+ title: "Get Node Info",
50
+ readOnlyHint: true,
51
+ destructiveHint: false,
52
+ idempotentHint: false,
53
+ openWorldHint: true,
54
+ },
55
+ }, async ({ network = "mainnet" }) => {
56
+ try {
57
+ const info = await services.getNodeInfo(network);
58
+ return {
59
+ content: [{ type: "text", text: services.helpers.formatJson(info) }],
60
+ };
61
+ }
62
+ catch (error) {
63
+ return {
64
+ content: [
65
+ {
66
+ type: "text",
67
+ text: `Error fetching node info: ${error instanceof Error ? error.message : String(error)}`,
68
+ },
69
+ ],
70
+ isError: true,
71
+ };
72
+ }
73
+ });
74
+ }
75
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/core/tools/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAGjD,MAAM,UAAU,iBAAiB,CAAC,YAA4B;IAC5D,YAAY,CACV,YAAY,EACZ;QACE,WAAW,EACT,kGAAkG;QACpG,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;SAC9E;QACD,WAAW,EAAE;YACX,KAAK,EAAE,YAAY;YACnB,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,EAAE,EAAE,OAAO,GAAG,SAAS,EAAE,EAAE,EAAE;QAChC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAChD,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;4BAChC,SAAS,EAAE,KAAK,CAAC,MAAM;4BACvB,KAAK;yBACN,CAAC;qBACH;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,wBAAwB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACvF;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;IAEF,YAAY,CACV,eAAe,EACf;QACE,WAAW,EACT,2GAA2G;QAC7G,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;SAC9E;QACD,WAAW,EAAE;YACX,KAAK,EAAE,eAAe;YACtB,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,EAAE,EAAE,OAAO,GAAG,SAAS,EAAE,EAAE,EAAE;QAChC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACjD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;aACrE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,6BAA6B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBAC5F;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { RegisterToolFn } from "./types.js";
2
+ /**
3
+ * Register all proposal / governance-voting tools.
4
+ * Separated from the main tools file to reduce merge conflicts in multi-developer workflows.
5
+ */
6
+ export declare function registerProposalTools(registerTool: RegisterToolFn): void;
@@ -0,0 +1,219 @@
1
+ import { z } from "zod";
2
+ import * as services from "../services/index.js";
3
+ /**
4
+ * Register all proposal / governance-voting tools.
5
+ * Separated from the main tools file to reduce merge conflicts in multi-developer workflows.
6
+ */
7
+ export function registerProposalTools(registerTool) {
8
+ // ============================================================================
9
+ // PROPOSALS TOOLS (Read-only)
10
+ // ============================================================================
11
+ registerTool("list_proposals", {
12
+ description: "List all network governance proposals.",
13
+ inputSchema: {
14
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
15
+ },
16
+ annotations: {
17
+ title: "List Proposals",
18
+ readOnlyHint: true,
19
+ destructiveHint: false,
20
+ idempotentHint: false,
21
+ openWorldHint: true,
22
+ },
23
+ }, async ({ network = "mainnet" }) => {
24
+ try {
25
+ const proposals = await services.listProposals(network);
26
+ return {
27
+ content: [{ type: "text", text: services.helpers.formatJson(proposals) }],
28
+ };
29
+ }
30
+ catch (error) {
31
+ return {
32
+ content: [
33
+ {
34
+ type: "text",
35
+ text: `Error listing proposals: ${error instanceof Error ? error.message : String(error)}`,
36
+ },
37
+ ],
38
+ isError: true,
39
+ };
40
+ }
41
+ });
42
+ registerTool("get_proposal", {
43
+ description: "Get details of a specific governance proposal by its ID.",
44
+ inputSchema: {
45
+ proposalId: z.number().int().nonnegative().describe("The proposal ID"),
46
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
47
+ },
48
+ annotations: {
49
+ title: "Get Proposal by ID",
50
+ readOnlyHint: true,
51
+ destructiveHint: false,
52
+ idempotentHint: true,
53
+ openWorldHint: true,
54
+ },
55
+ }, async ({ proposalId, network = "mainnet" }) => {
56
+ try {
57
+ const proposal = await services.getProposalById(proposalId, network);
58
+ return {
59
+ content: [{ type: "text", text: services.helpers.formatJson(proposal) }],
60
+ };
61
+ }
62
+ catch (error) {
63
+ return {
64
+ content: [
65
+ {
66
+ type: "text",
67
+ text: `Error fetching proposal: ${error instanceof Error ? error.message : String(error)}`,
68
+ },
69
+ ],
70
+ isError: true,
71
+ };
72
+ }
73
+ });
74
+ // ============================================================================
75
+ // PROPOSALS TOOLS (Write operations — SR only)
76
+ // ============================================================================
77
+ registerTool("create_proposal", {
78
+ description: "Create a new network governance proposal (SR only). Provide a map of chain parameter IDs to proposed values.",
79
+ inputSchema: {
80
+ parameters: z
81
+ .record(z.string(), z.number())
82
+ .describe("Map of chain parameter key IDs (as string numbers) to proposed values. E.g. { '6': 100 } to propose changing parameter #6 to 100."),
83
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
84
+ },
85
+ annotations: {
86
+ title: "Create Governance Proposal",
87
+ readOnlyHint: false,
88
+ destructiveHint: false,
89
+ idempotentHint: false,
90
+ openWorldHint: true,
91
+ },
92
+ }, async ({ parameters, network = "mainnet" }) => {
93
+ try {
94
+ const senderAddress = await services.getOwnerAddress();
95
+ // Convert string keys to numbers as expected by the service
96
+ const numericParams = {};
97
+ for (const [k, v] of Object.entries(parameters)) {
98
+ numericParams[Number(k)] = v;
99
+ }
100
+ const txHash = await services.createProposal(numericParams, network);
101
+ return {
102
+ content: [
103
+ {
104
+ type: "text",
105
+ text: JSON.stringify({
106
+ network,
107
+ from: senderAddress,
108
+ parameters,
109
+ txHash,
110
+ message: "Proposal submitted. Use get_transaction_info to check confirmation, then list_proposals to find the proposal ID.",
111
+ }, null, 2),
112
+ },
113
+ ],
114
+ };
115
+ }
116
+ catch (error) {
117
+ return {
118
+ content: [
119
+ {
120
+ type: "text",
121
+ text: `Error creating proposal: ${error instanceof Error ? error.message : String(error)}`,
122
+ },
123
+ ],
124
+ isError: true,
125
+ };
126
+ }
127
+ });
128
+ registerTool("approve_proposal", {
129
+ description: "Vote to approve or disapprove a governance proposal (SR only).",
130
+ inputSchema: {
131
+ proposalId: z.number().int().nonnegative().describe("The proposal ID to vote on"),
132
+ approve: z.boolean().describe("true to approve, false to disapprove"),
133
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
134
+ },
135
+ annotations: {
136
+ title: "Approve / Reject Proposal",
137
+ readOnlyHint: false,
138
+ destructiveHint: false,
139
+ idempotentHint: false,
140
+ openWorldHint: true,
141
+ },
142
+ }, async ({ proposalId, approve, network = "mainnet" }) => {
143
+ try {
144
+ const senderAddress = await services.getOwnerAddress();
145
+ const txHash = await services.approveProposal(proposalId, approve, network);
146
+ return {
147
+ content: [
148
+ {
149
+ type: "text",
150
+ text: JSON.stringify({
151
+ network,
152
+ from: senderAddress,
153
+ proposalId,
154
+ approve,
155
+ txHash,
156
+ message: `Vote ${approve ? "approved" : "disapproved"} for proposal #${proposalId}.`,
157
+ }, null, 2),
158
+ },
159
+ ],
160
+ };
161
+ }
162
+ catch (error) {
163
+ return {
164
+ content: [
165
+ {
166
+ type: "text",
167
+ text: `Error approving proposal: ${error instanceof Error ? error.message : String(error)}`,
168
+ },
169
+ ],
170
+ isError: true,
171
+ };
172
+ }
173
+ });
174
+ registerTool("delete_proposal", {
175
+ description: "Delete a governance proposal (SR only, only the proposal creator can delete it).",
176
+ inputSchema: {
177
+ proposalId: z.number().int().nonnegative().describe("The proposal ID to delete"),
178
+ network: z.string().optional().describe("Network name. Defaults to mainnet."),
179
+ },
180
+ annotations: {
181
+ title: "Delete Proposal",
182
+ readOnlyHint: false,
183
+ destructiveHint: true,
184
+ idempotentHint: false,
185
+ openWorldHint: true,
186
+ },
187
+ }, async ({ proposalId, network = "mainnet" }) => {
188
+ try {
189
+ const senderAddress = await services.getOwnerAddress();
190
+ const txHash = await services.deleteProposal(proposalId, network);
191
+ return {
192
+ content: [
193
+ {
194
+ type: "text",
195
+ text: JSON.stringify({
196
+ network,
197
+ from: senderAddress,
198
+ proposalId,
199
+ txHash,
200
+ message: `Proposal #${proposalId} deletion submitted.`,
201
+ }, null, 2),
202
+ },
203
+ ],
204
+ };
205
+ }
206
+ catch (error) {
207
+ return {
208
+ content: [
209
+ {
210
+ type: "text",
211
+ text: `Error deleting proposal: ${error instanceof Error ? error.message : String(error)}`,
212
+ },
213
+ ],
214
+ isError: true,
215
+ };
216
+ }
217
+ });
218
+ }
219
+ //# sourceMappingURL=proposals.js.map