@gala-chain/launchpad-mcp-server 1.23.0 → 1.24.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 (102) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/DRY_REFACTORING_GUIDE.md +272 -0
  3. package/README.md +34 -6
  4. package/dist/constants/mcpToolNames.d.ts +6 -2
  5. package/dist/constants/mcpToolNames.d.ts.map +1 -1
  6. package/dist/constants/mcpToolNames.js +4 -2
  7. package/dist/constants/mcpToolNames.js.map +1 -1
  8. package/dist/generated/version.d.ts +1 -1
  9. package/dist/generated/version.js +1 -1
  10. package/dist/prompts/analysis.d.ts.map +1 -1
  11. package/dist/prompts/analysis.js +14 -63
  12. package/dist/prompts/analysis.js.map +1 -1
  13. package/dist/prompts/balances.d.ts.map +1 -1
  14. package/dist/prompts/balances.js +46 -70
  15. package/dist/prompts/balances.js.map +1 -1
  16. package/dist/prompts/creation-utils.d.ts.map +1 -1
  17. package/dist/prompts/creation-utils.js +27 -50
  18. package/dist/prompts/creation-utils.js.map +1 -1
  19. package/dist/prompts/explore-dex-pools.d.ts +20 -0
  20. package/dist/prompts/explore-dex-pools.d.ts.map +1 -0
  21. package/dist/prompts/explore-dex-pools.js +132 -0
  22. package/dist/prompts/explore-dex-pools.js.map +1 -0
  23. package/dist/prompts/index.d.ts +3 -2
  24. package/dist/prompts/index.d.ts.map +1 -1
  25. package/dist/prompts/index.js +6 -3
  26. package/dist/prompts/index.js.map +1 -1
  27. package/dist/prompts/liquidity-positions.d.ts.map +1 -1
  28. package/dist/prompts/liquidity-positions.js +9 -44
  29. package/dist/prompts/liquidity-positions.js.map +1 -1
  30. package/dist/prompts/pools.d.ts.map +1 -1
  31. package/dist/prompts/pools.js +125 -228
  32. package/dist/prompts/pools.js.map +1 -1
  33. package/dist/prompts/portfolio.d.ts.map +1 -1
  34. package/dist/prompts/portfolio.js +13 -48
  35. package/dist/prompts/portfolio.js.map +1 -1
  36. package/dist/prompts/social.d.ts.map +1 -1
  37. package/dist/prompts/social.js +21 -31
  38. package/dist/prompts/social.js.map +1 -1
  39. package/dist/prompts/trading-calculations.d.ts.map +1 -1
  40. package/dist/prompts/trading-calculations.js +37 -126
  41. package/dist/prompts/trading-calculations.js.map +1 -1
  42. package/dist/prompts/trading.d.ts.map +1 -1
  43. package/dist/prompts/trading.js +23 -60
  44. package/dist/prompts/trading.js.map +1 -1
  45. package/dist/prompts/transfers.d.ts.map +1 -1
  46. package/dist/prompts/transfers.js +21 -31
  47. package/dist/prompts/transfers.js.map +1 -1
  48. package/dist/prompts/utility-tools.d.ts.map +1 -1
  49. package/dist/prompts/utility-tools.js +83 -202
  50. package/dist/prompts/utility-tools.js.map +1 -1
  51. package/dist/prompts/utility.d.ts.map +1 -1
  52. package/dist/prompts/utility.js +5 -20
  53. package/dist/prompts/utility.js.map +1 -1
  54. package/dist/prompts/utils/handlerHelpers.d.ts +35 -0
  55. package/dist/prompts/utils/handlerHelpers.d.ts.map +1 -0
  56. package/dist/prompts/utils/handlerHelpers.js +53 -0
  57. package/dist/prompts/utils/handlerHelpers.js.map +1 -0
  58. package/dist/prompts/utils/textTemplates.d.ts +42 -0
  59. package/dist/prompts/utils/textTemplates.d.ts.map +1 -0
  60. package/dist/prompts/utils/textTemplates.js +51 -0
  61. package/dist/prompts/utils/textTemplates.js.map +1 -0
  62. package/dist/tools/dex/fetchAllDexPools.d.ts +9 -0
  63. package/dist/tools/dex/fetchAllDexPools.d.ts.map +1 -0
  64. package/dist/tools/dex/fetchAllDexPools.js +45 -0
  65. package/dist/tools/dex/fetchAllDexPools.js.map +1 -0
  66. package/dist/tools/dex/fetchDexPools.d.ts +9 -0
  67. package/dist/tools/dex/fetchDexPools.d.ts.map +1 -0
  68. package/dist/tools/dex/fetchDexPools.js +58 -0
  69. package/dist/tools/dex/fetchDexPools.js.map +1 -0
  70. package/dist/tools/dex/index.d.ts +4 -3
  71. package/dist/tools/dex/index.d.ts.map +1 -1
  72. package/dist/tools/dex/index.js +9 -4
  73. package/dist/tools/dex/index.js.map +1 -1
  74. package/dist/utils/validation.d.ts +38 -0
  75. package/dist/utils/validation.d.ts.map +1 -1
  76. package/dist/utils/validation.js +52 -0
  77. package/dist/utils/validation.js.map +1 -1
  78. package/package.json +3 -3
  79. package/src/__tests__/server.test.ts +1 -2
  80. package/src/constants/mcpToolNames.ts +4 -2
  81. package/src/prompts/__tests__/promptStructure.test.ts +50 -0
  82. package/src/prompts/__tests__/registry.test.ts +23 -33
  83. package/src/prompts/analysis.ts +15 -64
  84. package/src/prompts/balances.ts +57 -73
  85. package/src/prompts/creation-utils.ts +34 -49
  86. package/src/prompts/explore-dex-pools.ts +138 -0
  87. package/src/prompts/index.ts +5 -2
  88. package/src/prompts/liquidity-positions.ts +11 -44
  89. package/src/prompts/pools.ts +156 -231
  90. package/src/prompts/portfolio.ts +13 -47
  91. package/src/prompts/social.ts +25 -31
  92. package/src/prompts/trading-calculations.ts +42 -127
  93. package/src/prompts/trading.ts +30 -61
  94. package/src/prompts/transfers.ts +25 -31
  95. package/src/prompts/utility-tools.ts +116 -199
  96. package/src/prompts/utility.ts +5 -20
  97. package/src/prompts/utils/handlerHelpers.ts +55 -0
  98. package/src/prompts/utils/textTemplates.ts +73 -0
  99. package/src/tools/dex/fetchAllDexPools.ts +45 -0
  100. package/src/tools/dex/fetchDexPools.ts +58 -0
  101. package/src/tools/dex/index.ts +9 -4
  102. package/src/utils/validation.ts +58 -0
