@gala-chain/launchpad-mcp-server
Version:
MCP server for Gala Launchpad SDK with 55 tools + 14 slash commands - Production-grade AI agent integration with comprehensive validation, optimized performance, and 80%+ test coverage
154 lines • 4.65 kB
TypeScript
/**
* Tool Factory Pattern Utilities
*
* DRY utilities for creating MCP tools with common patterns.
* Eliminates duplication across 47 tool definitions.
*
* @see Phase 2.1 of refactoring plan
*/
import type { MCPTool } from '../types/mcp.js';
import type { LaunchpadSDK } from '@gala-chain/launchpad-sdk';
/**
* Handler function that takes SDK and args, returns result
*/
type ToolHandler<T = any> = (sdk: LaunchpadSDK, args: any) => Promise<T>;
/**
* Simple handler that only needs SDK and tokenName
* Can return the result or null
*/
type SimpleTokenHandler<T = any> = (sdk: LaunchpadSDK, tokenName: string) => Promise<T | null>;
/**
* Boolean check handler that returns true/false
*/
type BooleanCheckHandler = (sdk: LaunchpadSDK, value: string) => Promise<boolean>;
/**
* No-parameter handler that only needs SDK, returns result
*/
type NoParamHandler<T = any> = (sdk: LaunchpadSDK) => T | Promise<T>;
/**
* Creates a simple fetch tool that takes tokenName and calls an SDK method
*
* @example
* ```typescript
* export const fetchPoolDetailsTool = createSimpleTokenFetchTool({
* name: 'gala_launchpad_fetch_pool_details',
* description: 'Get detailed pool state from GalaChain bonding curve',
* handler: (sdk, tokenName) => sdk.fetchPoolDetails(tokenName),
* });
* ```
*/
export declare function createSimpleTokenFetchTool(config: {
name: string;
description: string;
handler: SimpleTokenHandler;
}): MCPTool;
/**
* Creates a boolean check tool (e.g., isTokenNameAvailable, isTokenSymbolAvailable)
*
* @example
* ```typescript
* export const checkTokenNameTool = createBooleanCheckTool({
* name: 'gala_launchpad_check_token_name',
* description: 'Check if token name is available',
* paramName: 'tokenName',
* paramSchema: TOKEN_NAME_SCHEMA,
* handler: (sdk, tokenName) => sdk.isTokenNameAvailable(tokenName),
* messages: {
* true: 'Token name is available',
* false: 'Token name is already taken',
* },
* });
* ```
*/
export declare function createBooleanCheckTool(config: {
name: string;
description: string;
paramName: string;
paramSchema: any;
handler: BooleanCheckHandler;
messages: {
true: string;
false: string;
};
}): MCPTool;
/**
* Creates a generic fetch tool with custom input schema and handler
*
* @example
* ```typescript
* export const fetchPoolsTool = createFetchTool({
* name: 'gala_launchpad_fetch_pools',
* description: 'Fetch token pools from Gala Launchpad',
* inputSchema: {
* type: 'object',
* properties: {
* type: { type: 'string', enum: ['recent', 'popular'] },
* page: PAGE_SCHEMA,
* limit: createLimitSchema('pool', 20),
* },
* },
* handler: (sdk, args) => sdk.fetchPools({
* type: args.type || 'recent',
* page: args.page || 1,
* limit: args.limit || 20,
* }),
* });
* ```
*/
export declare function createFetchTool(config: {
name: string;
description: string;
inputSchema: {
type: 'object';
properties: Record<string, any>;
required?: string[];
};
handler: ToolHandler;
}): MCPTool;
/**
* Creates a resolution tool that maps tokenName to some resolved value
*
* @example
* ```typescript
* export const resolveVaultAddressTool = createResolutionTool({
* name: 'gala_launchpad_resolve_vault_address',
* description: 'Get GalaChain vault address for a token',
* resolver: (sdk, tokenName) => sdk.resolveVaultAddress(tokenName),
* resultKey: 'vaultAddress',
* });
* ```
*/
export declare function createResolutionTool(config: {
name: string;
description: string;
resolver: SimpleTokenHandler<string | any>;
resultKey: string;
}): MCPTool;
/**
* Creates a no-parameter tool that only needs SDK instance
*
* @example
* ```typescript
* export const getAddressTool = createNoParamTool({
* name: 'gala_launchpad_get_address',
* description: 'Get the GalaChain address format (eth|0x...) for the authenticated wallet.',
* handler: (sdk) => sdk.getAddress(),
* resultKey: 'address',
* });
* ```
*/
export declare function createNoParamTool(config: {
name: string;
description: string;
handler: NoParamHandler;
resultKey?: string;
}): MCPTool;
export declare const toolFactory: {
createSimpleTokenFetchTool: typeof createSimpleTokenFetchTool;
createBooleanCheckTool: typeof createBooleanCheckTool;
createFetchTool: typeof createFetchTool;
createResolutionTool: typeof createResolutionTool;
createNoParamTool: typeof createNoParamTool;
};
export {};
//# sourceMappingURL=tool-factory.d.ts.map