@gala-chain/launchpad-mcp-server 1.13.3 → 1.13.4

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 (61) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/generated/version.d.ts +1 -1
  3. package/dist/generated/version.js +1 -1
  4. package/docs/AI-AGENT-PATTERNS.md +555 -0
  5. package/docs/CONSTRAINTS-REFERENCE.md +454 -0
  6. package/docs/PROMPT-TOOL-MAPPING.md +352 -0
  7. package/docs/examples/default-values-pattern.md +240 -0
  8. package/docs/examples/tool-factory-pattern.md +217 -0
  9. package/jest.config.js +94 -0
  10. package/package.json +2 -2
  11. package/src/__tests__/integration/poolTools.integration.test.ts +185 -0
  12. package/src/constants/mcpToolNames.ts +141 -0
  13. package/src/index.ts +19 -0
  14. package/src/prompts/__tests__/promptStructure.test.ts +114 -0
  15. package/src/prompts/__tests__/registry.test.ts +143 -0
  16. package/src/prompts/analysis.ts +429 -0
  17. package/src/prompts/index.ts +127 -0
  18. package/src/prompts/portfolio.ts +242 -0
  19. package/src/prompts/trading.ts +191 -0
  20. package/src/prompts/utility.ts +43 -0
  21. package/src/prompts/utils/workflowTemplates.ts +344 -0
  22. package/src/schemas/common-schemas.ts +392 -0
  23. package/src/scripts/test-all-prompts.ts +184 -0
  24. package/src/server.ts +247 -0
  25. package/src/tools/balance/index.ts +174 -0
  26. package/src/tools/creation/index.ts +182 -0
  27. package/src/tools/index.ts +80 -0
  28. package/src/tools/pools/fetchAllPools.ts +47 -0
  29. package/src/tools/pools/fetchAllPriceHistory.ts +103 -0
  30. package/src/tools/pools/fetchAllPrices.ts +39 -0
  31. package/src/tools/pools/fetchPoolDetails.ts +27 -0
  32. package/src/tools/pools/fetchPoolDetailsForCalculation.ts +22 -0
  33. package/src/tools/pools/fetchPools.ts +47 -0
  34. package/src/tools/pools/fetchPriceHistory.ts +108 -0
  35. package/src/tools/pools/fetchPrices.ts +52 -0
  36. package/src/tools/pools/index.ts +248 -0
  37. package/src/tools/social/index.ts +64 -0
  38. package/src/tools/trading/index.ts +605 -0
  39. package/src/tools/transfers/index.ts +75 -0
  40. package/src/tools/utils/clearCache.ts +36 -0
  41. package/src/tools/utils/createWallet.ts +19 -0
  42. package/src/tools/utils/explainSdkUsage.ts +853 -0
  43. package/src/tools/utils/getAddress.ts +12 -0
  44. package/src/tools/utils/getCacheInfo.ts +14 -0
  45. package/src/tools/utils/getConfig.ts +11 -0
  46. package/src/tools/utils/getEthereumAddress.ts +12 -0
  47. package/src/tools/utils/getUrlByTokenName.ts +12 -0
  48. package/src/tools/utils/getVersion.ts +25 -0
  49. package/src/tools/utils/index.ts +27 -0
  50. package/src/tools/utils/isTokenGraduated.ts +16 -0
  51. package/src/types/mcp.ts +72 -0
  52. package/src/utils/__tests__/validation.test.ts +147 -0
  53. package/src/utils/constraints.ts +146 -0
  54. package/src/utils/default-values.ts +208 -0
  55. package/src/utils/error-handler.ts +69 -0
  56. package/src/utils/error-templates.ts +273 -0
  57. package/src/utils/response-formatter.ts +51 -0
  58. package/src/utils/tool-factory.ts +257 -0
  59. package/src/utils/tool-registry.ts +296 -0
  60. package/src/utils/validation.ts +336 -0
  61. package/tsconfig.json +23 -0
