Skip to main content
Glama
opentofu

OpenTofu MCP Server

Official
by opentofu

get-resource-docs

Retrieve detailed documentation for OpenTofu resources by specifying provider namespace, name, and resource identifier to understand configuration options and usage.

Instructions

Get detailed documentation for a specific OpenTofu resource by provider namespace, provider name, and resource name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceYesProvider namespace (e.g., 'hashicorp', 'opentofu')
nameYesProvider name WITHOUT 'terraform-provider-' prefix (e.g., 'aws', 'kubernetes')
resourceYesResource name WITHOUT provider prefix (e.g., 's3_bucket', 'instance')
versionNoProvider version (e.g., 'v4.0.0'). If not specified, latest version will be used

Implementation Reference

  • The tool handler function for 'get-resource-docs', which calls RegistryClient.getResourceDocs and returns the documentation as text, with error handling.
    server.tool("get-resource-docs", "Get detailed documentation for a specific OpenTofu resource by provider namespace, provider name, and resource name.", resourceDocsSchema, async (params) => {
      try {
        const resourceDocs = await client.getResourceDocs(params.namespace, params.name, params.resource, params.version);
        return textResult(resourceDocs);
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : "Resource documentation not found";
        return textResult(`Failed to get documentation for resource ${params.name}_${params.resource}: ${errorMessage}`);
      }
    });
  • Input schema/validation for the get-resource-docs tool using Zod.
    const resourceDocsSchema = {
      namespace: z.string().min(1).describe("Provider namespace (e.g., 'hashicorp', 'opentofu')"),
      name: z.string().min(1).describe("Provider name WITHOUT 'terraform-provider-' prefix (e.g., 'aws', 'kubernetes')"),
      resource: z.string().min(1).describe("Resource name WITHOUT provider prefix (e.g., 's3_bucket', 'instance')"),
      version: z.string().optional().describe("Provider version (e.g., 'v4.0.0'). If not specified, latest version will be used"),
    };
  • RegistryClient method that retrieves resource documentation by delegating to fetchMarkdownDoc.
    async getResourceDocs(namespace: string, name: string, target: string, version?: string): Promise<string> {
      return await this.fetchMarkdownDoc("resource", namespace, name, target, version);
    }
  • Core helper function that resolves the provider version if needed and fetches the markdown documentation from the OpenTofu Registry API.
      private async fetchMarkdownDoc(docType: DocType, namespace: string, name: string, docName: string, version?: string): Promise<string> {
        let targetVersion = version;
        if (!targetVersion) {
          targetVersion = await this.getLatestProviderVersion(namespace, name);
          if (!targetVersion) {
            throw new Error(`Could not determine latest version for provider ${namespace}/${name}`);
          }
        }
    
        const path = `/registry/docs/providers/${namespace}/${name}/${targetVersion}/${docType}s/${docName}.md`;
        console.error(`Fetching ${path}`);
        return this.fetchFromApi<string>(path, {}, "text");
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves documentation but does not mention potential behaviors such as error handling (e.g., if the resource doesn't exist), rate limits, authentication needs, or the format of the returned documentation. This leaves significant gaps in understanding how the tool operates beyond its basic purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose and lists the key parameters without unnecessary words. Every part of the sentence contributes directly to understanding the tool's function, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool with 4 parameters. It covers the basic purpose and parameters but fails to address behavioral aspects like error handling, return format, or usage constraints. For a read operation without structured output information, more context is needed to ensure the agent can use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with clear descriptions for all parameters (e.g., namespace, name, resource, version). The description adds minimal value beyond the schema by reiterating the parameters but does not provide additional context like examples beyond what's in the schema or explain interactions between parameters. With high schema coverage, a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get detailed documentation') and the target resource ('OpenTofu resource'), distinguishing it from sibling tools like get-datasource-docs or get-provider-details by focusing on resource documentation. It includes the key identifiers needed (provider namespace, provider name, resource name), making the purpose explicit and differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying the required parameters (provider namespace, provider name, resource name), but it does not explicitly state when to use this tool versus alternatives like get-datasource-docs or search-opentofu-registry. No exclusions or prerequisites are mentioned, leaving the context somewhat implied rather than clearly defined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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