servers
Manage Coolify deployments programmatically by performing operations like listing, creating, updating, and deleting servers, validating configurations, and handling resources or domains.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | No | JSON request body | |
| id | No | Server UUID | |
| operation | Yes | Operation to perform |
Implementation Reference
- src/mcp-server.ts:221-257 (registration)Registers the 'servers' MCP tool using server.tool(), defining the input schema with Zod and a wrapper async handler that logs args, calls serversHandler, and formats the response or error.// Register servers tool with proper Zod schema format server.tool( 'servers', { operation: z.enum([ 'list', 'get', 'create', 'update', 'delete', 'validate', 'resources', 'domains' ]).describe("Operation to perform"), id: z.string().optional().describe("Server UUID"), body: z.string().optional().describe("JSON request body") }, async ({ operation, id, body }) => { try { console.error('Servers tool received args:', JSON.stringify({ operation, id, body }, null, 2)); const result = await serversHandler({ operation, id, body }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/mcp/tools/servers.ts:19-62 (handler)The core handler function serversHandler that implements the tool logic by switching on the 'operation' parameter and invoking safeApiCall wrappers around generated API functions for list, get, create, update, delete, validate, resources, and domains.export async function serversHandler(args: ServersToolArgs) { const { operation, id, body } = args; switch (operation) { case 'list': return await safeApiCall(() => listServers()); case 'get': if (!id) throw new Error('ID required for get operation'); return await safeApiCall(() => getServerByUuid({ path: { uuid: id } })); case 'create': if (!body) throw new Error('Body required for create operation'); const createData = JSON.parse(body); return await safeApiCall(() => createServer({ body: createData })); case 'update': if (!id || !body) throw new Error('ID and body required for update operation'); const updateData = JSON.parse(body); return await safeApiCall(() => updateServerByUuid({ path: { uuid: id }, body: updateData } as any)); case 'delete': if (!id) throw new Error('ID required for delete operation'); return await safeApiCall(() => deleteServerByUuid({ path: { uuid: id } })); case 'validate': if (!id) throw new Error('ID required for validate operation'); return await safeApiCall(() => validateServerByUuid({ path: { uuid: id } })); case 'resources': if (!id) throw new Error('ID required for resources operation'); return await safeApiCall(() => getResourcesByServerUuid({ path: { uuid: id } })); case 'domains': if (!id) throw new Error('ID required for domains operation'); return await safeApiCall(() => getDomainsByServerUuid({ path: { uuid: id } })); default: throw new Error(`Unknown operation: ${operation}`); } }
- src/mcp-server.ts:224-231 (schema)Input schema for the 'servers' tool defined using Zod, specifying 'operation' enum, optional 'id', and optional 'body'.{ operation: z.enum([ 'list', 'get', 'create', 'update', 'delete', 'validate', 'resources', 'domains' ]).describe("Operation to perform"), id: z.string().optional().describe("Server UUID"), body: z.string().optional().describe("JSON request body") },