@gala-chain/launchpad-mcp-server 1.14.2 → 1.14.3
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 +7 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/tools/pools/fetchPools.js +1 -1
- package/dist/tools/pools/fetchPools.js.map +1 -1
- package/package.json +1 -1
- 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/server.ts
DELETED
|
@@ -1,241 +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
|
-
async initialize() {
|
|
51
|
-
try {
|
|
52
|
-
if (this.debug) {
|
|
53
|
-
console.error('[MCP Server] Initializing SDK...');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const { sdk, validation } = await AgentConfig.quickSetup({
|
|
57
|
-
environment: (process.env.ENVIRONMENT as any) || 'development',
|
|
58
|
-
privateKey: process.env.PRIVATE_KEY,
|
|
59
|
-
timeout: parseInt(process.env.TIMEOUT || '30000', 10),
|
|
60
|
-
debug: this.debug,
|
|
61
|
-
autoValidate: false,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
this.sdk = sdk;
|
|
65
|
-
|
|
66
|
-
if (this.debug) {
|
|
67
|
-
console.error('[MCP Server] SDK initialized successfully');
|
|
68
|
-
if (validation) {
|
|
69
|
-
console.error(`[MCP Server] Validation - Ready: ${validation.ready}`);
|
|
70
|
-
console.error(`[MCP Server] Validation - Can Trade: ${validation.capabilities.canTrade}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (validation && !validation.ready) {
|
|
75
|
-
console.error('[MCP Server] Warning: SDK not ready', validation.issues);
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error('[MCP Server] Failed to initialize SDK:', error);
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Setup tool handlers
|
|
85
|
-
*/
|
|
86
|
-
private setupToolHandlers() {
|
|
87
|
-
// Register tools/list handler
|
|
88
|
-
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
89
|
-
if (this.debug) {
|
|
90
|
-
console.error(`[MCP Server] Listing ${tools.length} tools`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
tools: tools.map((tool) => ({
|
|
95
|
-
name: tool.name,
|
|
96
|
-
description: tool.description,
|
|
97
|
-
inputSchema: tool.inputSchema,
|
|
98
|
-
})),
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// Register tools/call handler
|
|
103
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
104
|
-
const toolName = request.params.name as string;
|
|
105
|
-
const args = request.params.arguments || {};
|
|
106
|
-
|
|
107
|
-
if (this.debug) {
|
|
108
|
-
console.error(`[MCP Server] Executing tool: ${toolName}`);
|
|
109
|
-
console.error(`[MCP Server] Arguments:`, JSON.stringify(args, null, 2));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const tool = tools.find((t) => t.name === toolName);
|
|
113
|
-
|
|
114
|
-
if (!tool) {
|
|
115
|
-
throw new Error(`Tool not found: ${toolName}`);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (!this.sdk) {
|
|
119
|
-
throw new Error('SDK not initialized. Please ensure PRIVATE_KEY environment variable is set.');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
const result = await tool.handler(this.sdk, args);
|
|
124
|
-
|
|
125
|
-
if (this.debug) {
|
|
126
|
-
console.error(`[MCP Server] Tool execution successful: ${toolName}`);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return result as any;
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.error(`[MCP Server] Tool execution failed: ${toolName}`, error);
|
|
132
|
-
throw error;
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Setup prompt handlers
|
|
139
|
-
*/
|
|
140
|
-
private setupPromptHandlers() {
|
|
141
|
-
// Register prompts/list handler
|
|
142
|
-
this.server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
143
|
-
if (this.debug) {
|
|
144
|
-
console.error(`[MCP Server] Listing ${prompts.length} prompts`);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
prompts: prompts.map((prompt) => ({
|
|
149
|
-
name: prompt.name,
|
|
150
|
-
description: prompt.description,
|
|
151
|
-
arguments: prompt.arguments || [],
|
|
152
|
-
})),
|
|
153
|
-
};
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
// Register prompts/get handler
|
|
157
|
-
this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
158
|
-
const promptName = request.params.name as string;
|
|
159
|
-
const args = (request.params.arguments || {}) as Record<string, string>;
|
|
160
|
-
|
|
161
|
-
if (this.debug) {
|
|
162
|
-
console.error(`[MCP Server] Getting prompt: ${promptName}`);
|
|
163
|
-
console.error(`[MCP Server] Arguments:`, JSON.stringify(args, null, 2));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const prompt = getPrompt(promptName);
|
|
167
|
-
|
|
168
|
-
if (!prompt) {
|
|
169
|
-
throw new Error(`Prompt not found: ${promptName}`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
const messages = prompt.handler(args);
|
|
174
|
-
|
|
175
|
-
if (this.debug) {
|
|
176
|
-
console.error(`[MCP Server] Prompt generated ${messages.length} messages`);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
messages,
|
|
181
|
-
};
|
|
182
|
-
} catch (error) {
|
|
183
|
-
console.error(`[MCP Server] Prompt generation failed: ${promptName}`, error);
|
|
184
|
-
throw error;
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Setup error handlers
|
|
191
|
-
*/
|
|
192
|
-
private setupErrorHandlers() {
|
|
193
|
-
this.server.onerror = (error) => {
|
|
194
|
-
console.error('[MCP Server] Protocol error:', error);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
process.on('SIGINT', () => {
|
|
198
|
-
if (this.debug) {
|
|
199
|
-
console.error('[MCP Server] Received SIGINT, shutting down...');
|
|
200
|
-
}
|
|
201
|
-
this.cleanup();
|
|
202
|
-
process.exit(0);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
process.on('SIGTERM', () => {
|
|
206
|
-
if (this.debug) {
|
|
207
|
-
console.error('[MCP Server] Received SIGTERM, shutting down...');
|
|
208
|
-
}
|
|
209
|
-
this.cleanup();
|
|
210
|
-
process.exit(0);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Start the MCP server
|
|
216
|
-
*/
|
|
217
|
-
async start() {
|
|
218
|
-
await this.initialize();
|
|
219
|
-
|
|
220
|
-
const transport = new StdioServerTransport();
|
|
221
|
-
await this.server.connect(transport);
|
|
222
|
-
|
|
223
|
-
if (this.debug) {
|
|
224
|
-
console.error('[MCP Server] Gala Launchpad MCP server running on stdio');
|
|
225
|
-
console.error(`[MCP Server] Registered ${tools.length} tools`);
|
|
226
|
-
console.error(`[MCP Server] Registered ${prompts.length} prompts (slash commands)`);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Cleanup resources
|
|
232
|
-
*/
|
|
233
|
-
cleanup() {
|
|
234
|
-
if (this.sdk) {
|
|
235
|
-
this.sdk.cleanup();
|
|
236
|
-
if (this.debug) {
|
|
237
|
-
console.error('[MCP Server] SDK cleaned up');
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Balance & Portfolio Tools
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { MCPTool } from '../../types/mcp.js';
|
|
6
|
-
import { formatSuccess, formatBoolean } from '../../utils/response-formatter.js';
|
|
7
|
-
import { withErrorHandling } from '../../utils/error-handler.js';
|
|
8
|
-
import {
|
|
9
|
-
TOKEN_NAME_SCHEMA,
|
|
10
|
-
ADDRESS_SCHEMA,
|
|
11
|
-
PAGE_SCHEMA,
|
|
12
|
-
createLimitSchema,
|
|
13
|
-
SEARCH_SCHEMA,
|
|
14
|
-
FULL_NAME_SCHEMA,
|
|
15
|
-
PRIVATE_KEY_SCHEMA,
|
|
16
|
-
} from '../../schemas/common-schemas.js';
|
|
17
|
-
import { applyOperationPaginationDefaults } from '../../utils/default-values.js';
|
|
18
|
-
|
|
19
|
-
// 1. Fetch GALA Balance
|
|
20
|
-
export const fetchGalaBalanceTool: MCPTool = {
|
|
21
|
-
name: 'gala_launchpad_fetch_gala_balance',
|
|
22
|
-
description: 'Get GALA balance for a wallet',
|
|
23
|
-
inputSchema: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
properties: {
|
|
26
|
-
address: {
|
|
27
|
-
...ADDRESS_SCHEMA,
|
|
28
|
-
description: 'Wallet address (optional, defaults to SDK wallet)',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
33
|
-
const result = await sdk.fetchGalaBalance(args.address);
|
|
34
|
-
return formatSuccess(result);
|
|
35
|
-
}),
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// 2. Fetch Token Balance (Optimized Single-Token Lookup)
|
|
39
|
-
export const fetchTokenBalanceTool: MCPTool = {
|
|
40
|
-
name: 'gala_launchpad_fetch_token_balance',
|
|
41
|
-
description: 'Get token balance for a specific token. Automatically routes to the correct backend: GalaChain for standard tokens (GALA, GUSDC) or launchpad backend for launchpad tokens (anime, etc.).',
|
|
42
|
-
inputSchema: {
|
|
43
|
-
type: 'object',
|
|
44
|
-
properties: {
|
|
45
|
-
tokenName: TOKEN_NAME_SCHEMA,
|
|
46
|
-
address: ADDRESS_SCHEMA,
|
|
47
|
-
},
|
|
48
|
-
required: ['tokenName', 'address'],
|
|
49
|
-
},
|
|
50
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
51
|
-
// SDK now handles routing: tokenId → GalaChain, tokenName → launchpad backend
|
|
52
|
-
const result = await sdk.fetchTokenBalance({
|
|
53
|
-
tokenName: args.tokenName,
|
|
54
|
-
address: args.address
|
|
55
|
-
});
|
|
56
|
-
return formatSuccess(result);
|
|
57
|
-
}),
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// 3. Fetch Tokens Held (with Filtering Support)
|
|
61
|
-
export const fetchTokensHeldTool: MCPTool = {
|
|
62
|
-
name: 'gala_launchpad_fetch_tokens_held',
|
|
63
|
-
description: 'Get tokens held by a wallet with optional filtering. Supports exact match (tokenName) and fuzzy search (search) for efficient backend filtering.',
|
|
64
|
-
inputSchema: {
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: {
|
|
67
|
-
address: ADDRESS_SCHEMA,
|
|
68
|
-
page: PAGE_SCHEMA,
|
|
69
|
-
limit: createLimitSchema('user', 20),
|
|
70
|
-
tokenName: {
|
|
71
|
-
...TOKEN_NAME_SCHEMA,
|
|
72
|
-
description: 'Optional token name (exact match filter)',
|
|
73
|
-
},
|
|
74
|
-
search: SEARCH_SCHEMA,
|
|
75
|
-
},
|
|
76
|
-
required: ['address'],
|
|
77
|
-
},
|
|
78
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
79
|
-
const pagination = applyOperationPaginationDefaults(args, 'user');
|
|
80
|
-
const result = await sdk.fetchTokensHeld({
|
|
81
|
-
...pagination,
|
|
82
|
-
tokenName: args.tokenName,
|
|
83
|
-
search: args.search,
|
|
84
|
-
address: args.address,
|
|
85
|
-
});
|
|
86
|
-
return formatSuccess(result);
|
|
87
|
-
}),
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// 4. Fetch Tokens Created (with Filtering Support)
|
|
91
|
-
export const fetchTokensCreatedTool: MCPTool = {
|
|
92
|
-
name: 'gala_launchpad_fetch_tokens_created',
|
|
93
|
-
description: 'Get tokens created by a wallet with optional filtering. Supports exact match (tokenName) and fuzzy search (search) for efficient backend filtering.',
|
|
94
|
-
inputSchema: {
|
|
95
|
-
type: 'object',
|
|
96
|
-
properties: {
|
|
97
|
-
address: ADDRESS_SCHEMA,
|
|
98
|
-
page: PAGE_SCHEMA,
|
|
99
|
-
limit: createLimitSchema('user', 20),
|
|
100
|
-
tokenName: {
|
|
101
|
-
...TOKEN_NAME_SCHEMA,
|
|
102
|
-
description: 'Optional token name (exact match filter)',
|
|
103
|
-
},
|
|
104
|
-
search: SEARCH_SCHEMA,
|
|
105
|
-
},
|
|
106
|
-
required: ['address'],
|
|
107
|
-
},
|
|
108
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
109
|
-
const pagination = applyOperationPaginationDefaults(args, 'user');
|
|
110
|
-
const result = await sdk.fetchTokensCreated({
|
|
111
|
-
...pagination,
|
|
112
|
-
tokenName: args.tokenName,
|
|
113
|
-
search: args.search,
|
|
114
|
-
address: args.address,
|
|
115
|
-
});
|
|
116
|
-
return formatSuccess(result);
|
|
117
|
-
}),
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// 5. Fetch Profile
|
|
121
|
-
export const fetchProfileTool: MCPTool = {
|
|
122
|
-
name: 'gala_launchpad_fetch_profile',
|
|
123
|
-
description: 'Get user profile data',
|
|
124
|
-
inputSchema: {
|
|
125
|
-
type: 'object',
|
|
126
|
-
properties: {
|
|
127
|
-
address: {
|
|
128
|
-
...ADDRESS_SCHEMA,
|
|
129
|
-
description: 'Wallet address (optional, defaults to SDK wallet)',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
134
|
-
const result = await sdk.fetchProfile(args.address);
|
|
135
|
-
return formatSuccess(result);
|
|
136
|
-
}),
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// 6. Update Profile
|
|
140
|
-
export const updateProfileTool: MCPTool = {
|
|
141
|
-
name: 'gala_launchpad_update_profile',
|
|
142
|
-
description: 'Update user profile',
|
|
143
|
-
inputSchema: {
|
|
144
|
-
type: 'object',
|
|
145
|
-
properties: {
|
|
146
|
-
fullName: FULL_NAME_SCHEMA,
|
|
147
|
-
profileImage: {
|
|
148
|
-
type: 'string',
|
|
149
|
-
description: 'Profile image URL or empty string',
|
|
150
|
-
},
|
|
151
|
-
address: ADDRESS_SCHEMA,
|
|
152
|
-
privateKey: PRIVATE_KEY_SCHEMA,
|
|
153
|
-
},
|
|
154
|
-
required: ['fullName', 'profileImage', 'address'],
|
|
155
|
-
},
|
|
156
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
157
|
-
await sdk.updateProfile({
|
|
158
|
-
fullName: args.fullName,
|
|
159
|
-
profileImage: args.profileImage,
|
|
160
|
-
address: args.address,
|
|
161
|
-
privateKey: args.privateKey,
|
|
162
|
-
});
|
|
163
|
-
return formatBoolean(true, 'Profile updated successfully');
|
|
164
|
-
}),
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export const balanceTools: MCPTool[] = [
|
|
168
|
-
fetchGalaBalanceTool,
|
|
169
|
-
fetchTokenBalanceTool,
|
|
170
|
-
fetchTokensHeldTool,
|
|
171
|
-
fetchTokensCreatedTool,
|
|
172
|
-
fetchProfileTool,
|
|
173
|
-
updateProfileTool,
|
|
174
|
-
];
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token Creation 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 { createNoParamTool } from '../../utils/tool-factory.js';
|
|
9
|
-
import {
|
|
10
|
-
TOKEN_NAME_SCHEMA,
|
|
11
|
-
TOKEN_SYMBOL_SCHEMA,
|
|
12
|
-
TOKEN_DESCRIPTION_SCHEMA,
|
|
13
|
-
PRE_BUY_QUANTITY_SCHEMA,
|
|
14
|
-
URL_SCHEMA,
|
|
15
|
-
PRIVATE_KEY_SCHEMA,
|
|
16
|
-
ADDRESS_SCHEMA,
|
|
17
|
-
} from '../../schemas/common-schemas.js';
|
|
18
|
-
|
|
19
|
-
// 1. Launch Token
|
|
20
|
-
export const launchTokenTool: MCPTool = {
|
|
21
|
-
name: 'gala_launchpad_launch_token',
|
|
22
|
-
description: `Create a new token on the launchpad.
|
|
23
|
-
|
|
24
|
-
WORKFLOW:
|
|
25
|
-
1. checkTokenName() → Verify name is available
|
|
26
|
-
2. checkTokenSymbol() → Verify symbol is available
|
|
27
|
-
3. launchToken() → Create token with validated name/symbol
|
|
28
|
-
4. getUrlByTokenName() → Get frontend URL for the new token
|
|
29
|
-
|
|
30
|
-
REQUIREMENT: At least one social URL (websiteUrl, twitterUrl, or telegramUrl) is required.
|
|
31
|
-
|
|
32
|
-
RETURNS: Transaction details including token name, symbol, creator address, and transaction ID`,
|
|
33
|
-
inputSchema: {
|
|
34
|
-
type: 'object',
|
|
35
|
-
properties: {
|
|
36
|
-
tokenName: TOKEN_NAME_SCHEMA,
|
|
37
|
-
tokenSymbol: TOKEN_SYMBOL_SCHEMA,
|
|
38
|
-
tokenDescription: TOKEN_DESCRIPTION_SCHEMA,
|
|
39
|
-
tokenImage: {
|
|
40
|
-
...URL_SCHEMA,
|
|
41
|
-
description: 'Token image URL',
|
|
42
|
-
},
|
|
43
|
-
preBuyQuantity: PRE_BUY_QUANTITY_SCHEMA,
|
|
44
|
-
websiteUrl: {
|
|
45
|
-
...URL_SCHEMA,
|
|
46
|
-
description: 'Website URL (optional)',
|
|
47
|
-
},
|
|
48
|
-
telegramUrl: {
|
|
49
|
-
...URL_SCHEMA,
|
|
50
|
-
description: 'Telegram channel URL (optional)',
|
|
51
|
-
},
|
|
52
|
-
twitterUrl: {
|
|
53
|
-
...URL_SCHEMA,
|
|
54
|
-
description: 'Twitter profile URL (optional)',
|
|
55
|
-
},
|
|
56
|
-
tokenCategory: {
|
|
57
|
-
type: 'string',
|
|
58
|
-
description: 'Token category (defaults to "Unit")',
|
|
59
|
-
},
|
|
60
|
-
tokenCollection: {
|
|
61
|
-
type: 'string',
|
|
62
|
-
description: 'Token collection (defaults to "Token")',
|
|
63
|
-
},
|
|
64
|
-
reverseBondingCurveConfiguration: {
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: {
|
|
67
|
-
minFeePortion: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
description: 'Minimum fee portion',
|
|
70
|
-
},
|
|
71
|
-
maxFeePortion: {
|
|
72
|
-
type: 'string',
|
|
73
|
-
description: 'Maximum fee portion',
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
description: 'Reverse bonding curve configuration (optional, uses defaults)',
|
|
77
|
-
},
|
|
78
|
-
privateKey: PRIVATE_KEY_SCHEMA,
|
|
79
|
-
},
|
|
80
|
-
required: [
|
|
81
|
-
'tokenName',
|
|
82
|
-
'tokenSymbol',
|
|
83
|
-
'tokenDescription',
|
|
84
|
-
'tokenImage',
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
88
|
-
const result = await sdk.launchToken(args);
|
|
89
|
-
return formatSuccess(result);
|
|
90
|
-
}),
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// 2. Upload Token Image
|
|
94
|
-
export const uploadTokenImageTool: MCPTool = {
|
|
95
|
-
name: 'gala_launchpad_upload_token_image',
|
|
96
|
-
description: 'Upload token image from filesystem (Node.js only)',
|
|
97
|
-
inputSchema: {
|
|
98
|
-
type: 'object',
|
|
99
|
-
properties: {
|
|
100
|
-
tokenName: {
|
|
101
|
-
...TOKEN_NAME_SCHEMA,
|
|
102
|
-
description: 'Token name (2-20 lowercase alphanumeric)',
|
|
103
|
-
},
|
|
104
|
-
imagePath: {
|
|
105
|
-
type: 'string',
|
|
106
|
-
description: 'Absolute file path to image file',
|
|
107
|
-
},
|
|
108
|
-
privateKey: PRIVATE_KEY_SCHEMA,
|
|
109
|
-
},
|
|
110
|
-
required: ['tokenName', 'imagePath'],
|
|
111
|
-
},
|
|
112
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
113
|
-
const fs = await import('fs/promises');
|
|
114
|
-
const fileBuffer = await fs.readFile(args.imagePath);
|
|
115
|
-
|
|
116
|
-
const result = await sdk.uploadTokenImage({
|
|
117
|
-
tokenName: args.tokenName,
|
|
118
|
-
options: {
|
|
119
|
-
file: fileBuffer,
|
|
120
|
-
tokenName: args.tokenName,
|
|
121
|
-
},
|
|
122
|
-
privateKey: args.privateKey,
|
|
123
|
-
});
|
|
124
|
-
return formatSuccess(result);
|
|
125
|
-
}),
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
// 3. Upload Profile Image
|
|
129
|
-
export const uploadProfileImageTool: MCPTool = {
|
|
130
|
-
name: 'gala_launchpad_upload_profile_image',
|
|
131
|
-
description: 'Upload profile image from filesystem (Node.js only)',
|
|
132
|
-
inputSchema: {
|
|
133
|
-
type: 'object',
|
|
134
|
-
properties: {
|
|
135
|
-
imagePath: {
|
|
136
|
-
type: 'string',
|
|
137
|
-
description: 'Absolute file path to image file',
|
|
138
|
-
},
|
|
139
|
-
address: {
|
|
140
|
-
...ADDRESS_SCHEMA,
|
|
141
|
-
description: 'Optional wallet address (defaults to authenticated user)',
|
|
142
|
-
},
|
|
143
|
-
privateKey: PRIVATE_KEY_SCHEMA,
|
|
144
|
-
},
|
|
145
|
-
required: ['imagePath'],
|
|
146
|
-
},
|
|
147
|
-
handler: withErrorHandling(async (sdk, args) => {
|
|
148
|
-
const fs = await import('fs/promises');
|
|
149
|
-
const fileBuffer = await fs.readFile(args.imagePath);
|
|
150
|
-
|
|
151
|
-
const imageUrl = await sdk.uploadProfileImage({
|
|
152
|
-
file: fileBuffer,
|
|
153
|
-
address: args.address,
|
|
154
|
-
privateKey: args.privateKey,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// If no imageUrl returned but upload succeeded, provide helpful message
|
|
158
|
-
if (!imageUrl) {
|
|
159
|
-
return formatSuccess({
|
|
160
|
-
success: true,
|
|
161
|
-
message: 'Profile image uploaded successfully (image stored with wallet address)',
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return formatSuccess({ success: true, imageUrl });
|
|
166
|
-
}),
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
// 4. Fetch Launch Token Fee (45% code reduction via factory pattern)
|
|
170
|
-
export const fetchLaunchTokenFeeTool = createNoParamTool({
|
|
171
|
-
name: 'gala_launchpad_fetch_launch_token_fee',
|
|
172
|
-
description: 'Fetch the current GALA fee required to launch a new token on the launchpad. Returns a number (e.g., 0.001). This is a dynamic value that may change. Check this before launching a token to ensure sufficient balance.',
|
|
173
|
-
handler: (sdk) => sdk.fetchLaunchTokenFee(),
|
|
174
|
-
resultKey: 'feeAmount',
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
export const creationTools: MCPTool[] = [
|
|
178
|
-
launchTokenTool,
|
|
179
|
-
uploadTokenImageTool,
|
|
180
|
-
uploadProfileImageTool,
|
|
181
|
-
fetchLaunchTokenFeeTool,
|
|
182
|
-
];
|
package/src/tools/index.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Registry
|
|
3
|
-
*
|
|
4
|
-
* Enhanced tool registry with auto-validation and metadata.
|
|
5
|
-
* Uses tool-registry system for robust tool management.
|
|
6
|
-
*
|
|
7
|
-
* @see src/utils/tool-registry.ts
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { poolTools } from './pools/index.js';
|
|
11
|
-
import { tradingTools } from './trading/index.js';
|
|
12
|
-
import { balanceTools } from './balance/index.js';
|
|
13
|
-
import { creationTools } from './creation/index.js';
|
|
14
|
-
import { socialTools } from './social/index.js';
|
|
15
|
-
import { transferTools } from './transfers/index.js';
|
|
16
|
-
import { utilityTools } from './utils/index.js';
|
|
17
|
-
import { createToolRegistry, logToolRegistry } from '../utils/tool-registry.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Tool categories with metadata
|
|
21
|
-
*/
|
|
22
|
-
const toolCategories = [
|
|
23
|
-
{
|
|
24
|
-
name: 'pools',
|
|
25
|
-
description: 'Pool management, pricing, and token availability checks',
|
|
26
|
-
tools: poolTools,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'trading',
|
|
30
|
-
description: 'Token trading operations (buy, sell, calculate amounts)',
|
|
31
|
-
tools: tradingTools,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'balance',
|
|
35
|
-
description: 'Balance queries and portfolio management',
|
|
36
|
-
tools: balanceTools,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'creation',
|
|
40
|
-
description: 'Token creation and launch operations',
|
|
41
|
-
tools: creationTools,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: 'social',
|
|
45
|
-
description: 'Comments and social interactions',
|
|
46
|
-
tools: socialTools,
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'transfers',
|
|
50
|
-
description: 'Token and GALA transfer operations',
|
|
51
|
-
tools: transferTools,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: 'utils',
|
|
55
|
-
description: 'Utility tools (wallet, config, SDK documentation)',
|
|
56
|
-
tools: utilityTools,
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Enhanced tool registry with validation (54 tools)
|
|
62
|
-
*/
|
|
63
|
-
export const registry = createToolRegistry(toolCategories, 54);
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Complete tool array (for backward compatibility)
|
|
67
|
-
*/
|
|
68
|
-
export const tools = registry.tools;
|
|
69
|
-
|
|
70
|
-
// Log registry statistics in debug mode
|
|
71
|
-
if (process.env.DEBUG === 'true') {
|
|
72
|
-
logToolRegistry(registry);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Throw error if registry is invalid
|
|
76
|
-
if (!registry.isValid) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`Tool registry validation failed:\n${registry.errors.join('\n')}`
|
|
79
|
-
);
|
|
80
|
-
}
|