@gala-chain/launchpad-mcp-server 1.5.0 → 1.5.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.
- package/.eslintrc.json +9 -1
- package/dist/schemas/common-schemas.d.ts +121 -16
- package/dist/schemas/common-schemas.d.ts.map +1 -1
- package/dist/schemas/common-schemas.js +122 -17
- package/dist/schemas/common-schemas.js.map +1 -1
- package/dist/scripts/test-all-prompts.d.ts +6 -0
- package/dist/scripts/test-all-prompts.d.ts.map +1 -0
- package/dist/scripts/test-all-prompts.js +158 -0
- package/dist/scripts/test-all-prompts.js.map +1 -0
- package/dist/tools/balance/index.d.ts.map +1 -1
- package/dist/tools/balance/index.js +5 -4
- package/dist/tools/balance/index.js.map +1 -1
- package/dist/tools/creation/index.d.ts.map +1 -1
- package/dist/tools/creation/index.js +6 -11
- package/dist/tools/creation/index.js.map +1 -1
- package/dist/tools/index.d.ts +9 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +58 -14
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/pools/fetchPoolDetailsForCalculation.d.ts +2 -3
- package/dist/tools/pools/fetchPoolDetailsForCalculation.d.ts.map +1 -1
- package/dist/tools/pools/fetchPoolDetailsForCalculation.js +5 -17
- package/dist/tools/pools/fetchPoolDetailsForCalculation.js.map +1 -1
- package/dist/tools/pools/index.d.ts.map +1 -1
- package/dist/tools/pools/index.js +51 -137
- package/dist/tools/pools/index.js.map +1 -1
- package/dist/tools/social/index.d.ts.map +1 -1
- package/dist/tools/social/index.js +4 -3
- package/dist/tools/social/index.js.map +1 -1
- package/dist/tools/trading/index.d.ts.map +1 -1
- package/dist/tools/trading/index.js +7 -21
- package/dist/tools/trading/index.js.map +1 -1
- package/dist/tools/utils/createWallet.d.ts +2 -3
- package/dist/tools/utils/createWallet.d.ts.map +1 -1
- package/dist/tools/utils/createWallet.js +8 -13
- package/dist/tools/utils/createWallet.js.map +1 -1
- package/dist/tools/utils/getAddress.d.ts +2 -3
- package/dist/tools/utils/getAddress.d.ts.map +1 -1
- package/dist/tools/utils/getAddress.js +6 -13
- package/dist/tools/utils/getAddress.js.map +1 -1
- package/dist/tools/utils/getConfig.d.ts +2 -3
- package/dist/tools/utils/getConfig.d.ts.map +1 -1
- package/dist/tools/utils/getConfig.js +5 -13
- package/dist/tools/utils/getConfig.js.map +1 -1
- package/dist/tools/utils/getEthereumAddress.d.ts +2 -3
- package/dist/tools/utils/getEthereumAddress.d.ts.map +1 -1
- package/dist/tools/utils/getEthereumAddress.js +6 -13
- package/dist/tools/utils/getEthereumAddress.js.map +1 -1
- package/dist/tools/utils/getUrlByTokenName.d.ts +2 -3
- package/dist/tools/utils/getUrlByTokenName.d.ts.map +1 -1
- package/dist/tools/utils/getUrlByTokenName.js +6 -20
- package/dist/tools/utils/getUrlByTokenName.js.map +1 -1
- package/dist/tools/utils/isTokenGraduated.d.ts +2 -3
- package/dist/tools/utils/isTokenGraduated.d.ts.map +1 -1
- package/dist/tools/utils/isTokenGraduated.js +6 -17
- package/dist/tools/utils/isTokenGraduated.js.map +1 -1
- package/dist/utils/default-values.d.ts +147 -0
- package/dist/utils/default-values.d.ts.map +1 -0
- package/dist/utils/default-values.js +177 -0
- package/dist/utils/default-values.js.map +1 -0
- package/dist/utils/error-handler.d.ts +9 -2
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js +14 -59
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/error-templates.d.ts +96 -0
- package/dist/utils/error-templates.d.ts.map +1 -0
- package/dist/utils/error-templates.js +244 -0
- package/dist/utils/error-templates.js.map +1 -0
- package/dist/utils/tool-factory.d.ts +154 -0
- package/dist/utils/tool-factory.d.ts.map +1 -0
- package/dist/utils/tool-factory.js +194 -0
- package/dist/utils/tool-factory.js.map +1 -0
- package/dist/utils/tool-registry.d.ts +92 -0
- package/dist/utils/tool-registry.d.ts.map +1 -0
- package/dist/utils/tool-registry.js +227 -0
- package/dist/utils/tool-registry.js.map +1 -0
- package/jest.integration.config.js +70 -0
- package/package.json +9 -5
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Factory Pattern Utilities
|
|
4
|
+
*
|
|
5
|
+
* DRY utilities for creating MCP tools with common patterns.
|
|
6
|
+
* Eliminates duplication across 47 tool definitions.
|
|
7
|
+
*
|
|
8
|
+
* @see Phase 2.1 of refactoring plan
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.toolFactory = void 0;
|
|
12
|
+
exports.createSimpleTokenFetchTool = createSimpleTokenFetchTool;
|
|
13
|
+
exports.createBooleanCheckTool = createBooleanCheckTool;
|
|
14
|
+
exports.createFetchTool = createFetchTool;
|
|
15
|
+
exports.createResolutionTool = createResolutionTool;
|
|
16
|
+
exports.createNoParamTool = createNoParamTool;
|
|
17
|
+
const error_handler_js_1 = require("./error-handler.js");
|
|
18
|
+
const response_formatter_js_1 = require("./response-formatter.js");
|
|
19
|
+
const common_schemas_js_1 = require("../schemas/common-schemas.js");
|
|
20
|
+
// =============================================================================
|
|
21
|
+
// Factory Functions
|
|
22
|
+
// =============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Creates a simple fetch tool that takes tokenName and calls an SDK method
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* export const fetchPoolDetailsTool = createSimpleTokenFetchTool({
|
|
29
|
+
* name: 'gala_launchpad_fetch_pool_details',
|
|
30
|
+
* description: 'Get detailed pool state from GalaChain bonding curve',
|
|
31
|
+
* handler: (sdk, tokenName) => sdk.fetchPoolDetails(tokenName),
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function createSimpleTokenFetchTool(config) {
|
|
36
|
+
return {
|
|
37
|
+
name: config.name,
|
|
38
|
+
description: config.description,
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
tokenName: common_schemas_js_1.TOKEN_NAME_SCHEMA,
|
|
43
|
+
},
|
|
44
|
+
required: ['tokenName'],
|
|
45
|
+
},
|
|
46
|
+
handler: (0, error_handler_js_1.withErrorHandling)(async (sdk, args) => {
|
|
47
|
+
const result = await config.handler(sdk, args.tokenName);
|
|
48
|
+
return (0, response_formatter_js_1.formatSuccess)(result);
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a boolean check tool (e.g., isTokenNameAvailable, isTokenSymbolAvailable)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* export const checkTokenNameTool = createBooleanCheckTool({
|
|
58
|
+
* name: 'gala_launchpad_check_token_name',
|
|
59
|
+
* description: 'Check if token name is available',
|
|
60
|
+
* paramName: 'tokenName',
|
|
61
|
+
* paramSchema: TOKEN_NAME_SCHEMA,
|
|
62
|
+
* handler: (sdk, tokenName) => sdk.isTokenNameAvailable(tokenName),
|
|
63
|
+
* messages: {
|
|
64
|
+
* true: 'Token name is available',
|
|
65
|
+
* false: 'Token name is already taken',
|
|
66
|
+
* },
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
function createBooleanCheckTool(config) {
|
|
71
|
+
return {
|
|
72
|
+
name: config.name,
|
|
73
|
+
description: config.description,
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
[config.paramName]: config.paramSchema,
|
|
78
|
+
},
|
|
79
|
+
required: [config.paramName],
|
|
80
|
+
},
|
|
81
|
+
handler: (0, error_handler_js_1.withErrorHandling)(async (sdk, args) => {
|
|
82
|
+
const value = args[config.paramName];
|
|
83
|
+
const available = await config.handler(sdk, value);
|
|
84
|
+
return (0, response_formatter_js_1.formatBoolean)(available, available ? config.messages.true : config.messages.false);
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Creates a generic fetch tool with custom input schema and handler
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* export const fetchPoolsTool = createFetchTool({
|
|
94
|
+
* name: 'gala_launchpad_fetch_pools',
|
|
95
|
+
* description: 'Fetch token pools from Gala Launchpad',
|
|
96
|
+
* inputSchema: {
|
|
97
|
+
* type: 'object',
|
|
98
|
+
* properties: {
|
|
99
|
+
* type: { type: 'string', enum: ['recent', 'popular'] },
|
|
100
|
+
* page: PAGE_SCHEMA,
|
|
101
|
+
* limit: createLimitSchema('pool', 20),
|
|
102
|
+
* },
|
|
103
|
+
* },
|
|
104
|
+
* handler: (sdk, args) => sdk.fetchPools({
|
|
105
|
+
* type: args.type || 'recent',
|
|
106
|
+
* page: args.page || 1,
|
|
107
|
+
* limit: args.limit || 20,
|
|
108
|
+
* }),
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
function createFetchTool(config) {
|
|
113
|
+
return {
|
|
114
|
+
name: config.name,
|
|
115
|
+
description: config.description,
|
|
116
|
+
inputSchema: config.inputSchema,
|
|
117
|
+
handler: (0, error_handler_js_1.withErrorHandling)(async (sdk, args) => {
|
|
118
|
+
const result = await config.handler(sdk, args);
|
|
119
|
+
return (0, response_formatter_js_1.formatSuccess)(result);
|
|
120
|
+
}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Creates a resolution tool that maps tokenName to some resolved value
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* export const resolveVaultAddressTool = createResolutionTool({
|
|
129
|
+
* name: 'gala_launchpad_resolve_vault_address',
|
|
130
|
+
* description: 'Get GalaChain vault address for a token',
|
|
131
|
+
* resolver: (sdk, tokenName) => sdk.resolveVaultAddress(tokenName),
|
|
132
|
+
* resultKey: 'vaultAddress',
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
function createResolutionTool(config) {
|
|
137
|
+
return {
|
|
138
|
+
name: config.name,
|
|
139
|
+
description: config.description,
|
|
140
|
+
inputSchema: {
|
|
141
|
+
type: 'object',
|
|
142
|
+
properties: {
|
|
143
|
+
tokenName: common_schemas_js_1.TOKEN_NAME_SCHEMA,
|
|
144
|
+
},
|
|
145
|
+
required: ['tokenName'],
|
|
146
|
+
},
|
|
147
|
+
handler: (0, error_handler_js_1.withErrorHandling)(async (sdk, args) => {
|
|
148
|
+
const resolvedValue = await config.resolver(sdk, args.tokenName);
|
|
149
|
+
return (0, response_formatter_js_1.formatSuccess)({
|
|
150
|
+
tokenName: args.tokenName,
|
|
151
|
+
[config.resultKey]: resolvedValue,
|
|
152
|
+
});
|
|
153
|
+
}),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Creates a no-parameter tool that only needs SDK instance
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* export const getAddressTool = createNoParamTool({
|
|
162
|
+
* name: 'gala_launchpad_get_address',
|
|
163
|
+
* description: 'Get the GalaChain address format (eth|0x...) for the authenticated wallet.',
|
|
164
|
+
* handler: (sdk) => sdk.getAddress(),
|
|
165
|
+
* resultKey: 'address',
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
function createNoParamTool(config) {
|
|
170
|
+
return {
|
|
171
|
+
name: config.name,
|
|
172
|
+
description: config.description,
|
|
173
|
+
inputSchema: {
|
|
174
|
+
type: 'object',
|
|
175
|
+
properties: {},
|
|
176
|
+
},
|
|
177
|
+
handler: (0, error_handler_js_1.withErrorHandling)(async (sdk) => {
|
|
178
|
+
const result = await config.handler(sdk);
|
|
179
|
+
// If resultKey provided, wrap in object; otherwise return result directly
|
|
180
|
+
return (0, response_formatter_js_1.formatSuccess)(config.resultKey ? { [config.resultKey]: result } : result);
|
|
181
|
+
}),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
// =============================================================================
|
|
185
|
+
// Exports
|
|
186
|
+
// =============================================================================
|
|
187
|
+
exports.toolFactory = {
|
|
188
|
+
createSimpleTokenFetchTool,
|
|
189
|
+
createBooleanCheckTool,
|
|
190
|
+
createFetchTool,
|
|
191
|
+
createResolutionTool,
|
|
192
|
+
createNoParamTool,
|
|
193
|
+
};
|
|
194
|
+
//# sourceMappingURL=tool-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-factory.js","sourceRoot":"","sources":["../../src/utils/tool-factory.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAiDH,gEAoBC;AAoBD,wDA8BC;AA0BD,0CAmBC;AAeD,oDAwBC;AAeD,8CAmBC;AAzOD,yDAAuD;AACvD,mEAAuE;AACvE,oEAAiE;AA2BjE,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF;;;;;;;;;;;GAWG;AACH,SAAgB,0BAA0B,CAAC,MAI1C;IACC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,qCAAiB;aAC7B;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB;QACD,OAAO,EAAE,IAAA,oCAAiB,EAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAC7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YACzD,OAAO,IAAA,qCAAa,EAAC,MAAM,CAAC,CAAC;QAC/B,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,sBAAsB,CAAC,MA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B,iBAAiB;CAClB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry System
|
|
3
|
+
*
|
|
4
|
+
* Enhanced tool registration with auto-validation, metadata, and search capabilities.
|
|
5
|
+
* Provides runtime validation and developer-friendly tool discovery.
|
|
6
|
+
*
|
|
7
|
+
* @see Phase 3.1 of refactoring plan
|
|
8
|
+
*/
|
|
9
|
+
import type { MCPTool } from '../types/mcp.js';
|
|
10
|
+
/**
|
|
11
|
+
* Tool category metadata
|
|
12
|
+
*/
|
|
13
|
+
export interface ToolCategory {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
tools: MCPTool[];
|
|
17
|
+
count: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tool registry with metadata and search capabilities
|
|
21
|
+
*/
|
|
22
|
+
export interface ToolRegistry {
|
|
23
|
+
tools: MCPTool[];
|
|
24
|
+
categories: Map<string, ToolCategory>;
|
|
25
|
+
totalCount: number;
|
|
26
|
+
expectedCount: number;
|
|
27
|
+
isValid: boolean;
|
|
28
|
+
errors: string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Tool validation result
|
|
32
|
+
*/
|
|
33
|
+
export interface ToolValidationResult {
|
|
34
|
+
isValid: boolean;
|
|
35
|
+
errors: string[];
|
|
36
|
+
warnings: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Validates a single tool definition
|
|
40
|
+
*/
|
|
41
|
+
export declare function validateTool(tool: MCPTool): ToolValidationResult;
|
|
42
|
+
/**
|
|
43
|
+
* Validates all tools in a registry
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateTools(tools: MCPTool[]): ToolValidationResult;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a tool registry with metadata and validation
|
|
48
|
+
*/
|
|
49
|
+
export declare function createToolRegistry(categories: Array<{
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
tools: MCPTool[];
|
|
53
|
+
}>, expectedCount?: number): ToolRegistry;
|
|
54
|
+
/**
|
|
55
|
+
* Finds a tool by name
|
|
56
|
+
*/
|
|
57
|
+
export declare function findTool(registry: ToolRegistry, name: string): MCPTool | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Finds tools by category
|
|
60
|
+
*/
|
|
61
|
+
export declare function findToolsByCategory(registry: ToolRegistry, categoryName: string): MCPTool[];
|
|
62
|
+
/**
|
|
63
|
+
* Searches tools by name pattern
|
|
64
|
+
*/
|
|
65
|
+
export declare function searchTools(registry: ToolRegistry, pattern: string): MCPTool[];
|
|
66
|
+
/**
|
|
67
|
+
* Gets tool statistics by category
|
|
68
|
+
*/
|
|
69
|
+
export declare function getToolStatistics(registry: ToolRegistry): {
|
|
70
|
+
total: number;
|
|
71
|
+
byCategory: Record<string, number>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Logs tool registry statistics
|
|
75
|
+
*/
|
|
76
|
+
export declare function logToolRegistry(registry: ToolRegistry): void;
|
|
77
|
+
/**
|
|
78
|
+
* Generates markdown documentation for tool registry
|
|
79
|
+
*/
|
|
80
|
+
export declare function generateToolDocumentation(registry: ToolRegistry): string;
|
|
81
|
+
export declare const toolRegistry: {
|
|
82
|
+
createToolRegistry: typeof createToolRegistry;
|
|
83
|
+
validateTool: typeof validateTool;
|
|
84
|
+
validateTools: typeof validateTools;
|
|
85
|
+
findTool: typeof findTool;
|
|
86
|
+
findToolsByCategory: typeof findToolsByCategory;
|
|
87
|
+
searchTools: typeof searchTools;
|
|
88
|
+
getToolStatistics: typeof getToolStatistics;
|
|
89
|
+
logToolRegistry: typeof logToolRegistry;
|
|
90
|
+
generateToolDocumentation: typeof generateToolDocumentation;
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=tool-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/utils/tool-registry.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ACtB,YAAY,EAAE,MAAM,GACnB,OAAO,EAAE,CAGX;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAG9E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAWA;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAgB5D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAiBxE;AAMD,eAAO,MAAM,YAAY;;;;;;;;;;CAUxB,CAAC"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Registry System
|
|
4
|
+
*
|
|
5
|
+
* Enhanced tool registration with auto-validation, metadata, and search capabilities.
|
|
6
|
+
* Provides runtime validation and developer-friendly tool discovery.
|
|
7
|
+
*
|
|
8
|
+
* @see Phase 3.1 of refactoring plan
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.toolRegistry = void 0;
|
|
12
|
+
exports.validateTool = validateTool;
|
|
13
|
+
exports.validateTools = validateTools;
|
|
14
|
+
exports.createToolRegistry = createToolRegistry;
|
|
15
|
+
exports.findTool = findTool;
|
|
16
|
+
exports.findToolsByCategory = findToolsByCategory;
|
|
17
|
+
exports.searchTools = searchTools;
|
|
18
|
+
exports.getToolStatistics = getToolStatistics;
|
|
19
|
+
exports.logToolRegistry = logToolRegistry;
|
|
20
|
+
exports.generateToolDocumentation = generateToolDocumentation;
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Validation Functions
|
|
23
|
+
// =============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Validates a single tool definition
|
|
26
|
+
*/
|
|
27
|
+
function validateTool(tool) {
|
|
28
|
+
const errors = [];
|
|
29
|
+
const warnings = [];
|
|
30
|
+
// Required fields
|
|
31
|
+
if (!tool.name) {
|
|
32
|
+
errors.push('Tool name is required');
|
|
33
|
+
}
|
|
34
|
+
else if (typeof tool.name !== 'string') {
|
|
35
|
+
errors.push('Tool name must be a string');
|
|
36
|
+
}
|
|
37
|
+
else if (!tool.name.startsWith('gala_launchpad_')) {
|
|
38
|
+
warnings.push(`Tool name "${tool.name}" should start with "gala_launchpad_"`);
|
|
39
|
+
}
|
|
40
|
+
if (!tool.description) {
|
|
41
|
+
errors.push('Tool description is required');
|
|
42
|
+
}
|
|
43
|
+
else if (typeof tool.description !== 'string') {
|
|
44
|
+
errors.push('Tool description must be a string');
|
|
45
|
+
}
|
|
46
|
+
if (!tool.inputSchema) {
|
|
47
|
+
errors.push('Tool inputSchema is required');
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// Validate input schema structure
|
|
51
|
+
if (tool.inputSchema.type !== 'object') {
|
|
52
|
+
errors.push('inputSchema.type must be "object"');
|
|
53
|
+
}
|
|
54
|
+
if (!tool.inputSchema.properties) {
|
|
55
|
+
warnings.push('inputSchema.properties is empty');
|
|
56
|
+
}
|
|
57
|
+
if (tool.inputSchema.required && !Array.isArray(tool.inputSchema.required)) {
|
|
58
|
+
errors.push('inputSchema.required must be an array');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!tool.handler) {
|
|
62
|
+
errors.push('Tool handler is required');
|
|
63
|
+
}
|
|
64
|
+
else if (typeof tool.handler !== 'function') {
|
|
65
|
+
errors.push('Tool handler must be a function');
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
isValid: errors.length === 0,
|
|
69
|
+
errors,
|
|
70
|
+
warnings,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Validates all tools in a registry
|
|
75
|
+
*/
|
|
76
|
+
function validateTools(tools) {
|
|
77
|
+
const allErrors = [];
|
|
78
|
+
const allWarnings = [];
|
|
79
|
+
const toolNames = new Set();
|
|
80
|
+
tools.forEach((tool, index) => {
|
|
81
|
+
const result = validateTool(tool);
|
|
82
|
+
// Collect errors with tool context
|
|
83
|
+
result.errors.forEach((error) => {
|
|
84
|
+
allErrors.push(`Tool #${index + 1} (${tool.name || 'unknown'}): ${error}`);
|
|
85
|
+
});
|
|
86
|
+
result.warnings.forEach((warning) => {
|
|
87
|
+
allWarnings.push(`Tool #${index + 1} (${tool.name || 'unknown'}): ${warning}`);
|
|
88
|
+
});
|
|
89
|
+
// Check for duplicate names
|
|
90
|
+
if (tool.name) {
|
|
91
|
+
if (toolNames.has(tool.name)) {
|
|
92
|
+
allErrors.push(`Duplicate tool name: ${tool.name}`);
|
|
93
|
+
}
|
|
94
|
+
toolNames.add(tool.name);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
isValid: allErrors.length === 0,
|
|
99
|
+
errors: allErrors,
|
|
100
|
+
warnings: allWarnings,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// =============================================================================
|
|
104
|
+
// Registry Functions
|
|
105
|
+
// =============================================================================
|
|
106
|
+
/**
|
|
107
|
+
* Creates a tool registry with metadata and validation
|
|
108
|
+
*/
|
|
109
|
+
function createToolRegistry(categories, expectedCount) {
|
|
110
|
+
const allTools = [];
|
|
111
|
+
const categoryMap = new Map();
|
|
112
|
+
const registryErrors = [];
|
|
113
|
+
// Process each category
|
|
114
|
+
categories.forEach((category) => {
|
|
115
|
+
const toolCategory = {
|
|
116
|
+
name: category.name,
|
|
117
|
+
description: category.description,
|
|
118
|
+
tools: category.tools,
|
|
119
|
+
count: category.tools.length,
|
|
120
|
+
};
|
|
121
|
+
categoryMap.set(category.name, toolCategory);
|
|
122
|
+
allTools.push(...category.tools);
|
|
123
|
+
});
|
|
124
|
+
// Validate all tools
|
|
125
|
+
const validation = validateTools(allTools);
|
|
126
|
+
registryErrors.push(...validation.errors);
|
|
127
|
+
// Check expected count
|
|
128
|
+
const actualCount = allTools.length;
|
|
129
|
+
const hasExpectedCount = expectedCount !== undefined;
|
|
130
|
+
const countMatches = hasExpectedCount ? actualCount === expectedCount : true;
|
|
131
|
+
if (hasExpectedCount && !countMatches) {
|
|
132
|
+
registryErrors.push(`Tool count mismatch: expected ${expectedCount}, got ${actualCount}`);
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
tools: allTools,
|
|
136
|
+
categories: categoryMap,
|
|
137
|
+
totalCount: actualCount,
|
|
138
|
+
expectedCount: expectedCount ?? actualCount,
|
|
139
|
+
isValid: registryErrors.length === 0,
|
|
140
|
+
errors: registryErrors,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Finds a tool by name
|
|
145
|
+
*/
|
|
146
|
+
function findTool(registry, name) {
|
|
147
|
+
return registry.tools.find((tool) => tool.name === name);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Finds tools by category
|
|
151
|
+
*/
|
|
152
|
+
function findToolsByCategory(registry, categoryName) {
|
|
153
|
+
const category = registry.categories.get(categoryName);
|
|
154
|
+
return category ? category.tools : [];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Searches tools by name pattern
|
|
158
|
+
*/
|
|
159
|
+
function searchTools(registry, pattern) {
|
|
160
|
+
const regex = new RegExp(pattern, 'i');
|
|
161
|
+
return registry.tools.filter((tool) => regex.test(tool.name));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Gets tool statistics by category
|
|
165
|
+
*/
|
|
166
|
+
function getToolStatistics(registry) {
|
|
167
|
+
const byCategory = {};
|
|
168
|
+
registry.categories.forEach((category, name) => {
|
|
169
|
+
byCategory[name] = category.count;
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
total: registry.totalCount,
|
|
173
|
+
byCategory,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// =============================================================================
|
|
177
|
+
// Logging and Reporting
|
|
178
|
+
// =============================================================================
|
|
179
|
+
/**
|
|
180
|
+
* Logs tool registry statistics
|
|
181
|
+
*/
|
|
182
|
+
function logToolRegistry(registry) {
|
|
183
|
+
console.log('\n📦 Tool Registry Statistics:');
|
|
184
|
+
console.log(` Total Tools: ${registry.totalCount}/${registry.expectedCount}`);
|
|
185
|
+
console.log(` Valid: ${registry.isValid ? '✅' : '❌'}`);
|
|
186
|
+
if (!registry.isValid && registry.errors.length > 0) {
|
|
187
|
+
console.log('\n❌ Validation Errors:');
|
|
188
|
+
registry.errors.forEach((error) => console.log(` - ${error}`));
|
|
189
|
+
}
|
|
190
|
+
console.log('\n📂 Categories:');
|
|
191
|
+
registry.categories.forEach((category) => {
|
|
192
|
+
console.log(` ${category.name}: ${category.count} tools`);
|
|
193
|
+
});
|
|
194
|
+
console.log('');
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Generates markdown documentation for tool registry
|
|
198
|
+
*/
|
|
199
|
+
function generateToolDocumentation(registry) {
|
|
200
|
+
let doc = '# MCP Tool Registry\n\n';
|
|
201
|
+
doc += `**Total Tools**: ${registry.totalCount}\n\n`;
|
|
202
|
+
doc += '## Categories\n\n';
|
|
203
|
+
registry.categories.forEach((category) => {
|
|
204
|
+
doc += `### ${category.name} (${category.count} tools)\n\n`;
|
|
205
|
+
doc += `${category.description}\n\n`;
|
|
206
|
+
category.tools.forEach((tool) => {
|
|
207
|
+
doc += `- **${tool.name}**: ${tool.description}\n`;
|
|
208
|
+
});
|
|
209
|
+
doc += '\n';
|
|
210
|
+
});
|
|
211
|
+
return doc;
|
|
212
|
+
}
|
|
213
|
+
// =============================================================================
|
|
214
|
+
// Export All
|
|
215
|
+
// =============================================================================
|
|
216
|
+
exports.toolRegistry = {
|
|
217
|
+
createToolRegistry,
|
|
218
|
+
validateTool,
|
|
219
|
+
validateTools,
|
|
220
|
+
findTool,
|
|
221
|
+
findToolsByCategory,
|
|
222
|
+
searchTools,
|
|
223
|
+
getToolStatistics,
|
|
224
|
+
logToolRegistry,
|
|
225
|
+
generateToolDocumentation,
|
|
226
|
+
};
|
|
227
|
+
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../src/utils/tool-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA8CH,oCA6CC;AAKD,sCA+BC;AASD,gDA4CC;AAKD,4BAEC;AAKD,kDAMC;AAKD,kCAGC;AAKD,8CAcC;AASD,0CAgBC;AAKD,8DAiBC;AAzOD,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAa;IACxC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,kBAAkB;IAClB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC5C,CAAC;SAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACpD,QAAQ,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,uCAAuC,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IAC9C,CAAC;SAAM,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IACnD,CA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ACb,gFAAgF;AAEnE,QAAA,YAAY,GAAG;IAC1B,kBAAkB;IAClB,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,mBAAmB;IACnB,WAAW;IACX,iBAAiB;IACjB,eAAe;IACf,yBAAyB;CAC1B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jest Configuration for Integration Tests
|
|
3
|
+
*
|
|
4
|
+
* Integration tests use real SDK instances and make actual API calls.
|
|
5
|
+
* Requires valid PRIVATE_KEY environment variable.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
// Use ts-jest for TypeScript support
|
|
10
|
+
preset: 'ts-jest',
|
|
11
|
+
|
|
12
|
+
// Node.js environment (MCP server is server-side)
|
|
13
|
+
testEnvironment: 'node',
|
|
14
|
+
|
|
15
|
+
// Integration test file location patterns
|
|
16
|
+
roots: ['<rootDir>/src'],
|
|
17
|
+
testMatch: ['**/__tests__/integration/**/*.integration.test.ts'],
|
|
18
|
+
|
|
19
|
+
// Coverage collection
|
|
20
|
+
collectCoverageFrom: [
|
|
21
|
+
'src/tools/**/*.ts',
|
|
22
|
+
'!src/tools/**/__tests__/**',
|
|
23
|
+
'!src/**/*.d.ts',
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
// Coverage reporters
|
|
27
|
+
coverageReporters: ['text', 'text-summary', 'html', 'lcov'],
|
|
28
|
+
|
|
29
|
+
// Module path aliases
|
|
30
|
+
moduleNameMapper: {
|
|
31
|
+
'^@/(.*}$': '<rootDir>/src/$1',
|
|
32
|
+
'^(\\.{1,2}/.*)\\.js$': '$1', // Map .js imports to .ts files
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// Transform files with ts-jest
|
|
36
|
+
transform: {
|
|
37
|
+
'^.+\\.ts$': [
|
|
38
|
+
'ts-jest',
|
|
39
|
+
{
|
|
40
|
+
tsconfig: {
|
|
41
|
+
module: 'commonjs',
|
|
42
|
+
strict: true,
|
|
43
|
+
esModuleInterop: true,
|
|
44
|
+
skipLibCheck: true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
// File extensions to consider
|
|
51
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
|
|
52
|
+
|
|
53
|
+
// Ignore patterns
|
|
54
|
+
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/.history/'],
|
|
55
|
+
|
|
56
|
+
// Setup files (if needed for global test setup)
|
|
57
|
+
// setupFilesAfterEnv: ['<rootDir>/src/__tests__/setup.ts'],
|
|
58
|
+
|
|
59
|
+
// Clear mocks between tests
|
|
60
|
+
clearMocks: true,
|
|
61
|
+
|
|
62
|
+
// Verbose output
|
|
63
|
+
verbose: true,
|
|
64
|
+
|
|
65
|
+
// Integration tests may take longer
|
|
66
|
+
testTimeout: 60000, // 60 seconds
|
|
67
|
+
|
|
68
|
+
// Maximum worker threads (optimize for CI/CD)
|
|
69
|
+
maxWorkers: '50%',
|
|
70
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gala-chain/launchpad-mcp-server",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "MCP server for Gala Launchpad SDK with 47 tools + 14 slash commands - Production-grade AI agent integration with comprehensive validation, optimized performance, and 80%+ test coverage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"test": "jest --passWithNoTests",
|
|
14
14
|
"test:watch": "jest --watch",
|
|
15
15
|
"test:coverage": "jest --coverage",
|
|
16
|
+
"test:integration": "jest --config jest.integration.config.js",
|
|
17
|
+
"test:integration:coverage": "jest --config jest.integration.config.js --coverage",
|
|
18
|
+
"test:prompts": "npm run build && node src/scripts/test-all-prompts.ts",
|
|
19
|
+
"test:all": "npm run test && npm run test:integration && npm run test:prompts",
|
|
16
20
|
"typecheck": "tsc --noEmit",
|
|
17
21
|
"lint": "eslint src --ext .ts",
|
|
18
22
|
"lint:fix": "eslint src --ext .ts --fix",
|
|
@@ -56,14 +60,14 @@
|
|
|
56
60
|
"registry": "https://registry.npmjs.org/"
|
|
57
61
|
},
|
|
58
62
|
"dependencies": {
|
|
59
|
-
"@gala-chain/launchpad-sdk": "^3.9.0",
|
|
60
|
-
"@modelcontextprotocol/sdk": "^0.5.0",
|
|
61
|
-
"ethers": "^6.15.0",
|
|
62
63
|
"@gala-chain/api": "^2.4.3",
|
|
63
64
|
"@gala-chain/connect": "^2.4.3",
|
|
64
|
-
"
|
|
65
|
+
"@gala-chain/launchpad-sdk": "^3.9.1",
|
|
66
|
+
"@modelcontextprotocol/sdk": "^0.5.0",
|
|
65
67
|
"axios": "^1.12.2",
|
|
66
68
|
"bignumber.js": "^9.1.2",
|
|
69
|
+
"ethers": "^6.15.0",
|
|
70
|
+
"socket.io-client": "^4.8.1",
|
|
67
71
|
"zod": "^3.25.76",
|
|
68
72
|
"zod-to-json-schema": "^3.24.6"
|
|
69
73
|
},
|