/**
* Tools Registry
* Central registry for all MCP tools provided by this server
*/
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
import type { OpenClawClient } from '../openclaw-client.js';
import type { SendMessageParams, ExecuteCommandParams, CreateCalendarEventParams, SendEmailParams, GetTaskStatusParams } from '../types.js';
// Import tool definitions and handlers
import {
SendMessageTool,
executeSendMessage,
} from './send-message.js';
import {
ExecuteCommandTool,
executeExecuteCommand,
} from './execute-command.js';
import {
CreateCalendarEventTool,
executeCreateCalendarEvent,
} from './create-calendar-event.js';
import { SendEmailTool, executeSendEmail } from './send-email.js';
import { GetTaskStatusTool, executeGetTaskStatus } from './get-task-status.js';
/**
* All available tools
*/
export const tools: Tool[] = [
SendMessageTool as Tool,
ExecuteCommandTool as Tool,
CreateCalendarEventTool as Tool,
SendEmailTool as Tool,
GetTaskStatusTool as Tool,
];
/**
* Tool handler result type
*/
export type ToolHandlerResult = Promise<{
content: Array<{ type: string; text: string }>;
isError?: boolean;
}>;
/**
* Tool handler type
*/
export type ToolHandler = (
client: OpenClawClient,
args: unknown
) => ToolHandlerResult;
/**
* Tool handlers map
*/
export const toolHandlers: Record<string, ToolHandler> = {
send_message: (client, args) =>
executeSendMessage(client, args as SendMessageParams),
execute_command: (client, args) =>
executeExecuteCommand(client, args as ExecuteCommandParams),
create_calendar_event: (client, args) =>
executeCreateCalendarEvent(client, args as CreateCalendarEventParams),
send_email: (client, args) =>
executeSendEmail(client, args as SendEmailParams),
get_task_status: (client, args) =>
executeGetTaskStatus(client, args as GetTaskStatusParams),
};
/**
* Get tool handler by name
*/
export function getToolHandler(name: string): ToolHandler | undefined {
return toolHandlers[name];
}
/**
* Check if a tool exists
*/
export function hasTool(name: string): boolean {
return name in toolHandlers;
}
/**
* Get all tool names
*/
export function getToolNames(): string[] {
return Object.keys(toolHandlers);
}