import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
import * as z from 'zod';
import { executeClio } from '../clio/executor.js';
/**
* Register CLIO environment management tools.
* Currently implements: ping, restart
*/
export function registerEnvironmentTools(server: McpServer): void {
server.registerTool(
'clio-environment',
{
description: 'Manage Creatio environments. Supports ping (check environment health) and restart (restart web application).',
inputSchema: {
command: z.enum(['ping', 'restart']).describe('The environment command to execute'),
environment: z.string().describe('Target environment name (registered via clio reg-web-app)'),
},
annotations: {
title: 'CLIO Environment Management',
destructiveHint: true, // restart is destructive
readOnlyHint: false,
},
},
async ({ command, environment }): Promise<CallToolResult> => {
const result = await executeClio(command, ['-e', environment]);
if (!result.success) {
return {
content: [
{
type: 'text',
text: `Error executing clio ${command}:\n${result.error}\n\n${result.output}`,
},
],
isError: true,
};
}
return {
content: [
{
type: 'text',
text: result.output,
},
],
};
}
);
}