@gala-chain/launchpad-mcp-server 1.14.2 → 1.15.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.
- package/CHANGELOG.md +118 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/tools/pools/fetchAllPriceHistory.d.ts.map +1 -1
- package/dist/tools/pools/fetchAllPriceHistory.js +19 -4
- package/dist/tools/pools/fetchAllPriceHistory.js.map +1 -1
- package/dist/tools/pools/fetchPools.js +1 -1
- package/dist/tools/pools/fetchPools.js.map +1 -1
- package/dist/tools/pools/fetchPriceHistory.d.ts.map +1 -1
- package/dist/tools/pools/fetchPriceHistory.js +19 -4
- package/dist/tools/pools/fetchPriceHistory.js.map +1 -1
- package/package.json +2 -2
- package/docs/AI-AGENT-PATTERNS.md +0 -555
- package/docs/CONSTRAINTS-REFERENCE.md +0 -454
- package/docs/PROMPT-TOOL-MAPPING.md +0 -352
- package/docs/examples/default-values-pattern.md +0 -240
- package/docs/examples/tool-factory-pattern.md +0 -217
- package/jest.config.js +0 -94
- package/src/__tests__/integration/fetchTokenDetails.integration.test.ts +0 -258
- package/src/__tests__/integration/poolTools.integration.test.ts +0 -185
- package/src/constants/mcpToolNames.ts +0 -141
- package/src/index.ts +0 -19
- package/src/prompts/__tests__/promptStructure.test.ts +0 -114
- package/src/prompts/__tests__/registry.test.ts +0 -145
- package/src/prompts/analysis.ts +0 -429
- package/src/prompts/index.ts +0 -127
- package/src/prompts/portfolio.ts +0 -242
- package/src/prompts/trading.ts +0 -191
- package/src/prompts/utility.ts +0 -43
- package/src/prompts/utils/workflowTemplates.ts +0 -344
- package/src/schemas/common-schemas.ts +0 -393
- package/src/scripts/test-all-prompts.ts +0 -184
- package/src/server.ts +0 -241
- package/src/tools/balance/index.ts +0 -174
- package/src/tools/creation/index.ts +0 -182
- package/src/tools/index.ts +0 -80
- package/src/tools/pools/fetchAllPools.ts +0 -47
- package/src/tools/pools/fetchAllPriceHistory.ts +0 -103
- package/src/tools/pools/fetchPoolDetails.ts +0 -27
- package/src/tools/pools/fetchPoolDetailsForCalculation.ts +0 -22
- package/src/tools/pools/fetchPools.ts +0 -47
- package/src/tools/pools/fetchPriceHistory.ts +0 -108
- package/src/tools/pools/fetchTokenDetails.ts +0 -77
- package/src/tools/pools/index.ts +0 -246
- package/src/tools/social/index.ts +0 -64
- package/src/tools/trading/index.ts +0 -605
- package/src/tools/transfers/index.ts +0 -75
- package/src/tools/utils/clearCache.ts +0 -36
- package/src/tools/utils/createWallet.ts +0 -19
- package/src/tools/utils/explainSdkUsage.ts +0 -1277
- package/src/tools/utils/getAddress.ts +0 -12
- package/src/tools/utils/getCacheInfo.ts +0 -14
- package/src/tools/utils/getConfig.ts +0 -11
- package/src/tools/utils/getEthereumAddress.ts +0 -12
- package/src/tools/utils/getUrlByTokenName.ts +0 -12
- package/src/tools/utils/getVersion.ts +0 -25
- package/src/tools/utils/index.ts +0 -27
- package/src/tools/utils/isTokenGraduated.ts +0 -16
- package/src/types/mcp.ts +0 -72
- package/src/utils/__tests__/validation.test.ts +0 -147
- package/src/utils/constraints.ts +0 -155
- package/src/utils/default-values.ts +0 -208
- package/src/utils/error-handler.ts +0 -69
- package/src/utils/error-templates.ts +0 -273
- package/src/utils/response-formatter.ts +0 -51
- package/src/utils/tool-factory.ts +0 -257
- package/src/utils/tool-registry.ts +0 -296
- package/src/utils/validation.ts +0 -336
- package/tsconfig.json +0 -23
package/src/utils/validation.ts
DELETED
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation Utilities for MCP Prompts
|
|
3
|
-
*
|
|
4
|
-
* Input validation functions for slash command arguments.
|
|
5
|
-
* Prevents malformed inputs and provides clear error messages.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Validation error class for better error handling
|
|
10
|
-
*/
|
|
11
|
-
export class ValidationError extends Error {
|
|
12
|
-
constructor(
|
|
13
|
-
public field: string,
|
|
14
|
-
message: string
|
|
15
|
-
) {
|
|
16
|
-
super(`Validation error for '${field}': ${message}`);
|
|
17
|
-
this.name = 'ValidationError';
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Validate token name format
|
|
23
|
-
*
|
|
24
|
-
* Token names must be 2-20 characters, alphanumeric with hyphens and underscores.
|
|
25
|
-
*
|
|
26
|
-
* @param name - Token name to validate
|
|
27
|
-
* @param fieldName - Field name for error messages (default: 'tokenName')
|
|
28
|
-
* @throws {ValidationError} If token name is invalid
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* validateTokenName('anime'); // ✅ Valid
|
|
33
|
-
* validateTokenName('test-123'); // ✅ Valid
|
|
34
|
-
* validateTokenName('my_token'); // ✅ Valid
|
|
35
|
-
* validateTokenName('a'); // ❌ Throws: too short
|
|
36
|
-
* validateTokenName('token@#$'); // ❌ Throws: invalid characters
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export function validateTokenName(name: string, fieldName = 'tokenName'): void {
|
|
40
|
-
if (!name || typeof name !== 'string') {
|
|
41
|
-
throw new ValidationError(fieldName, 'Token name is required');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (name.length < 2 || name.length > 20) {
|
|
45
|
-
throw new ValidationError(
|
|
46
|
-
fieldName,
|
|
47
|
-
`Token name must be 2-20 characters (got ${name.length})`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const tokenNameRegex = /^[a-zA-Z0-9-_]+$/;
|
|
52
|
-
if (!tokenNameRegex.test(name)) {
|
|
53
|
-
throw new ValidationError(
|
|
54
|
-
fieldName,
|
|
55
|
-
'Token name can only contain letters, numbers, hyphens, and underscores'
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Validate numeric amount
|
|
62
|
-
*
|
|
63
|
-
* Amounts must be positive numbers (integers or decimals).
|
|
64
|
-
*
|
|
65
|
-
* @param amount - Amount to validate (string or number)
|
|
66
|
-
* @param fieldName - Field name for error messages
|
|
67
|
-
* @throws {ValidationError} If amount is invalid
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* validateNumericAmount('100', 'galaAmount'); // ✅ Valid
|
|
72
|
-
* validateNumericAmount('99.5', 'tokenAmount'); // ✅ Valid
|
|
73
|
-
* validateNumericAmount('-5', 'amount'); // ❌ Throws: negative
|
|
74
|
-
* validateNumericAmount('abc', 'amount'); // ❌ Throws: not a number
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export function validateNumericAmount(
|
|
78
|
-
amount: string | number,
|
|
79
|
-
fieldName: string
|
|
80
|
-
): void {
|
|
81
|
-
if (amount === null || amount === undefined || amount === '') {
|
|
82
|
-
throw new ValidationError(fieldName, 'Amount is required');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
|
|
86
|
-
|
|
87
|
-
if (isNaN(numAmount)) {
|
|
88
|
-
throw new ValidationError(fieldName, `Amount must be a valid number (got: ${amount})`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (numAmount <= 0) {
|
|
92
|
-
throw new ValidationError(
|
|
93
|
-
fieldName,
|
|
94
|
-
`Amount must be positive (got: ${numAmount})`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (!isFinite(numAmount)) {
|
|
99
|
-
throw new ValidationError(fieldName, 'Amount must be a finite number');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Validate slippage tolerance percentage
|
|
105
|
-
*
|
|
106
|
-
* Slippage must be between 0.01% and 100%.
|
|
107
|
-
*
|
|
108
|
-
* @param slippage - Slippage percentage to validate
|
|
109
|
-
* @param fieldName - Field name for error messages (default: 'slippage')
|
|
110
|
-
* @throws {ValidationError} If slippage is invalid
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```typescript
|
|
114
|
-
* validateSlippage('1'); // ✅ Valid (1%)
|
|
115
|
-
* validateSlippage('0.5'); // ✅ Valid (0.5%)
|
|
116
|
-
* validateSlippage('50'); // ✅ Valid (50%)
|
|
117
|
-
* validateSlippage('0'); // ❌ Throws: too low
|
|
118
|
-
* validateSlippage('150'); // ❌ Throws: too high
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
export function validateSlippage(
|
|
122
|
-
slippage: string | number,
|
|
123
|
-
fieldName = 'slippage'
|
|
124
|
-
): void {
|
|
125
|
-
if (slippage === null || slippage === undefined || slippage === '') {
|
|
126
|
-
throw new ValidationError(fieldName, 'Slippage is required');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const numSlippage = typeof slippage === 'string' ? parseFloat(slippage) : slippage;
|
|
130
|
-
|
|
131
|
-
if (isNaN(numSlippage)) {
|
|
132
|
-
throw new ValidationError(
|
|
133
|
-
fieldName,
|
|
134
|
-
`Slippage must be a valid number (got: ${slippage})`
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (numSlippage < 0.01 || numSlippage > 100) {
|
|
139
|
-
throw new ValidationError(
|
|
140
|
-
fieldName,
|
|
141
|
-
`Slippage must be between 0.01% and 100% (got: ${numSlippage}%)`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Validate wallet address format
|
|
148
|
-
*
|
|
149
|
-
* Supports both GalaChain format (eth|0x...) and standard Ethereum format (0x...).
|
|
150
|
-
*
|
|
151
|
-
* @param address - Wallet address to validate
|
|
152
|
-
* @param fieldName - Field name for error messages (default: 'address')
|
|
153
|
-
* @throws {ValidationError} If address is invalid
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```typescript
|
|
157
|
-
* validateAddress('eth|0x1234567890abcdef1234567890abcdef12345678'); // ✅ Valid
|
|
158
|
-
* validateAddress('0x1234567890abcdef1234567890abcdef12345678'); // ✅ Valid
|
|
159
|
-
* validateAddress('invalid'); // ❌ Throws: invalid format
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
export function validateAddress(address: string, fieldName = 'address'): void {
|
|
163
|
-
if (!address || typeof address !== 'string') {
|
|
164
|
-
throw new ValidationError(fieldName, 'Address is required');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// GalaChain format: eth|0x{40 hex chars}
|
|
168
|
-
const galachainRegex = /^eth\|0x[a-fA-F0-9]{40}$/;
|
|
169
|
-
// Standard Ethereum format: 0x{40 hex chars}
|
|
170
|
-
const ethereumRegex = /^0x[a-fA-F0-9]{40}$/;
|
|
171
|
-
|
|
172
|
-
if (!galachainRegex.test(address) && !ethereumRegex.test(address)) {
|
|
173
|
-
throw new ValidationError(
|
|
174
|
-
fieldName,
|
|
175
|
-
'Address must be in GalaChain format (eth|0x...) or Ethereum format (0x...)'
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Validate token symbol format
|
|
182
|
-
*
|
|
183
|
-
* Symbols must be 1-8 uppercase letters.
|
|
184
|
-
*
|
|
185
|
-
* @param symbol - Token symbol to validate
|
|
186
|
-
* @param fieldName - Field name for error messages (default: 'symbol')
|
|
187
|
-
* @throws {ValidationError} If symbol is invalid
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* validateTokenSymbol('GALA'); // ✅ Valid
|
|
192
|
-
* validateTokenSymbol('TEST'); // ✅ Valid
|
|
193
|
-
* validateTokenSymbol('test'); // ❌ Throws: must be uppercase
|
|
194
|
-
* validateTokenSymbol('TOOLONG123'); // ❌ Throws: too long
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
export function validateTokenSymbol(symbol: string, fieldName = 'symbol'): void {
|
|
198
|
-
if (!symbol || typeof symbol !== 'string') {
|
|
199
|
-
throw new ValidationError(fieldName, 'Symbol is required');
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (symbol.length < 1 || symbol.length > 8) {
|
|
203
|
-
throw new ValidationError(
|
|
204
|
-
fieldName,
|
|
205
|
-
`Symbol must be 1-8 characters (got ${symbol.length})`
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const symbolRegex = /^[A-Z]+$/;
|
|
210
|
-
if (!symbolRegex.test(symbol)) {
|
|
211
|
-
throw new ValidationError(
|
|
212
|
-
fieldName,
|
|
213
|
-
'Symbol must be uppercase letters only (A-Z)'
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Validate pagination limit
|
|
220
|
-
*
|
|
221
|
-
* Limits must be positive integers within reasonable range (1-100).
|
|
222
|
-
*
|
|
223
|
-
* @param limit - Pagination limit to validate
|
|
224
|
-
* @param max - Maximum allowed limit (default: 100)
|
|
225
|
-
* @param fieldName - Field name for error messages (default: 'limit')
|
|
226
|
-
* @throws {ValidationError} If limit is invalid
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* ```typescript
|
|
230
|
-
* validatePaginationLimit('20'); // ✅ Valid
|
|
231
|
-
* validatePaginationLimit('1'); // ✅ Valid
|
|
232
|
-
* validatePaginationLimit('0'); // ❌ Throws: too low
|
|
233
|
-
* validatePaginationLimit('150'); // ❌ Throws: too high
|
|
234
|
-
* ```
|
|
235
|
-
*/
|
|
236
|
-
export function validatePaginationLimit(
|
|
237
|
-
limit: string | number,
|
|
238
|
-
max = 100,
|
|
239
|
-
fieldName = 'limit'
|
|
240
|
-
): void {
|
|
241
|
-
if (limit === null || limit === undefined || limit === '') {
|
|
242
|
-
throw new ValidationError(fieldName, 'Limit is required');
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const numLimit = typeof limit === 'string' ? parseInt(limit, 10) : limit;
|
|
246
|
-
|
|
247
|
-
if (isNaN(numLimit) || !Number.isInteger(numLimit)) {
|
|
248
|
-
throw new ValidationError(
|
|
249
|
-
fieldName,
|
|
250
|
-
`Limit must be a valid integer (got: ${limit})`
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (numLimit < 1 || numLimit > max) {
|
|
255
|
-
throw new ValidationError(
|
|
256
|
-
fieldName,
|
|
257
|
-
`Limit must be between 1 and ${max} (got: ${numLimit})`
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Validate comma-separated token list
|
|
264
|
-
*
|
|
265
|
-
* For batch operations that accept multiple token names.
|
|
266
|
-
*
|
|
267
|
-
* @param tokens - Comma-separated token names
|
|
268
|
-
* @param fieldName - Field name for error messages (default: 'tokens')
|
|
269
|
-
* @throws {ValidationError} If token list is invalid
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
* ```typescript
|
|
273
|
-
* validateTokenList('anime,test,dragon'); // ✅ Valid
|
|
274
|
-
* validateTokenList('token1'); // ✅ Valid (single token)
|
|
275
|
-
* validateTokenList(''); // ❌ Throws: empty list
|
|
276
|
-
* validateTokenList('token1,invalid@#$'); // ❌ Throws: invalid token name
|
|
277
|
-
* ```
|
|
278
|
-
*/
|
|
279
|
-
export function validateTokenList(tokens: string, fieldName = 'tokens'): string[] {
|
|
280
|
-
if (!tokens || typeof tokens !== 'string') {
|
|
281
|
-
throw new ValidationError(fieldName, 'Token list is required');
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const tokenArray = tokens.split(',').map((t) => t.trim());
|
|
285
|
-
|
|
286
|
-
if (tokenArray.length === 0 || tokenArray.some((t) => !t)) {
|
|
287
|
-
throw new ValidationError(fieldName, 'Token list cannot be empty');
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Validate each token name
|
|
291
|
-
tokenArray.forEach((token, index) => {
|
|
292
|
-
try {
|
|
293
|
-
validateTokenName(token, `${fieldName}[${index}]`);
|
|
294
|
-
} catch (error) {
|
|
295
|
-
if (error instanceof ValidationError) {
|
|
296
|
-
throw new ValidationError(
|
|
297
|
-
fieldName,
|
|
298
|
-
`Invalid token at position ${index + 1}: ${token}`
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
throw error;
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
return tokenArray;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Safe validation wrapper that doesn't throw
|
|
310
|
-
*
|
|
311
|
-
* Useful for non-critical validation where you want to continue with a warning.
|
|
312
|
-
*
|
|
313
|
-
* @param validationFn - Validation function to execute
|
|
314
|
-
* @returns Object with success flag and optional error
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
* ```typescript
|
|
318
|
-
* const result = safeValidate(() => validateTokenName('anime'));
|
|
319
|
-
* if (!result.success) {
|
|
320
|
-
* console.warn('Validation warning:', result.error);
|
|
321
|
-
* }
|
|
322
|
-
* ```
|
|
323
|
-
*/
|
|
324
|
-
export function safeValidate(
|
|
325
|
-
validationFn: () => void
|
|
326
|
-
): { success: boolean; error?: string } {
|
|
327
|
-
try {
|
|
328
|
-
validationFn();
|
|
329
|
-
return { success: true };
|
|
330
|
-
} catch (error) {
|
|
331
|
-
if (error instanceof ValidationError) {
|
|
332
|
-
return { success: false, error: error.message };
|
|
333
|
-
}
|
|
334
|
-
return { success: false, error: String(error) };
|
|
335
|
-
}
|
|
336
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./src",
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"declarationMap": true,
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"strict": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"noEmit": false,
|
|
16
|
-
"forceConsistentCasingInFileNames": true,
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"allowSyntheticDefaultImports": true,
|
|
19
|
-
"types": ["node", "jest"]
|
|
20
|
-
},
|
|
21
|
-
"include": ["src/**/*"],
|
|
22
|
-
"exclude": ["node_modules", "dist", "tests", "src/scripts", "src/**/__tests__"]
|
|
23
|
-
}
|