Skip to main content
Glama
terrakube-io

Terrakube MCP Server

by terrakube-io

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
NameRequiredDescriptionDefault
descriptionNoModule description
nameYesModule name
organizationIdYesOrganization ID
providerYesProvider name
registryYesRegistry URL

Implementation Reference

  • 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)
        }]
      };
    }
  • 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")
    },
  • 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);
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/terrakube-io/mcp-server-terrakube'

If you have feedback or need assistance with the MCP directory API, please join our Discord server