@gala-chain/launchpad-mcp-server 1.22.0 → 1.22.2

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 (73) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/generated/version.d.ts +1 -1
  3. package/dist/generated/version.js +1 -1
  4. package/package.json +2 -2
  5. package/docs/AI-AGENT-PATTERNS.md +0 -555
  6. package/docs/CONSTRAINTS-REFERENCE.md +0 -454
  7. package/docs/PROMPT-TOOL-MAPPING.md +0 -352
  8. package/docs/examples/default-values-pattern.md +0 -240
  9. package/docs/examples/tool-factory-pattern.md +0 -217
  10. package/jest.config.js +0 -94
  11. package/src/__tests__/integration/fetchTokenDetails.integration.test.ts +0 -258
  12. package/src/__tests__/integration/poolTools.integration.test.ts +0 -185
  13. package/src/constants/mcpToolNames.ts +0 -141
  14. package/src/index.ts +0 -19
  15. package/src/prompts/__tests__/promptStructure.test.ts +0 -137
  16. package/src/prompts/__tests__/registry.test.ts +0 -191
  17. package/src/prompts/analysis.ts +0 -429
  18. package/src/prompts/create-token.ts +0 -123
  19. package/src/prompts/dex-trading.ts +0 -86
  20. package/src/prompts/discover-tokens.ts +0 -86
  21. package/src/prompts/index.ts +0 -154
  22. package/src/prompts/liquidity-positions.ts +0 -270
  23. package/src/prompts/portfolio.ts +0 -242
  24. package/src/prompts/trading.ts +0 -191
  25. package/src/prompts/utility.ts +0 -43
  26. package/src/prompts/utils/workflowTemplates.ts +0 -511
  27. package/src/schemas/common-schemas.ts +0 -393
  28. package/src/scripts/test-all-prompts.ts +0 -184
  29. package/src/server.ts +0 -277
  30. package/src/tools/__tests__/dex-tools.test.ts +0 -562
  31. package/src/tools/__tests__/liquidity-positions.test.ts +0 -673
  32. package/src/tools/balance/index.ts +0 -174
  33. package/src/tools/creation/index.ts +0 -182
  34. package/src/tools/dex/index.ts +0 -226
  35. package/src/tools/dex/liquidity-positions.ts +0 -547
  36. package/src/tools/index.ts +0 -86
  37. package/src/tools/pools/fetchAllPools.ts +0 -47
  38. package/src/tools/pools/fetchAllPriceHistory.ts +0 -119
  39. package/src/tools/pools/fetchPoolDetails.ts +0 -27
  40. package/src/tools/pools/fetchPoolDetailsForCalculation.ts +0 -22
  41. package/src/tools/pools/fetchPools.ts +0 -47
  42. package/src/tools/pools/fetchPriceHistory.ts +0 -124
  43. package/src/tools/pools/fetchTokenDetails.ts +0 -77
  44. package/src/tools/pools/index.ts +0 -284
  45. package/src/tools/social/index.ts +0 -64
  46. package/src/tools/trading/index.ts +0 -605
  47. package/src/tools/transfers/index.ts +0 -75
  48. package/src/tools/utils/clearCache.ts +0 -36
  49. package/src/tools/utils/createWallet.ts +0 -19
  50. package/src/tools/utils/explainSdkUsage.ts +0 -1446
  51. package/src/tools/utils/getAddress.ts +0 -12
  52. package/src/tools/utils/getCacheInfo.ts +0 -14
  53. package/src/tools/utils/getConfig.ts +0 -11
  54. package/src/tools/utils/getEthereumAddress.ts +0 -12
  55. package/src/tools/utils/getUrlByTokenName.ts +0 -12
  56. package/src/tools/utils/getVersion.ts +0 -25
  57. package/src/tools/utils/getWallet.ts +0 -25
  58. package/src/tools/utils/hasWallet.ts +0 -15
  59. package/src/tools/utils/index.ts +0 -33
  60. package/src/tools/utils/isTokenGraduated.ts +0 -16
  61. package/src/tools/utils/setWallet.ts +0 -41
  62. package/src/types/mcp.ts +0 -72
  63. package/src/utils/__tests__/validation.test.ts +0 -147
  64. package/src/utils/constraints.ts +0 -155
  65. package/src/utils/default-values.ts +0 -208
  66. package/src/utils/error-handler.ts +0 -69
  67. package/src/utils/error-templates.ts +0 -273
  68. package/src/utils/response-formatter.ts +0 -51
  69. package/src/utils/tool-factory.ts +0 -257
  70. package/src/utils/tool-registry.ts +0 -296
  71. package/src/utils/validation.ts +0 -371
  72. package/tests/wallet-management-integration.test.ts +0 -284
  73. package/tsconfig.json +0 -23