@@ -6,6 +6,8 @@
6
6
 
7
7
  import type { MCPPrompt } from '../types/mcp.js';
8
8
  import { MCP_TOOLS } from '../constants/mcpToolNames.js';
9
+ import { createPromptResponse } from './utils/handlerHelpers.js';
10
+ import { createSimpleOperationText } from './utils/textTemplates.js';
9
11
 
10
12
  /**
11
13
  * Create Wallet - Generate new wallet
@@ -13,24 +15,15 @@ import { MCP_TOOLS } from '../constants/mcpToolNames.js';
13
15
  export const createWalletPrompt: MCPPrompt = {
14
16
  name: 'galachain-launchpad:create-wallet',
15
17
  description: 'Generate a new wallet with random private key',
16
- handler: () => {
17
- return [
18
- {
19
- role: 'user',
20
- content: {
21
- type: 'text',
22
- text: `Create a new wallet with random private key.
23
-
24
- Use ${MCP_TOOLS.CREATE_WALLET} to generate:
25
- - New wallet address
26
- - Random private key
27
- - Wallet credentials for authentication
28
-
29
- Display the wallet details with a security warning about private key storage.`,
30
- },
31
- },
32
- ];
33
- },
18
+ handler: () =>
19
+ createPromptResponse(
20
+ createSimpleOperationText({
21
+ operation: 'Create a new wallet with random private key.',
22
+ toolName: MCP_TOOLS.CREATE_WALLET,
23
+ actionDescription: 'generate new wallet address, random private key, and wallet credentials for authentication',
24
+ displayFormat: 'Display the wallet details with a security warning about private key storage.',
25
+ })
26
+ ),
34
27
  };
35
28
 
36
29
  /**
@@ -39,21 +32,15 @@ Display the wallet details with a security warning about private key storage.`,
39
32
  export const getAddressPrompt: MCPPrompt = {
40
33
  name: 'galachain-launchpad:get-address',
41
34
  description: 'Get the GalaChain address format of authenticated wallet',
42
- handler: () => {
43
- return [
44
- {
45
- role: 'user',
46
- content: {
47
- type: 'text',
48
- text: `Get the GalaChain format address of the authenticated wallet.
49
-
50
- Use ${MCP_TOOLS.GET_ADDRESS} to retrieve the address in GalaChain format (eth|0x...).
51
-
52
- Display the wallet address.`,
53
- },
54
- },
55
- ];
56
- },
35
+ handler: () =>
36
+ createPromptResponse(
37
+ createSimpleOperationText({
38
+ operation: 'Get the GalaChain format address of the authenticated wallet.',
39
+ toolName: MCP_TOOLS.GET_ADDRESS,
40
+ actionDescription: 'retrieve the address in GalaChain format (eth|0x...)',
41
+ displayFormat: 'Display the wallet address.',
42
+ })
43
+ ),
57
44
  };
58
45
 
59
46
  /**
@@ -62,21 +49,15 @@ Display the wallet address.`,
62
49
  export const getEthereumAddressPrompt: MCPPrompt = {
63
50
  name: 'galachain-launchpad:get-ethereum-address',
64
51
  description: 'Get the standard Ethereum address format of authenticated wallet',
65
- handler: () => {
66
- return [
67
- {
68
- role: 'user',
69
- content: {
70
- type: 'text',
71
- text: `Get the standard Ethereum format address of the authenticated wallet.
72
-
73
- Use ${MCP_TOOLS.GET_ETHEREUM_ADDRESS} to retrieve the address in Ethereum format (0x...).
74
-
75
- Display the wallet address.`,
76
- },
77
- },
78
- ];
79
- },
52
+ handler: () =>
53
+ createPromptResponse(
54
+ createSimpleOperationText({
55
+ operation: 'Get the standard Ethereum format address of the authenticated wallet.',
56
+ toolName: MCP_TOOLS.GET_ETHEREUM_ADDRESS,
57
+ actionDescription: 'retrieve the address in Ethereum format (0x...)',
58
+ displayFormat: 'Display the wallet address.',
59
+ })
60
+ ),
80
61
  };
81
62
 
82
63
  /**
@@ -85,27 +66,15 @@ Display the wallet address.`,
85
66
  export const getConfigPrompt: MCPPrompt = {
86
67
  name: 'galachain-launchpad:get-config',
87
68
  description: 'View current SDK and MCP server configuration',
88
- handler: () => {
89
- return [
90
- {
91
- role: 'user',
92
- content: {
93
- type: 'text',
94
- text: `Get the current SDK and MCP server configuration.
95
-
96
- Use ${MCP_TOOLS.GET_CONFIG} to retrieve:
97
- - Environment (production, development, testing)
98
- - Base URLs
99
- - Timeout settings
100
- - Feature flags
101
- - Effective slippage tolerance factors
102
- - Current MCP server environment state
103
-
104
- Display the configuration in a readable format.`,
105
- },
106
- },
107
- ];
108
- },
69
+ handler: () =>
70
+ createPromptResponse(
71
+ createSimpleOperationText({
72
+ operation: 'Get the current SDK and MCP server configuration.',
73
+ toolName: MCP_TOOLS.GET_CONFIG,
74
+ actionDescription: 'retrieve environment, base URLs, timeout settings, feature flags, effective slippage tolerance factors, and current MCP server state',
75
+ displayFormat: 'Display the configuration in a readable format.',
76
+ })
77
+ ),
109
78
  };
110
79
 
111
80
  /**
@@ -121,23 +90,18 @@ export const getUrlByTokenNamePrompt: MCPPrompt = {
121
90
  required: true,
122
91
  },
123
92
  ],
124
- handler: (args) => {
125
- return [
126
- {
127
- role: 'user',
128
- content: {
129
- type: 'text',
130
- text: `Get the launchpad frontend URL for a token.
131
-
132
- Token: ${args.tokenName}
133
-
134
- Use ${MCP_TOOLS.GET_URL_BY_TOKEN_NAME} to generate the URL.
135
-
136
- Display the complete launchpad URL for viewing/trading the token.`,
93
+ handler: (args) =>
94
+ createPromptResponse(
95
+ createSimpleOperationText({
96
+ operation: 'Get the launchpad frontend URL for a token.',
97
+ parameters: {
98
+ token_name: `Token: ${args.tokenName}`,
137
99
  },
138
- },
139
- ];
140
- },
100
+ toolName: MCP_TOOLS.GET_URL_BY_TOKEN_NAME,
101
+ actionDescription: 'generate the URL',
102
+ displayFormat: 'Display the complete launchpad URL for viewing/trading the token.',
103
+ })
104
+ ),
141
105
  };
142
106
 
143
107
  /**
@@ -153,21 +117,15 @@ export const explainSdkUsagePrompt: MCPPrompt = {
153
117
  required: true,
154
118
  },
155
119
  ],
156
- handler: (args) => {
157
- return [
158
- {
159
- role: 'user',
160
- content: {
161
- type: 'text',
162
- text: `Get detailed SDK usage examples for topic: ${args.topic}
163
-
164
- Use ${MCP_TOOLS.EXPLAIN_SDK_USAGE} to retrieve complete runnable code examples.
165
-
166
- Display the examples with explanations for integrating the SDK directly.`,
167
- },
168
- },
169
- ];
170
- },
120
+ handler: (args) =>
121
+ createPromptResponse(
122
+ createSimpleOperationText({
123
+ operation: `Get detailed SDK usage examples for topic: ${args.topic}.`,
124
+ toolName: MCP_TOOLS.EXPLAIN_SDK_USAGE,
125
+ actionDescription: 'retrieve complete runnable code examples',
126
+ displayFormat: 'Display the examples with explanations for integrating the SDK directly.',
127
+ })
128
+ ),
171
129
  };
172
130
 
173
131
  /**
@@ -176,24 +134,15 @@ Display the examples with explanations for integrating the SDK directly.`,
176
134
  export const getCacheInfoPrompt: MCPPrompt = {
177
135
  name: 'galachain-launchpad:get-cache-info',
178
136
  description: 'Get token metadata cache statistics',
179
- handler: () => {
180
- return [
181
- {
182
- role: 'user',
183
- content: {
184
- type: 'text',
185
- text: `Get token metadata cache statistics.
186
-
187
- Use ${MCP_TOOLS.GET_CACHE_INFO} to retrieve:
188
- - Total tokens cached
189
- - Cache size in bytes
190
- - Timestamp of oldest entry
191
-
192
- Display the cache information.`,
193
- },
194
- },
195
- ];
196
- },
137
+ handler: () =>
138
+ createPromptResponse(
139
+ createSimpleOperationText({
140
+ operation: 'Get token metadata cache statistics.',
141
+ toolName: MCP_TOOLS.GET_CACHE_INFO,
142
+ actionDescription: 'retrieve total tokens cached, cache size in bytes, and timestamp of oldest entry',
143
+ displayFormat: 'Display the cache information.',
144
+ })
145
+ ),
197
146
  };
198
147
 
199
148
  /**
@@ -209,23 +158,18 @@ export const clearCachePrompt: MCPPrompt = {
209
158
  required: false,
210
159
  },
211
160
  ],
212
- handler: (args) => {
213
- return [
214
- {
215
- role: 'user',
216
- content: {
217
- type: 'text',
218
- text: `Clear token metadata cache.
219
-
220
- ${args.tokenName ? `Token: ${args.tokenName}` : 'Clearing entire cache'}
221
-
222
- Use ${MCP_TOOLS.CLEAR_CACHE} to clear the cache.
223
-
224
- Display confirmation of cache clearing.`,
161
+ handler: (args) =>
162
+ createPromptResponse(
163
+ createSimpleOperationText({
164
+ operation: 'Clear token metadata cache.',
165
+ parameters: {
166
+ token_name: args.tokenName ? `Token: ${args.tokenName}` : 'Clearing entire cache',
225
167
  },
226
- },
227
- ];
228
- },
168
+ toolName: MCP_TOOLS.CLEAR_CACHE,
169
+ actionDescription: 'clear the cache',
170
+ displayFormat: 'Display confirmation of cache clearing.',
171
+ })
172
+ ),
229
173
  };
230
174
 
231
175
  /**
@@ -234,23 +178,15 @@ Display confirmation of cache clearing.`,
234
178
  export const hasWalletPrompt: MCPPrompt = {
235
179
  name: 'galachain-launchpad:has-wallet',
236
180
  description: 'Check if a wallet is configured in the MCP server',
237
- handler: () => {
238
- return [
239
- {
240
- role: 'user',
241
- content: {
242
- type: 'text',
243
- text: `Check wallet configuration status.
244
-
245
- Use ${MCP_TOOLS.HAS_WALLET} to determine:
246
- - Whether a wallet is configured
247
- - Whether MCP server is in full-access or read-only mode
248
-
249
- Display the wallet status clearly.`,
250
- },
251
- },
252
- ];
253
- },
181
+ handler: () =>
182
+ createPromptResponse(
183
+ createSimpleOperationText({
184
+ operation: 'Check wallet configuration status.',
185
+ toolName: MCP_TOOLS.HAS_WALLET,
186
+ actionDescription: 'determine whether a wallet is configured and whether MCP server is in full-access or read-only mode',
187
+ displayFormat: 'Display the wallet status clearly.',
188
+ })
189
+ ),
254
190
  };
255
191
 
256
192
  /**
@@ -259,23 +195,15 @@ Display the wallet status clearly.`,
259
195
  export const getWalletPrompt: MCPPrompt = {
260
196
  name: 'galachain-launchpad:get-wallet',
261
197
  description: 'Get the currently configured wallet instance',
262
- handler: () => {
263
- return [
264
- {
265
- role: 'user',
266
- content: {
267
- type: 'text',
268
- text: `Get the currently configured wallet instance.
269
-
270
- Use ${MCP_TOOLS.GET_WALLET} to retrieve:
271
- - Wallet object if available
272
- - Null if in read-only mode
273
-
274
- Display the wallet information.`,
275
- },
276
- },
277
- ];
278
- },
198
+ handler: () =>
199
+ createPromptResponse(
200
+ createSimpleOperationText({
201
+ operation: 'Get the currently configured wallet instance.',
202
+ toolName: MCP_TOOLS.GET_WALLET,
203
+ actionDescription: 'retrieve wallet object if available (null if in read-only mode)',
204
+ displayFormat: 'Display the wallet information.',
205
+ })
206
+ ),
279
207
  };
280
208
 
281
209
  /**
@@ -291,23 +219,18 @@ export const setWalletPrompt: MCPPrompt = {
291
219
  required: true,
292
220
  },
293
221
  ],
294
- handler: (args) => {
295
- return [
296
- {
297
- role: 'user',
298
- content: {
299
- type: 'text',
300
- text: `Configure wallet for signing operations.
301
-
302
- Private Key: ${args.privateKey.substring(0, 10)}...${args.privateKey.substring(60)}
303
-
304
- Use ${MCP_TOOLS.SET_WALLET} to configure the wallet.
305
-
306
- Display confirmation that wallet is configured for full-access mode.`,
222
+ handler: (args) =>
223
+ createPromptResponse(
224
+ createSimpleOperationText({
225
+ operation: 'Configure wallet for signing operations.',
226
+ parameters: {
227
+ private_key: `Private Key: ${args.privateKey.substring(0, 10)}...${args.privateKey.substring(60)}`,
307
228
  },
308
- },
309
- ];
310
- },
229
+ toolName: MCP_TOOLS.SET_WALLET,
230
+ actionDescription: 'configure the wallet',
231
+ displayFormat: 'Display confirmation that wallet is configured for full-access mode.',
232
+ })
233
+ ),
311
234
  };
312
235
 
313
236
  /**
@@ -316,21 +239,15 @@ Display confirmation that wallet is configured for full-access mode.`,
316
239
  export const getEnvironmentPrompt: MCPPrompt = {
317
240
  name: 'galachain-launchpad:get-environment',
318
241
  description: 'Get the current MCP server environment',
319
- handler: () => {
320
- return [
321
- {
322
- role: 'user',
323
- content: {
324
- type: 'text',
325
- text: `Get the current MCP server environment.
326
-
327
- Use ${MCP_TOOLS.GET_ENVIRONMENT} to retrieve the active environment.
328
-
329
- Display the current environment (production, development, or testing).`,
330
- },
331
- },
332
- ];
333
- },
242
+ handler: () =>
243
+ createPromptResponse(
244
+ createSimpleOperationText({
245
+ operation: 'Get the current MCP server environment.',
246
+ toolName: MCP_TOOLS.GET_ENVIRONMENT,
247
+ actionDescription: 'retrieve the active environment',
248
+ displayFormat: 'Display the current environment (production, development, or testing).',
249
+ })
250
+ ),
334
251
  };
335
252
 
336
253
  export const utilityToolPrompts: MCPPrompt[] = [
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { MCPPrompt } from '../types/mcp.js';
8
+ import { createPromptResponse } from './utils/handlerHelpers.js';
8
9
 
9
10
  /**
10
11
  * Get Version - Display SDK and MCP server version information
@@ -16,12 +17,7 @@ export const getVersionPrompt: MCPPrompt = {
16
17
  name: 'galachain-launchpad:version',
17
18
  description: 'Get SDK and MCP server version information',
18
19
  handler: () => {
19
- return [
20
- {
21
- role: 'user',
22
- content: {
23
- type: 'text',
24
- text: `Get version information for the Gala Launchpad SDK and MCP server.
20
+ return createPromptResponse(`Get version information for the Gala Launchpad SDK and MCP server.
25
21
 
26
22
  Use the gala_launchpad_get_version tool to fetch the version details.
27
23
 
@@ -30,10 +26,7 @@ Display the results in a clear, formatted response showing:
30
26
  2. MCP Server Version
31
27
  3. Timestamp
32
28
 
33
- This is helpful for debugging version compatibility issues or confirming installed versions.`,
34
- },
35
- },
36
- ];
29
+ This is helpful for debugging version compatibility issues or confirming installed versions.`);
37
30
  },
38
31
  };
39
32
 
@@ -59,12 +52,7 @@ export const switchEnvironmentPrompt: MCPPrompt = {
59
52
  const validEnvs = ['production', 'development', 'testing'];
60
53
  const isValidEnv = validEnvs.includes(targetEnv);
61
54
 
62
- return [
63
- {
64
- role: 'user',
65
- content: {
66
- type: 'text',
67
- text: `Switch the Gala Launchpad MCP server to a different environment.
55
+ return createPromptResponse(`Switch the Gala Launchpad MCP server to a different environment.
68
56
 
69
57
  Current task: Switch to the ${isValidEnv ? targetEnv : 'specified'} environment
70
58
 
@@ -79,10 +67,7 @@ Available environments:
79
67
  - development: Development environment for testing features
80
68
  - testing: Testing environment for local/staging tests
81
69
 
82
- Wallet Preservation: The wallet configuration will be preserved during the switch, maintaining your current signing capabilities if configured.`,
83
- },
84
- },
85
- ];
70
+ Wallet Preservation: The wallet configuration will be preserved during the switch, maintaining your current signing capabilities if configured.`);
86
71
  },
87
72
  };
88
73
 
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Handler Helper Utilities
3
+ *
4
+ * Provides reusable utilities for creating MCP prompt handlers with
5
+ * standardized response formatting and validation patterns.
6
+ */
7
+
8
+ import type { PromptMessage } from '../../types/mcp.js';
9
+
10
+ /**
11
+ * Create a standard MCP prompt response with user role
12
+ *
13
+ * @param text - The prompt text to send to the user
14
+ * @returns Array containing formatted MCP message
15
+ *
16
+ * @example
17
+ * handler: (args) => {
18
+ * validateTokenName(args.tokenName);
19
+ * return createPromptResponse(`Fetch token ${args.tokenName}...`);
20
+ * }
21
+ */
22
+ export function createPromptResponse(text: string): PromptMessage[] {
23
+ return [
24
+ {
25
+ role: 'user',
26
+ content: {
27
+ type: 'text',
28
+ text,
29
+ },
30
+ },
31
+ ];
32
+ }
33
+
34
+ /**
35
+ * Create a handler function that validates arguments and returns a prompt response
36
+ *
37
+ * @param validator - Function to validate the arguments
38
+ * @param textGenerator - Function that generates the prompt text from arguments
39
+ * @returns A handler function ready to use in a prompt definition
40
+ *
41
+ * @example
42
+ * handler: createValidatedHandler(
43
+ * (args) => validateTokenName(args.tokenName),
44
+ * (args) => `Fetch token ${args.tokenName}...`
45
+ * )
46
+ */
47
+ export function createValidatedHandler<T>(
48
+ validator: (args: T) => void,
49
+ textGenerator: (args: T) => string
50
+ ): (args: T) => PromptMessage[] {
51
+ return (args: T) => {
52
+ validator(args);
53
+ return createPromptResponse(textGenerator(args));
54
+ };
55
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Prompt Text Templates
3
+ *
4
+ * Provides reusable template generators for common MCP prompt patterns.
5
+ */
6
+
7
+ /**
8
+ * Configuration for simple operation prompts
9
+ */
10
+ export interface SimpleOperationConfig {
11
+ /** Operation description (e.g., "Fetch GALA balance for wallet.") */
12
+ operation: string;
13
+
14
+ /** Parameter descriptions as key-value pairs (optional) */
15
+ parameters?: Record<string, string | undefined>;
16
+
17
+ /** MCP tool name (e.g., MCP_TOOLS.FETCH_GALA_BALANCE) */
18
+ toolName: string;
19
+
20
+ /** Description of what the tool does (e.g., "retrieve the GALA balance") */
21
+ actionDescription: string;
22
+
23
+ /** Optional display format instructions */
24
+ displayFormat?: string;
25
+ }
26
+
27
+ /**
28
+ * Generate text for simple operation prompts
29
+ *
30
+ * Creates a standardized prompt text with operation, parameters, tool usage,
31
+ * and optional display format instructions.
32
+ *
33
+ * @param config - Configuration for the operation
34
+ * @returns Formatted prompt text
35
+ *
36
+ * @example
37
+ * text: createSimpleOperationText({
38
+ * operation: 'Get GALA balance for wallet.',
39
+ * parameters: {
40
+ * address: args.address ? `Address: ${args.address}` : 'Using default wallet'
41
+ * },
42
+ * toolName: MCP_TOOLS.FETCH_GALA_BALANCE,
43
+ * actionDescription: 'retrieve the GALA balance',
44
+ * displayFormat: 'Display the balance in a clear format.'
45
+ * })
46
+ */
47
+ export function createSimpleOperationText(config: SimpleOperationConfig): string {
48
+ const { operation, parameters, toolName, actionDescription, displayFormat } = config;
49
+
50
+ const parts: string[] = [operation];
51
+
52
+ // Add parameters section
53
+ if (parameters && Object.values(parameters).some((v) => v !== undefined)) {
54
+ parts.push('');
55
+ Object.entries(parameters).forEach(([, value]) => {
56
+ if (value !== undefined && value !== null && value !== '') {
57
+ parts.push(value);
58
+ }
59
+ });
60
+ }
61
+
62
+ // Add tool usage instruction
63
+ parts.push('');
64
+ parts.push(`Use ${toolName} to ${actionDescription}.`);
65
+
66
+ // Add display format if provided
67
+ if (displayFormat) {
68
+ parts.push('');
69
+ parts.push(displayFormat);
70
+ }
71
+
72
+ return parts.join('\n');
73
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Fetch All DEX Pools Tool
3
+ *
4
+ * Convenience tool that fetches all available DEX pools with automatic pagination.
5
+ * No page/limit parameters needed - returns ALL pools matching filters.
6
+ */
7
+
8
+ import type { MCPTool } from '../../types/mcp.js';
9
+ import { formatSuccess } from '../../utils/response-formatter.js';
10
+ import { withErrorHandling } from '../../utils/error-handler.js';
11
+
12
+ export const fetchAllDexPoolsTool: MCPTool = {
13
+ name: 'gala_launchpad_fetch_all_dex_pools',
14
+ description: 'Fetch all DEX pools with automatic pagination. No page/limit parameters needed - returns ALL pools matching filters.',
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ search: {
19
+ type: 'string',
20
+ minLength: 1,
21
+ maxLength: 100,
22
+ description: 'Search filter for token symbols in pool pair (e.g., "GALA", "GUSDC")',
23
+ },
24
+ sortBy: {
25
+ type: 'string',
26
+ enum: ['tvl', 'volume30d', 'volume1d'],
27
+ description: 'Field to sort results by (default: tvl)',
28
+ },
29
+ sortOrder: {
30
+ type: 'string',
31
+ enum: ['asc', 'desc'],
32
+ description: 'Sort order direction (default: desc)',
33
+ },
34
+ },
35
+ },
36
+ handler: withErrorHandling(async (sdk, args) => {
37
+ const result = await sdk.fetchAllDexPools({
38
+ ...(args.search && { search: args.search }),
39
+ ...(args.sortBy && { sortBy: args.sortBy }),
40
+ ...(args.sortOrder && { sortOrder: args.sortOrder }),
41
+ });
42
+
43
+ return formatSuccess(result);
44
+ }),
45
+ };