codemesh
Version:
Execute TypeScript code against multiple MCP servers, weaving them together into powerful workflows
78 lines (77 loc) • 2.32 kB
TypeScript
import type { DiscoveryResult } from './toolDiscovery.js';
export interface GeneratedToolType {
toolName: string;
serverId: string;
serverName: string;
inputTypeName: string;
inputTypeDefinition: string;
outputTypeName?: string;
outputTypeDefinition?: string;
functionSignature: string;
namespacedServerName: string;
namespacedInputTypeName: string;
namespacedOutputTypeName?: string;
camelCaseMethodName: string;
serverObjectName: string;
inputSchema?: unknown;
outputSchema?: unknown;
description?: string;
}
export interface GeneratedTypes {
tools: GeneratedToolType[];
combinedTypes: string;
toolsNamespace: string;
}
export declare class TypeGeneratorService {
private static instance;
private constructor();
static getInstance(): TypeGeneratorService;
/**
* Generate TypeScript types from discovered tools
*/
generateTypes(discoveryResults: DiscoveryResult[], codemeshDir?: string): Promise<GeneratedTypes>;
/**
* Generate TypeScript types for a single tool
*/
private generateToolType;
/**
* Create a safe TypeScript type name from tool name and server ID
*/
private createSafeTypeName;
/**
* Create a namespaced type name for use within server namespace
*/
private createNamespacedTypeName;
/**
* Generate a TypeScript function signature for a tool
*/
private generateFunctionSignature;
/**
* Generate detailed JSDoc comment for a tool method
*/
private generateDetailedJSDoc;
/**
* Combine all type definitions into a single TypeScript module
*/
private generateCombinedTypes;
/**
* Generate namespaced types and server interfaces
*/
private generateNamespacedTypes;
/**
* Extract interface content from generated type definition
*/
private extractInterfaceContent;
/**
* Generate the tools namespace with all function signatures
*/
private generateToolsNamespace;
/**
* Save generated types to files
*/
saveGeneratedTypes(generatedTypes: GeneratedTypes, outputDir: string): Promise<void>;
/**
* Generate clean tools namespace with only namespaced server objects
*/
private generateNamespacedToolsNamespace;
}