@gala-chain/launchpad-mcp-server 1.7.15 → 1.8.1

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