Skip to main content
Glama
opentofu

OpenTofu MCP Server

Official
by opentofu

get-module-details

Retrieve detailed information about a specific OpenTofu module by providing its namespace, name, and target platform to access module specifications and configurations.

Instructions

Get detailed information about a specific OpenTofu module by namespace, name, and target. Use the simple module name, NOT the full repository name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceYesModule namespace without prefix (e.g., 'terraform-aws-modules')
nameYesSimple module name WITHOUT 'terraform-aws-' or similar prefix (e.g., 'vpc', 's3-bucket')
targetYesModule target platform (e.g., 'aws', 'kubernetes', 'azurerm')

Implementation Reference

  • MCP tool handler for 'get-module-details': fetches details using RegistryClient, renders with renderModuleDetails, handles errors.
    async (params) => {
      try {
        const module = await client.getModuleDetails(params.namespace, params.name, params.target);
        return textResult(renderModuleDetails(module));
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : "Module not found";
        return textResult(`Failed to get details for module ${params.namespace}/${params.name} (${params.target}): ${errorMessage}`);
      }
    },
  • Zod input schema defining parameters for get-module-details tool: namespace, name, target.
    const moduleDetailsSchema = {
      namespace: z.string().min(1).describe("Module namespace without prefix (e.g., 'terraform-aws-modules')"),
      name: z.string().min(1).describe("Simple module name WITHOUT 'terraform-aws-' or similar prefix (e.g., 'vpc', 's3-bucket')"),
      target: z.string().min(1).describe("Module target platform (e.g., 'aws', 'kubernetes', 'azurerm')"),
    };
  • Registration of the 'get-module-details' MCP tool via server.tool with description, schema, and handler.
    server.tool(
      "get-module-details",
      "Get detailed information about a specific OpenTofu module by namespace, name, and target. Use the simple module name, NOT the full repository name.",
      moduleDetailsSchema,
      async (params) => {
        try {
          const module = await client.getModuleDetails(params.namespace, params.name, params.target);
          return textResult(renderModuleDetails(module));
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : "Module not found";
          return textResult(`Failed to get details for module ${params.namespace}/${params.name} (${params.target}): ${errorMessage}`);
        }
      },
    );
  • RegistryClient.getModuleDetails: Fetches the module JSON from OpenTofu Registry API endpoint.
    async getModuleDetails(namespace: string, name: string, target: string): Promise<apiDefinition["Module"]> {
      const path = `/registry/docs/modules/${namespace}/${name}/${target}/index.json`;
      return await this.fetchFromApi<apiDefinition["Module"]>(path);
    }
  • renderModuleDetails: Formats the fetched module data into a human-readable markdown string.
    export function renderModuleDetails(module: apiDefinition["Module"]): string {
      return `## Module: ${module.addr.display}\n
    ${module.description}
    
    **Available Versions**: ${module.versions.map((v) => v.id).join(", ")}
    
    **Popularity Score**: ${module.popularity}
    ${module.fork_of ? `\n**Forked from**: ${module.fork_of.display}\n` : ""}${module.fork_count > 0 ? `\n**Fork count**: ${module.fork_count}\n` : ""}`;
    }

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/opentofu/opentofu-mcp-server'

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