/**
* Execute Module Tool Handlers
* Maps MCP tool calls to Komodo API operations
*/
import type { KomodoClient } from '../../core/KomodoClient';
import { Logger } from '../../utils/logger';
// Import handler functions
import { executeDeploy, type DeployRequest, type DeployResponse } from './Deploy';
import { executeBuild, type BuildRequest, type BuildResponse } from './Build';
import {
startServer,
stopServer,
restartServer,
type ServerLifecycleRequest,
type ServerLifecycleResponse
} from './ServerLifecycle';
import { runProcedure, type RunProcedureRequest, type RunProcedureResponse } from './RunProcedure';
import { triggerAction, type TriggerActionRequest, type TriggerActionResponse } from './TriggerAction';
import { pullRepo, cloneRepo, type PullRepoRequest, type CloneRepoRequest, type RepoOperationResponse } from './RepoOperations';
/**
* Execute module handler registry
* Maps tool names to their handler functions
*/
export class ExecuteHandlers {
private client: KomodoClient;
private logger: Logger;
constructor(client: KomodoClient) {
this.client = client;
this.logger = Logger.getInstance();
}
/**
* Handle komodo_execute_Deploy
*/
async handleDeploy(args: DeployRequest): Promise<DeployResponse> {
this.logger.debug('Handling Deploy tool call', { deploymentId: args.id });
return executeDeploy(this.client, args);
}
/**
* Handle komodo_execute_Build
*/
async handleBuild(args: BuildRequest): Promise<BuildResponse> {
this.logger.debug('Handling Build tool call', { buildId: args.id });
return executeBuild(this.client, args);
}
/**
* Handle komodo_execute_StartServer
*/
async handleStartServer(args: ServerLifecycleRequest): Promise<ServerLifecycleResponse> {
this.logger.debug('Handling StartServer tool call', { serverId: args.id });
return startServer(this.client, args);
}
/**
* Handle komodo_execute_StopServer
*/
async handleStopServer(args: ServerLifecycleRequest): Promise<ServerLifecycleResponse> {
this.logger.debug('Handling StopServer tool call', { serverId: args.id });
return stopServer(this.client, args);
}
/**
* Handle komodo_execute_RestartServer
*/
async handleRestartServer(args: ServerLifecycleRequest): Promise<ServerLifecycleResponse> {
this.logger.debug('Handling RestartServer tool call', { serverId: args.id });
return restartServer(this.client, args);
}
/**
* Handle komodo_execute_RunProcedure
*/
async handleRunProcedure(args: RunProcedureRequest): Promise<RunProcedureResponse> {
this.logger.debug('Handling RunProcedure tool call', { procedureId: args.id });
return runProcedure(this.client, args);
}
/**
* Handle komodo_execute_TriggerAction
*/
async handleTriggerAction(args: TriggerActionRequest): Promise<TriggerActionResponse> {
this.logger.debug('Handling TriggerAction tool call', { actionId: args.id });
return triggerAction(this.client, args);
}
/**
* Handle komodo_execute_PullRepo
*/
async handlePullRepo(args: PullRepoRequest): Promise<RepoOperationResponse> {
this.logger.debug('Handling PullRepo tool call', { repoId: args.id });
return pullRepo(this.client, args);
}
/**
* Handle komodo_execute_CloneRepo
*/
async handleCloneRepo(args: CloneRepoRequest): Promise<RepoOperationResponse> {
this.logger.debug('Handling CloneRepo tool call', { repoId: args.id });
return cloneRepo(this.client, args);
}
/**
* Route tool calls to appropriate handlers
*/
async handleToolCall(toolName: string, args: any): Promise<any> {
switch (toolName) {
case 'komodo_execute_Deploy':
return this.handleDeploy(args);
case 'komodo_execute_Build':
return this.handleBuild(args);
case 'komodo_execute_StartServer':
return this.handleStartServer(args);
case 'komodo_execute_StopServer':
return this.handleStopServer(args);
case 'komodo_execute_RestartServer':
return this.handleRestartServer(args);
case 'komodo_execute_RunProcedure':
return this.handleRunProcedure(args);
case 'komodo_execute_TriggerAction':
return this.handleTriggerAction(args);
case 'komodo_execute_PullRepo':
return this.handlePullRepo(args);
case 'komodo_execute_CloneRepo':
return this.handleCloneRepo(args);
default:
throw new Error(`Unknown execute tool: ${toolName}`);
}
}
}
/**
* Export type definitions for external use
*/
export type {
DeployRequest,
DeployResponse,
BuildRequest,
BuildResponse,
ServerLifecycleRequest,
ServerLifecycleResponse,
RunProcedureRequest,
RunProcedureResponse,
TriggerActionRequest,
TriggerActionResponse,
PullRepoRequest,
CloneRepoRequest,
RepoOperationResponse
};