package/src/server.ts DELETED
@@ -1,277 +0,0 @@
1
- /**
2
- * Gala Launchpad MCP Server
3
- *
4
- * Provides MCP tools for AI agents to interact with Gala Launchpad
5
- */
6
-
7
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
8
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
9
- import {
10
- ListToolsRequestSchema,
11
- CallToolRequestSchema,
12
- ListPromptsRequestSchema,
13
- GetPromptRequestSchema,
14
- } from '@modelcontextprotocol/sdk/types.js';
15
- import { AgentConfig, type LaunchpadSDK } from '@gala-chain/launchpad-sdk';
16
- import { tools } from './tools/index.js';
17
- import { prompts, getPrompt } from './prompts/index.js';
18
-
19
- export class LaunchpadMCPServer {
20
- private server: Server;
21
- private sdk: LaunchpadSDK | null = null;
22
- private debug: boolean;
23
-
24
- constructor() {
25
- this.debug = process.env.DEBUG === 'true';
26
-
27
- this.server = new Server(
28
- {
29
- name: '@gala-chain/launchpad-mcp-server',
30
- version: '1.5.0',
31
- },
32
- {
33
- capabilities: {
34
- tools: {},
35
- prompts: {
36
- listChanged: true,
37
- },
38
- },
39
- }
40
- );
41
-
42
- this.setupToolHandlers();
43
- this.setupPromptHandlers();
44
- this.setupErrorHandlers();
45
- }
46
-
47
- /**
48
- * Initialize SDK with AgentConfig
49
- *
50
- * Supports two operational modes:
51
- * 1. Full-access mode (PRIVATE_KEY provided): Uses quickSetup() - all operations available
52
- * 2. Read-only mode (PRIVATE_KEY not provided): Uses readOnlySetup() - query operations only
53
- *
54
- * In read-only mode, signing operations (buy, sell, create tokens, etc.) will throw ValidationError
55
- * when attempted, but all query operations (fetchPools, fetchBalance, etc.) work normally.
56
- */
57
- async initialize() {
58
- try {
59
- if (this.debug) {
60
- console.error('[MCP Server] Initializing SDK...');
61
- }
62
-
63
- const hasPrivateKey = Boolean(process.env.PRIVATE_KEY && process.env.PRIVATE_KEY.trim());
64
- const environment = (process.env.ENVIRONMENT as any) || 'production';
65
- const timeout = parseInt(process.env.TIMEOUT || '30000', 10);
66
-
67
- if (hasPrivateKey) {
68
- // Full-access mode: use quickSetup() to enable signing operations
69
- if (this.debug) {
70
- console.error('[MCP Server] PRIVATE_KEY detected - initializing in full-access mode');
71
- }
72
-
73
- const { sdk, validation } = await AgentConfig.quickSetup({
74
- environment,
75
- privateKey: process.env.PRIVATE_KEY,
76
- timeout,
77
- debug: this.debug,
78
- autoValidate: false,
79
- });
80
-
81
- this.sdk = sdk;
82
-
83
- if (this.debug) {
84
- console.error('[MCP Server] SDK initialized successfully (full-access mode)');
85
- if (validation) {
86
- console.error(`[MCP Server] Validation - Ready: ${validation.ready}`);
87
- console.error(`[MCP Server] Validation - Can Trade: ${validation.capabilities.canTrade}`);
88
- }
89
- }
90
-
91
- if (validation && !validation.ready) {
92
- console.error('[MCP Server] Warning: SDK not ready', validation.issues);
93
- }
94
- } else {
95
- // Read-only mode: use readOnlySetup() for query-only operations
96
- if (this.debug) {
97
- console.error('[MCP Server] PRIVATE_KEY not provided - initializing in read-only mode');
98
- }
99
-
100
- const { sdk } = await AgentConfig.readOnlySetup({
101
- environment,
102
- timeout,
103
- debug: this.debug,
104
- });
105
-
106
- this.sdk = sdk;
107
-
108
- if (this.debug) {
109
- console.error('[MCP Server] SDK initialized successfully (read-only mode)');
110
- console.error('[MCP Server] Note: Signing operations will fail - wallet required');
111
- }
112
- }
113
- } catch (error) {
114
- console.error('[MCP Server] Failed to initialize SDK:', error);
115
- throw error;
116
- }
117
- }
118
-
119
- /**
120
- * Setup tool handlers
121
- */
122
- private setupToolHandlers() {
123
- // Register tools/list handler
124
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
125
- if (this.debug) {
126
- console.error(`[MCP Server] Listing ${tools.length} tools`);
127
- }
128
-
129
- return {
130
- tools: tools.map((tool) => ({
131
- name: tool.name,
132
- description: tool.description,
133
- inputSchema: tool.inputSchema,
134
- })),
135
- };
136
- });
137
-
138
- // Register tools/call handler
139
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
140
- const toolName = request.params.name as string;
141
- const args = request.params.arguments || {};
142
-
143
- if (this.debug) {
144
- console.error(`[MCP Server] Executing tool: ${toolName}`);
145
- console.error(`[MCP Server] Arguments:`, JSON.stringify(args, null, 2));
146
- }
147
-
148
- const tool = tools.find((t) => t.name === toolName);
149
-
150
- if (!tool) {
151
- throw new Error(`Tool not found: ${toolName}`);
152
- }
153
-
154
- if (!this.sdk) {
155
- throw new Error('SDK not initialized. Failed during startup - check logs for details.');
156
- }
157
-
158
- try {
159
- const result = await tool.handler(this.sdk, args);
160
-
161
- if (this.debug) {
162
- console.error(`[MCP Server] Tool execution successful: ${toolName}`);
163
- }
164
-
165
- return result as any;
166
- } catch (error) {
167
- console.error(`[MCP Server] Tool execution failed: ${toolName}`, error);
168
- throw error;
169
- }
170
- });
171
- }
172
-
173
- /**
174
- * Setup prompt handlers
175
- */
176
- private setupPromptHandlers() {
177
- // Register prompts/list handler
178
- this.server.setRequestHandler(ListPromptsRequestSchema, async () => {
179
- if (this.debug) {
180
- console.error(`[MCP Server] Listing ${prompts.length} prompts`);
181
- }
182
-
183
- return {
184
- prompts: prompts.map((prompt) => ({
185
- name: prompt.name,
186
- description: prompt.description,
187
- arguments: prompt.arguments || [],
188
- })),
189
- };
190
- });
191
-
192
- // Register prompts/get handler
193
- this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
194
- const promptName = request.params.name as string;
195
- const args = (request.params.arguments || {}) as Record<string, string>;
196
-
197
- if (this.debug) {
198
- console.error(`[MCP Server] Getting prompt: ${promptName}`);
199
- console.error(`[MCP Server] Arguments:`, JSON.stringify(args, null, 2));
200
- }
201
-
202
- const prompt = getPrompt(promptName);
203
-
204
- if (!prompt) {
205
- throw new Error(`Prompt not found: ${promptName}`);
206
- }
207
-
208
- try {
209
- const messages = prompt.handler(args);
210
-
211
- if (this.debug) {
212
- console.error(`[MCP Server] Prompt generated ${messages.length} messages`);
213
- }
214
-
215
- return {
216
- messages,
217
- };
218
- } catch (error) {
219
- console.error(`[MCP Server] Prompt generation failed: ${promptName}`, error);
220
- throw error;
221
- }
222
- });
223
- }
224
-
225
- /**
226
- * Setup error handlers
227
- */
228
- private setupErrorHandlers() {
229
- this.server.onerror = (error) => {
230
- console.error('[MCP Server] Protocol error:', error);
231
- };
232
-
233
- process.on('SIGINT', () => {
234
- if (this.debug) {
235
- console.error('[MCP Server] Received SIGINT, shutting down...');
236
- }
237
- this.cleanup();
238
- process.exit(0);
239
- });
240
-
241
- process.on('SIGTERM', () => {
242
- if (this.debug) {
243
- console.error('[MCP Server] Received SIGTERM, shutting down...');
244
- }
245
- this.cleanup();
246
- process.exit(0);
247
- });
248
- }
249
-
250
- /**
251
- * Start the MCP server
252
- */
253
- async start() {
254
- await this.initialize();
255
-
256
- const transport = new StdioServerTransport();
257
- await this.server.connect(transport);
258
-
259
- if (this.debug) {
260
- console.error('[MCP Server] Gala Launchpad MCP server running on stdio');
261
- console.error(`[MCP Server] Registered ${tools.length} tools`);
262
- console.error(`[MCP Server] Registered ${prompts.length} prompts (slash commands)`);
263
- }
264
- }
265
-
266
- /**
267
- * Cleanup resources
268
- */
269
- cleanup() {
270
- if (this.sdk) {
271
- this.sdk.cleanup();
272
- if (this.debug) {
273
- console.error('[MCP Server] SDK cleaned up');
274
- }
275
- }
276
- }
277
- }