create-module
Generate new modules within a specified organization to manage Terrakube infrastructure, including defining module name, provider, and registry details for efficient project configuration.
Instructions
Creates a new module in the specified organization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Module description | |
| name | Yes | Module name | |
| organizationId | Yes | Organization ID | |
| provider | Yes | Provider name | |
| registry | Yes | Registry URL |
Implementation Reference
- src/tools/modules.ts:77-108 (handler)The async handler function that executes the 'create-module' tool. It makes a POST request to the Terrakube API to create a new module with the provided name, description, registry, and provider in the specified organization.async ({ organizationId, name, description, registry, provider }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/module`, { method: "POST", headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" }, body: JSON.stringify({ data: { type: "module", attributes: { name, description, registry, provider } } }) }); if (!response.ok) { throw new Error(`Failed to create module: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/tools/modules.ts:70-76 (schema)Zod schema defining the input parameters for the 'create-module' tool: organizationId (required), name (required), description (optional), registry (required), provider (required).{ organizationId: z.string().describe("Organization ID"), name: z.string().describe("Module name"), description: z.string().optional().describe("Module description"), registry: z.string().describe("Registry URL"), provider: z.string().describe("Provider name") },
- src/tools/modules.ts:67-109 (registration)The server.tool() registration of the 'create-module' tool, including name, description, input schema, and handler function within the registerModuleTools function.server.tool( "create-module", "Creates a new module in the specified organization", { organizationId: z.string().describe("Organization ID"), name: z.string().describe("Module name"), description: z.string().optional().describe("Module description"), registry: z.string().describe("Registry URL"), provider: z.string().describe("Provider name") }, async ({ organizationId, name, description, registry, provider }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/module`, { method: "POST", headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" }, body: JSON.stringify({ data: { type: "module", attributes: { name, description, registry, provider } } }) }); if (!response.ok) { throw new Error(`Failed to create module: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );
- src/index.ts:24-24 (registration)Invocation of registerModuleTools(server) in the main server setup, which registers the 'create-module' tool among others.registerModuleTools(server);