@@ -0,0 +1,248 @@
1
+ /**
2
+ * Pool Management Tools
3
+ */
4
+
5
+ import { POOL_TYPES } from '@gala-chain/launchpad-sdk';
6
+ import type { MCPTool } from '../../types/mcp.js';
7
+ import { formatSuccess } from '../../utils/response-formatter.js';
8
+ import { withErrorHandling } from '../../utils/error-handler.js';
9
+ import {
10
+ TOKEN_NAME_SCHEMA,
11
+ TOKEN_SYMBOL_SCHEMA,
12
+ ADDRESS_SCHEMA,
13
+ PAGE_SCHEMA,
14
+ createLimitSchema,
15
+ CALCULATION_MODE_SCHEMA,
16
+ CURRENT_SUPPLY_SCHEMA,
17
+ } from '../../schemas/common-schemas.js';
18
+ import { fetchPoolDetailsForCalculationTool } from './fetchPoolDetailsForCalculation.js';
19
+ import { fetchAllPoolsTool } from './fetchAllPools.js';
20
+ import { fetchPriceHistoryTool } from './fetchPriceHistory.js';
21
+ import { fetchAllPriceHistoryTool } from './fetchAllPriceHistory.js';
22
+ import { fetchPricesTool } from './fetchPrices.js';
23
+ import { fetchAllPricesTool } from './fetchAllPrices.js';
24
+ import {
25
+ createSimpleTokenFetchTool,
26
+ createBooleanCheckTool,
27
+ createResolutionTool,
28
+ createNoParamTool,
29
+ } from '../../utils/tool-factory.js';
30
+ import { resolutionToSeconds, dateToUnixTimestamp, DEFAULT_VOLUME_RESOLUTION } from '../../utils/default-values.js';
31
+
32
+ // 1. Fetch Pools
33
+ export const fetchPoolsTool: MCPTool = {
34
+ name: 'gala_launchpad_fetch_pools',
35
+ description: 'Fetch token pools from Gala Launchpad with filtering and pagination',
36
+ inputSchema: {
37
+ type: 'object',
38
+ properties: {
39
+ type: {
40
+ type: 'string',
41
+ enum: Object.values(POOL_TYPES),
42
+ description: 'Type of pools to fetch (default: recent)',
43
+ },
44
+ creatorAddress: {
45
+ ...ADDRESS_SCHEMA,
46
+ description: 'Filter by creator address (optional)',
47
+ },
48
+ page: PAGE_SCHEMA,
49
+ limit: createLimitSchema('pool', 20),
50
+ },
51
+ },
52
+ handler: withErrorHandling(async (sdk, args) => {
53
+ const result = await sdk.fetchPools({
54
+ type: args.type || 'recent',
55
+ page: args.page || 1,
56
+ limit: args.limit || 20,
57
+ });
58
+ return formatSuccess(result);
59
+ }),
60
+ };
61
+
62
+ // 2. Fetch Pool Details (73% code reduction via factory pattern)
63
+ export const fetchPoolDetailsTool = createSimpleTokenFetchTool({
64
+ name: 'gala_launchpad_fetch_pool_details',
65
+ description: 'Get detailed pool state from GalaChain bonding curve',
66
+ handler: (sdk, tokenName) => sdk.fetchPoolDetails(tokenName),
67
+ });
68
+
69
+ // 3. Fetch Token Distribution (73% code reduction via factory pattern)
70
+ export const fetchTokenDistributionTool = createSimpleTokenFetchTool({
71
+ name: 'gala_launchpad_fetch_token_distribution',
72
+ description: 'Get holder distribution and supply metrics',
73
+ handler: (sdk, tokenName) => sdk.fetchTokenDistribution(tokenName),
74
+ });
75
+
76
+ // 4. Fetch Token Badges (73% code reduction via factory pattern)
77
+ export const fetchTokenBadgesTool = createSimpleTokenFetchTool({
78
+ name: 'gala_launchpad_fetch_token_badges',
79
+ description: 'Get achievement badges for volume and engagement',
80
+ handler: (sdk, tokenName) => sdk.fetchTokenBadges(tokenName),
81
+ });
82
+
83
+ // 5. Fetch Volume Data (using centralized default values utilities)
84
+ export const fetchVolumeDataTool: MCPTool = {
85
+ name: 'gala_launchpad_fetch_volume_data',
86
+ description: 'Get OHLCV (candlestick) data for charting',
87
+ inputSchema: {
88
+ type: 'object',
89
+ properties: {
90
+ tokenName: TOKEN_NAME_SCHEMA,
91
+ from: {
92
+ type: 'string',
93
+ format: 'date-time',
94
+ description: 'Start date (ISO 8601)',
95
+ },
96
+ to: {
97
+ type: 'string',
98
+ format: 'date-time',
99
+ description: 'End date (ISO 8601)',
100
+ },
101
+ resolution: {
102
+ type: 'string',
103
+ enum: ['1m', '5m', '15m', '1h', '4h', '1d'],
104
+ description: 'Time resolution (default: 1h)',
105
+ },
106
+ },
107
+ required: ['tokenName'],
108
+ },
109
+ handler: withErrorHandling(async (sdk, args) => {
110
+ const result = await sdk.fetchVolumeData({
111
+ tokenName: args.tokenName,
112
+ from: dateToUnixTimestamp(args.from),
113
+ to: dateToUnixTimestamp(args.to),
114
+ resolution: resolutionToSeconds(args.resolution, DEFAULT_VOLUME_RESOLUTION),
115
+ });
116
+ return formatSuccess(result);
117
+ }),
118
+ };
119
+
120
+ // 6. Fetch Token Spot Price (General DEX Tokens)
121
+ export const fetchTokenSpotPriceTool: MCPTool = {
122
+ name: 'gala_launchpad_fetch_token_spot_price',
123
+ description: 'Fetch USD spot price for DEX tokens (GALA, SILK, MUSIC, etc.)',
124
+ inputSchema: {
125
+ type: 'object',
126
+ properties: {
127
+ symbols: {
128
+ oneOf: [
129
+ { type: 'string' },
130
+ {
131
+ type: 'array',
132
+ items: { type: 'string' },
133
+ minItems: 1
134
+ }
135
+ ],
136
+ description: 'Single symbol string or array of symbols (e.g., "GALA" or ["GALA", "SILK", "MUSIC"])',
137
+ },
138
+ },
139
+ required: ['symbols'],
140
+ },
141
+ handler: withErrorHandling(async (sdk, args) => {
142
+ const result = await sdk.fetchTokenSpotPrice(args.symbols);
143
+ return formatSuccess(result);
144
+ }),
145
+ };
146
+
147
+ // 7. Fetch GALA Spot Price (45% code reduction via factory pattern)
148
+ export const fetchGalaSpotPriceTool = createNoParamTool({
149
+ name: 'gala_launchpad_fetch_gala_spot_price',
150
+ description: 'Fetch current GALA USD spot price (convenience method)',
151
+ handler: (sdk) => sdk.fetchGalaSpotPrice(),
152
+ });
153
+
154
+ // 8. Fetch Launchpad Token Spot Price
155
+ export const fetchLaunchpadTokenSpotPriceTool: MCPTool = {
156
+ name: 'gala_launchpad_fetch_launchpad_token_spot_price',
157
+ description: `Fetch USD spot price for a launchpad token by name.
158
+
159
+ Performance optimization: Provide currentSupply to avoid fetching pool details twice.`,
160
+ inputSchema: {
161
+ type: 'object',
162
+ properties: {
163
+ tokenName: {
164
+ ...TOKEN_NAME_SCHEMA,
165
+ description: 'Token name (e.g., "dragnrkti", "rocketri", "unicornri")',
166
+ },
167
+ calculateAmountMode: CALCULATION_MODE_SCHEMA,
168
+ currentSupply: CURRENT_SUPPLY_SCHEMA,
169
+ },
170
+ required: ['tokenName'],
171
+ },
172
+ handler: withErrorHandling(async (sdk, args) => {
173
+ // Build options object only if mode or supply provided
174
+ const options = args.calculateAmountMode || args.currentSupply
175
+ ? {
176
+ tokenName: args.tokenName,
177
+ calculateAmountMode: args.calculateAmountMode,
178
+ currentSupply: args.currentSupply,
179
+ }
180
+ : args.tokenName;
181
+
182
+ const result = await sdk.fetchLaunchpadTokenSpotPrice(options);
183
+ return formatSuccess(result);
184
+ }),
185
+ };
186
+
187
+ // 9. Check Token Name (60% code reduction via factory pattern)
188
+ export const checkTokenNameTool = createBooleanCheckTool({
189
+ name: 'gala_launchpad_check_token_name',
190
+ description: 'Check if token name is available',
191
+ paramName: 'tokenName',
192
+ paramSchema: TOKEN_NAME_SCHEMA,
193
+ handler: (sdk, tokenName) => sdk.isTokenNameAvailable(tokenName),
194
+ messages: {
195
+ true: 'Token name is available',
196
+ false: 'Token name is already taken',
197
+ },
198
+ });
199
+
200
+ // 10. Check Token Symbol (60% code reduction via factory pattern)
201
+ export const checkTokenSymbolTool = createBooleanCheckTool({
202
+ name: 'gala_launchpad_check_token_symbol',
203
+ description: 'Check if token symbol is available',
204
+ paramName: 'symbol',
205
+ paramSchema: TOKEN_SYMBOL_SCHEMA,
206
+ handler: (sdk, symbol) => sdk.isTokenSymbolAvailable(symbol),
207
+ messages: {
208
+ true: 'Token symbol is available',
209
+ false: 'Token symbol is already taken',
210
+ },
211
+ });
212
+
213
+ // 11. Resolve Vault Address (73% code reduction via factory pattern)
214
+ export const resolveVaultAddressTool = createResolutionTool({
215
+ name: 'gala_launchpad_resolve_vault_address',
216
+ description: 'Get GalaChain vault address for a token (useful for debugging)',
217
+ resolver: (sdk, tokenName) => sdk.resolveVaultAddress(tokenName),
218
+ resultKey: 'vaultAddress',
219
+ });
220
+
221
+ // 12. Resolve Token Class Key (73% code reduction via factory pattern)
222
+ export const resolveTokenClassKeyTool = createResolutionTool({
223
+ name: 'gala_launchpad_resolve_token_class_key',
224
+ description: 'Get GalaChain TokenClassKey for a launchpad token (useful for direct GalaChain operations)',
225
+ resolver: (sdk, tokenName) => sdk.resolveTokenClassKey(tokenName),
226
+ resultKey: 'tokenClassKey',
227
+ });
228
+
229
+ export const poolTools: MCPTool[] = [
230
+ fetchPoolsTool,
231
+ fetchAllPoolsTool,
232
+ fetchPoolDetailsTool,
233
+ fetchPoolDetailsForCalculationTool,
234
+ fetchTokenDistributionTool,
235
+ fetchTokenBadgesTool,
236
+ fetchVolumeDataTool,
237
+ fetchTokenSpotPriceTool,
238
+ fetchGalaSpotPriceTool,
239
+ fetchLaunchpadTokenSpotPriceTool,
240
+ fetchPriceHistoryTool,
241
+ fetchAllPriceHistoryTool,
242
+ fetchPricesTool,
243
+ fetchAllPricesTool,
244
+ checkTokenNameTool,
245
+ checkTokenSymbolTool,
246
+ resolveVaultAddressTool,
247
+ resolveTokenClassKeyTool,
248
+ ];
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Comments & Social Tools
3
+ */
4
+
5
+ import type { MCPTool } from '../../types/mcp.js';
6
+ import { formatSuccess } from '../../utils/response-formatter.js';
7
+ import { withErrorHandling } from '../../utils/error-handler.js';
8
+ import {
9
+ TOKEN_NAME_SCHEMA,
10
+ COMMENT_MESSAGE_SCHEMA,
11
+ PRIVATE_KEY_SCHEMA,
12
+ PAGE_SCHEMA,
13
+ createLimitSchema,
14
+ } from '../../schemas/common-schemas.js';
15
+ import { applyOperationPaginationDefaults } from '../../utils/default-values.js';
16
+
17
+ // 1. Post Comment
18
+ export const postCommentTool: MCPTool = {
19
+ name: 'gala_launchpad_post_comment',
20
+ description: 'Post a comment on a token pool',
21
+ inputSchema: {
22
+ type: 'object',
23
+ properties: {
24
+ tokenName: TOKEN_NAME_SCHEMA,
25
+ message: COMMENT_MESSAGE_SCHEMA,
26
+ privateKey: PRIVATE_KEY_SCHEMA,
27
+ },
28
+ required: ['tokenName', 'message'],
29
+ },
30
+ handler: withErrorHandling(async (sdk, args) => {
31
+ await sdk.postComment({
32
+ tokenName: args.tokenName,
33
+ content: args.message, // MCP parameter "message" → SDK parameter "content"
34
+ privateKey: args.privateKey,
35
+ });
36
+ // postComment returns void, so return success message
37
+ return formatSuccess({ success: true, message: 'Comment posted successfully' });
38
+ }),
39
+ };
40
+
41
+ // 2. Fetch Comments (using centralized pagination defaults)
42
+ export const fetchCommentsTool: MCPTool = {
43
+ name: 'gala_launchpad_fetch_comments',
44
+ description: 'Get comments for a token pool',
45
+ inputSchema: {
46
+ type: 'object',
47
+ properties: {
48
+ tokenName: TOKEN_NAME_SCHEMA,
49
+ page: PAGE_SCHEMA,
50
+ limit: createLimitSchema('comment', 20),
51
+ },
52
+ required: ['tokenName'],
53
+ },
54
+ handler: withErrorHandling(async (sdk, args) => {
55
+ const pagination = applyOperationPaginationDefaults(args, 'comment');
56
+ const result = await sdk.fetchComments({
57
+ tokenName: args.tokenName,
58
+ ...pagination,
59
+ });
60
+ return formatSuccess(result);
61
+ }),
62
+ };
63
+
64
+ export const socialTools: MCPTool[] = [postCommentTool, fetchCommentsTool];