@gala-chain/launchpad-mcp-server 1.23.1 → 1.24.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 (116) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +34 -6
  3. package/dist/constants/mcpToolNames.d.ts +6 -2
  4. package/dist/constants/mcpToolNames.d.ts.map +1 -1
  5. package/dist/constants/mcpToolNames.js +4 -2
  6. package/dist/constants/mcpToolNames.js.map +1 -1
  7. package/dist/generated/version.d.ts +1 -1
  8. package/dist/generated/version.js +1 -1
  9. package/dist/prompts/explore-dex-pools.d.ts +20 -0
  10. package/dist/prompts/explore-dex-pools.d.ts.map +1 -0
  11. package/dist/prompts/explore-dex-pools.js +132 -0
  12. package/dist/prompts/explore-dex-pools.js.map +1 -0
  13. package/dist/prompts/index.d.ts +3 -2
  14. package/dist/prompts/index.d.ts.map +1 -1
  15. package/dist/prompts/index.js +6 -3
  16. package/dist/prompts/index.js.map +1 -1
  17. package/dist/prompts/pools.js.map +1 -1
  18. package/dist/tools/dex/fetchAllDexPools.d.ts +9 -0
  19. package/dist/tools/dex/fetchAllDexPools.d.ts.map +1 -0
  20. package/dist/tools/dex/fetchAllDexPools.js +45 -0
  21. package/dist/tools/dex/fetchAllDexPools.js.map +1 -0
  22. package/dist/tools/dex/fetchDexPools.d.ts +9 -0
  23. package/dist/tools/dex/fetchDexPools.d.ts.map +1 -0
  24. package/dist/tools/dex/fetchDexPools.js +58 -0
  25. package/dist/tools/dex/fetchDexPools.js.map +1 -0
  26. package/dist/tools/dex/index.d.ts +4 -3
  27. package/dist/tools/dex/index.d.ts.map +1 -1
  28. package/dist/tools/dex/index.js +9 -4
  29. package/dist/tools/dex/index.js.map +1 -1
  30. package/dist/tools/index.d.ts +2 -2
  31. package/dist/tools/index.js +3 -3
  32. package/docs/AI-AGENT-PATTERNS.md +555 -0
  33. package/docs/CONSTRAINTS-REFERENCE.md +454 -0
  34. package/docs/PROMPT-TOOL-MAPPING.md +352 -0
  35. package/docs/examples/default-values-pattern.md +240 -0
  36. package/docs/examples/tool-factory-pattern.md +217 -0
  37. package/jest.config.js +94 -0
  38. package/package.json +3 -3
  39. package/src/__tests__/integration/fetchTokenDetails.integration.test.ts +258 -0
  40. package/src/__tests__/integration/poolTools.integration.test.ts +185 -0
  41. package/src/__tests__/server.test.ts +255 -0
  42. package/src/constants/mcpToolNames.ts +183 -0
  43. package/src/index.ts +19 -0
  44. package/src/prompts/__tests__/promptStructure.test.ts +187 -0
  45. package/src/prompts/__tests__/registry.test.ts +349 -0
  46. package/src/prompts/analysis.ts +380 -0
  47. package/src/prompts/balances.ts +182 -0
  48. package/src/prompts/create-token.ts +123 -0
  49. package/src/prompts/creation-utils.ts +103 -0
  50. package/src/prompts/dex-trading.ts +86 -0
  51. package/src/prompts/discover-tokens.ts +86 -0
  52. package/src/prompts/explore-dex-pools.ts +138 -0
  53. package/src/prompts/index.ts +178 -0
  54. package/src/prompts/liquidity-positions.ts +237 -0
  55. package/src/prompts/pools.ts +496 -0
  56. package/src/prompts/portfolio.ts +208 -0
  57. package/src/prompts/social.ts +94 -0
  58. package/src/prompts/trading-calculations.ts +414 -0
  59. package/src/prompts/trading.ts +160 -0
  60. package/src/prompts/transfers.ts +97 -0
  61. package/src/prompts/utility-tools.ts +266 -0
  62. package/src/prompts/utility.ts +77 -0
  63. package/src/prompts/utils/handlerHelpers.ts +55 -0
  64. package/src/prompts/utils/textTemplates.ts +73 -0
  65. package/src/prompts/utils/workflowTemplates.ts +511 -0
  66. package/src/schemas/common-schemas.ts +393 -0
  67. package/src/scripts/test-all-prompts.ts +184 -0
  68. package/src/server.ts +367 -0
  69. package/src/tools/__tests__/dex-tools.test.ts +562 -0
  70. package/src/tools/__tests__/liquidity-positions.test.ts +673 -0
  71. package/src/tools/balance/index.ts +174 -0
  72. package/src/tools/creation/index.ts +182 -0
  73. package/src/tools/dex/fetchAllDexPools.ts +45 -0
  74. package/src/tools/dex/fetchDexPools.ts +58 -0
  75. package/src/tools/dex/index.ts +231 -0
  76. package/src/tools/dex/liquidity-positions.ts +547 -0
  77. package/src/tools/index.ts +94 -0
  78. package/src/tools/pools/fetchAllPools.ts +47 -0
  79. package/src/tools/pools/fetchAllPriceHistory.ts +119 -0
  80. package/src/tools/pools/fetchPoolDetails.ts +27 -0
  81. package/src/tools/pools/fetchPoolDetailsForCalculation.ts +22 -0
  82. package/src/tools/pools/fetchPools.ts +47 -0
  83. package/src/tools/pools/fetchPriceHistory.ts +124 -0
  84. package/src/tools/pools/fetchTokenDetails.ts +77 -0
  85. package/src/tools/pools/index.ts +284 -0
  86. package/src/tools/social/index.ts +64 -0
  87. package/src/tools/trading/index.ts +605 -0
  88. package/src/tools/transfers/index.ts +75 -0
  89. package/src/tools/utils/clearCache.ts +36 -0
  90. package/src/tools/utils/createWallet.ts +19 -0
  91. package/src/tools/utils/explainSdkUsage.ts +1446 -0
  92. package/src/tools/utils/getAddress.ts +12 -0
  93. package/src/tools/utils/getCacheInfo.ts +14 -0
  94. package/src/tools/utils/getConfig.ts +21 -0
  95. package/src/tools/utils/getEnvironment.ts +17 -0
  96. package/src/tools/utils/getEthereumAddress.ts +12 -0
  97. package/src/tools/utils/getUrlByTokenName.ts +12 -0
  98. package/src/tools/utils/getVersion.ts +25 -0
  99. package/src/tools/utils/getWallet.ts +25 -0
  100. package/src/tools/utils/hasWallet.ts +15 -0
  101. package/src/tools/utils/index.ts +37 -0
  102. package/src/tools/utils/isTokenGraduated.ts +16 -0
  103. package/src/tools/utils/setWallet.ts +41 -0
  104. package/src/tools/utils/switchEnvironment.ts +28 -0
  105. package/src/types/mcp.ts +72 -0
  106. package/src/utils/__tests__/validation.test.ts +147 -0
  107. package/src/utils/constraints.ts +155 -0
  108. package/src/utils/default-values.ts +208 -0
  109. package/src/utils/error-handler.ts +69 -0
  110. package/src/utils/error-templates.ts +273 -0
  111. package/src/utils/response-formatter.ts +51 -0
  112. package/src/utils/tool-factory.ts +303 -0
  113. package/src/utils/tool-registry.ts +296 -0
  114. package/src/utils/validation.ts +429 -0
  115. package/tests/wallet-management-integration.test.ts +284 -0
  116. package/tsconfig.json +23 -0
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Fetch All Price History Tool
3
+ *
4
+ * Queries all historical token price data from DEX Backend API with automatic pagination.
5
+ * Uses the /price-oracle/fetch-price endpoint for complete price history retrieval.
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 fetchAllPriceHistoryTool: MCPTool = {
13
+ name: 'gala_launchpad_fetch_all_price_history',
14
+ description: `Fetch all historical price snapshots for DEX tokens from the DEX Backend API with automatic pagination.
15
+
16
+ **Endpoint:** \`/price-oracle/fetch-price\`
17
+
18
+ **Requirements:**
19
+ - DEX Backend API must be configured (dexBackendBaseUrl in SDK config)
20
+ - Node.js environment only (not available in browser)
21
+ - Either tokenName OR tokenId is required (not both)
22
+
23
+ **Token Identification:**
24
+ - Use \`tokenName\` for convenience (e.g., "demonkpop") - automatically resolved to full token ID
25
+ - Use \`tokenId\` for direct specification (e.g., "Token|Unit|DKP|eth:...")
26
+ - Provide exactly ONE of these parameters
27
+
28
+ **Use Cases:**
29
+ - Complete historical price analysis and charting
30
+ - Full price trend identification over time periods
31
+ - Comprehensive volatility analysis
32
+ - Data export for external analytics
33
+
34
+ **Performance:** API-based queries with automatic pagination (max 100 items per page, combined into single result).`,
35
+
36
+ inputSchema: {
37
+ type: 'object',
38
+ properties: {
39
+ tokenName: {
40
+ type: 'string',
41
+ description:
42
+ 'Simple token name for convenience (e.g., "demonkpop", "shoewars") - automatically resolves to full token ID. Use this OR tokenId, not both.',
43
+ },
44
+ tokenId: {
45
+ oneOf: [
46
+ {
47
+ type: 'string',
48
+ description:
49
+ 'Pipe-delimited format: "collection|category|type|additionalKey" (e.g., "Token|Unit|GUSDC|eth:...")',
50
+ },
51
+ {
52
+ type: 'object',
53
+ properties: {
54
+ collection: {
55
+ type: 'string',
56
+ description: 'Token collection (e.g., "Token")',
57
+ },
58
+ category: {
59
+ type: 'string',
60
+ description: 'Token category (e.g., "Unit")',
61
+ },
62
+ type: {
63
+ type: 'string',
64
+ description: 'Token type (e.g., "GUSDC")',
65
+ },
66
+ additionalKey: {
67
+ type: 'string',
68
+ description: 'Additional key (e.g., "eth:0x...")',
69
+ },
70
+ },
71
+ required: ['collection', 'category', 'type', 'additionalKey'],
72
+ description: 'TokenClassKey object format',
73
+ },
74
+ ],
75
+ description: 'Token identifier (string or TokenClassKey object). Use this OR tokenName, not both.',
76
+ },
77
+ from: {
78
+ type: 'string',
79
+ format: 'date-time',
80
+ description: 'Start date for filtering (ISO 8601 format, defaults to 30 days ago)',
81
+ },
82
+ to: {
83
+ type: 'string',
84
+ format: 'date-time',
85
+ description: 'End date for filtering (ISO 8601 format, defaults to now)',
86
+ },
87
+ sortOrder: {
88
+ type: 'string',
89
+ enum: ['ASC', 'DESC'],
90
+ description: 'Sort order for results (default: DESC for newest-first)',
91
+ },
92
+ },
93
+ required: [],
94
+ },
95
+
96
+ handler: withErrorHandling(async (sdk, args) => {
97
+ // Convert string dates to Date objects if provided
98
+ const options: any = {
99
+ sortOrder: args.sortOrder,
100
+ };
101
+
102
+ // Support both tokenName and tokenId (mutual exclusivity validation happens in SDK)
103
+ if (args.tokenName) {
104
+ options.tokenName = args.tokenName;
105
+ } else {
106
+ options.tokenId = args.tokenId;
107
+ }
108
+
109
+ if (args.from) {
110
+ options.from = new Date(args.from);
111
+ }
112
+ if (args.to) {
113
+ options.to = new Date(args.to);
114
+ }
115
+
116
+ const result = await sdk.fetchAllPriceHistory(options);
117
+ return formatSuccess(result);
118
+ }),
119
+ };
@@ -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', 'popular'],
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,124 @@
1
+ /**
2
+ * Fetch Price History Tool
3
+ *
4
+ * Queries historical token price data from DEX Backend API.
5
+ * Uses the /price-oracle/fetch-price endpoint for paginated price history retrieval.
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
+ import { PAGE_SCHEMA, createLimitSchema } from '../../schemas/common-schemas.js';
12
+
13
+ export const fetchPriceHistoryTool: MCPTool = {
14
+ name: 'gala_launchpad_fetch_price_history',
15
+ description: `Fetch historical price snapshots for DEX tokens from the DEX Backend API.
16
+
17
+ **Endpoint:** \`/price-oracle/fetch-price\`
18
+
19
+ **Requirements:**
20
+ - DEX Backend API must be configured (dexBackendBaseUrl in SDK config)
21
+ - Node.js environment only (not available in browser)
22
+ - Either tokenName OR tokenId is required (not both)
23
+
24
+ **Token Identification:**
25
+ - Use \`tokenName\` for convenience (e.g., "demonkpop") - automatically resolved to full token ID
26
+ - Use \`tokenId\` for direct specification (e.g., "Token|Unit|DKP|eth:...")
27
+ - Provide exactly ONE of these parameters
28
+
29
+ **Use Cases:**
30
+ - Historical price analysis and charting
31
+ - Price trend identification
32
+ - Volatility analysis over time periods
33
+ - Data export for external analytics
34
+
35
+ **Performance:** API-based queries with pagination support (max 50 items per page).`,
36
+
37
+ inputSchema: {
38
+ type: 'object',
39
+ properties: {
40
+ tokenName: {
41
+ type: 'string',
42
+ description:
43
+ 'Simple token name for convenience (e.g., "demonkpop", "shoewars") - automatically resolves to full token ID. Use this OR tokenId, not both.',
44
+ },
45
+ tokenId: {
46
+ oneOf: [
47
+ {
48
+ type: 'string',
49
+ description:
50
+ 'Pipe-delimited format: "collection|category|type|additionalKey" (e.g., "Token|Unit|GUSDC|eth:...")',
51
+ },
52
+ {
53
+ type: 'object',
54
+ properties: {
55
+ collection: {
56
+ type: 'string',
57
+ description: 'Token collection (e.g., "Token")',
58
+ },
59
+ category: {
60
+ type: 'string',
61
+ description: 'Token category (e.g., "Unit")',
62
+ },
63
+ type: {
64
+ type: 'string',
65
+ description: 'Token type (e.g., "GUSDC")',
66
+ },
67
+ additionalKey: {
68
+ type: 'string',
69
+ description: 'Additional key (e.g., "eth:0x...")',
70
+ },
71
+ },
72
+ required: ['collection', 'category', 'type', 'additionalKey'],
73
+ description: 'TokenClassKey object format',
74
+ },
75
+ ],
76
+ description: 'Token identifier (string or TokenClassKey object). Use this OR tokenName, not both.',
77
+ },
78
+ from: {
79
+ type: 'string',
80
+ format: 'date-time',
81
+ description: 'Start date for filtering (ISO 8601 format, defaults to 30 days ago)',
82
+ },
83
+ to: {
84
+ type: 'string',
85
+ format: 'date-time',
86
+ description: 'End date for filtering (ISO 8601 format, defaults to now)',
87
+ },
88
+ sortOrder: {
89
+ type: 'string',
90
+ enum: ['ASC', 'DESC'],
91
+ description: 'Sort order for results (default: DESC for newest-first)',
92
+ },
93
+ page: PAGE_SCHEMA,
94
+ limit: createLimitSchema('priceHistory', 10),
95
+ },
96
+ required: [],
97
+ },
98
+
99
+ handler: withErrorHandling(async (sdk, args) => {
100
+ // Convert string dates to Date objects if provided
101
+ const options: any = {
102
+ sortOrder: args.sortOrder,
103
+ page: args.page,
104
+ limit: args.limit,
105
+ };
106
+
107
+ // Support both tokenName and tokenId (mutual exclusivity validation happens in SDK)
108
+ if (args.tokenName) {
109
+ options.tokenName = args.tokenName;
110
+ } else {
111
+ options.tokenId = args.tokenId;
112
+ }
113
+
114
+ if (args.from) {
115
+ options.from = new Date(args.from);
116
+ }
117
+ if (args.to) {
118
+ options.to = new Date(args.to);
119
+ }
120
+
121
+ const result = await sdk.fetchPriceHistory(options);
122
+ return formatSuccess(result);
123
+ }),
124
+ };
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Fetch Token Details Tool
3
+ *
4
+ * Queries the DEX API platform endpoint to retrieve comprehensive token metadata
5
+ * including image, decimals, description, verification status, network information,
6
+ * and trading capabilities.
7
+ */
8
+
9
+ import type { MCPTool } from '../../types/mcp.js';
10
+ import { formatSuccess } from '../../utils/response-formatter.js';
11
+ import { withErrorHandling } from '../../utils/error-handler.js';
12
+
13
+ export const fetchTokenDetailsTool: MCPTool = {
14
+ name: 'gala_launchpad_fetch_token_details',
15
+ description: `Fetch comprehensive token details from DEX API platform
16
+
17
+ **Endpoint:** \`/v1/tokens?tokenclasskeys=...\`
18
+
19
+ **Requirements:**
20
+ - DEX API platform must be configured (dexApiHttp client)
21
+ - Token identifier required in flexible format (string or object)
22
+
23
+ **Use Cases:**
24
+ - Retrieve complete token metadata and information
25
+ - Verify token specifications (decimals, symbol, description)
26
+ - Check verification status and trading capabilities
27
+ - Access token image and network information
28
+ - Analyze token details before trading
29
+
30
+ **Flexible Token Identification:**
31
+ Supports both pipe-delimited string and object formats for maximum flexibility.`,
32
+
33
+ inputSchema: {
34
+ type: 'object',
35
+ properties: {
36
+ tokenId: {
37
+ oneOf: [
38
+ {
39
+ type: 'string',
40
+ description:
41
+ 'Pipe-delimited format: "collection|category|type|additionalKey" (e.g., "Token|Unit|GUSDC|eth:0x...")',
42
+ },
43
+ {
44
+ type: 'object',
45
+ properties: {
46
+ collection: {
47
+ type: 'string',
48
+ description: 'Token collection (e.g., "Token")',
49
+ },
50
+ category: {
51
+ type: 'string',
52
+ description: 'Token category (e.g., "Unit")',
53
+ },
54
+ type: {
55
+ type: 'string',
56
+ description: 'Token type (e.g., "GUSDC")',
57
+ },
58
+ additionalKey: {
59
+ type: 'string',
60
+ description: 'Additional key (e.g., "eth:0x...")',
61
+ },
62
+ },
63
+ required: ['collection', 'category', 'type', 'additionalKey'],
64
+ description: 'TokenClassKey object format',
65
+ },
66
+ ],
67
+ description: 'Token identifier in flexible format (string or object)',
68
+ },
69
+ },
70
+ required: ['tokenId'],
71
+ },
72
+
73
+ handler: withErrorHandling(async (sdk, args) => {
74
+ const result = await sdk.fetchTokenDetails(args.tokenId);
75
+ return formatSuccess(result);
76
+ }),
77
+ };