Skip to main content
Glama
AgentWong

IAC Memory MCP Server

by AgentWong

get_terraform_resource_info

Retrieve Terraform resource schema and documentation to understand configuration options and usage details for infrastructure-as-code development.

Instructions

Retrieve comprehensive information about a Terraform resource including schema and documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
provider_nameYesName of the Terraform provider
resource_nameYesName of the resource

Implementation Reference

  • The handler function that executes the core logic of the get_terraform_resource_info tool. It retrieves resource information from the database using get_resource_info, formats the output including schema and documentation, and handles errors.
    async def handle_get_terraform_resource_info(
        db: Any, arguments: Dict[str, Any], operation_id: str
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle get_terraform_resource_info tool."""
        try:
            logger.info(
                "Getting resource info",
                extra={
                    "provider_name": arguments["provider_name"],
                    "resource_name": arguments["resource_name"],
                    "operation_id": operation_id,
                },
            )
    
            # Get resource info
            resource = get_resource_info(
                db,
                arguments["resource_name"],
                provider_name=arguments["provider_name"]
            )
            if not resource:
                error_msg = f"Resource '{arguments['resource_name']}' not found for provider '{arguments['provider_name']}'"
                logger.error(error_msg, extra={"operation_id": operation_id})
                return [types.TextContent(
                    type="text",
                    text=error_msg
                )]
    
            # Format output
            output = [
                f"Resource: {resource['name']}",
                f"Provider: {resource['provider_name']}",
                f"Type: {resource['resource_type']}",
                f"Version: {resource['version']}",
                f"Documentation: {resource['doc_url']}",
                "\nSchema:",
                resource["schema"],
            ]
    
            return [types.TextContent(
                type="text",
                text="\n".join(output)
            )]
    
        except Exception as e:
            error_msg = f"Failed to get resource info: {str(e)}"
            logger.error(error_msg, extra={"operation_id": operation_id})
            return [types.TextContent(type="text", text=error_msg)]
  • JSON schema defining the input parameters for the get_terraform_resource_info tool, including required fields provider_name and resource_name.
    "get_terraform_resource_info": {
        "type": "object",
        "description": "Retrieve comprehensive information about a Terraform resource including schema and documentation",
        "required": ["provider_name", "resource_name"],
        "properties": {
            "provider_name": {
                "type": "string",
                "description": "Name of the Terraform provider",
            },
            "resource_name": {"type": "string", "description": "Name of the resource"},
        },
    },
  • Dictionary mapping tool names to their handler functions, registering get_terraform_resource_info to handle_get_terraform_resource_info.
    terraform_tool_handlers = {
        "get_terraform_provider_info": handle_get_terraform_provider_info,
        "list_provider_resources": handle_list_provider_resources,
        "get_terraform_resource_info": handle_get_terraform_resource_info,
        "add_terraform_provider": handle_add_terraform_provider,
        "add_terraform_resource": handle_add_terraform_resource,
        "update_provider_version": handle_update_provider_version,
        "update_resource_schema": handle_update_resource_schema,
    }

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/AgentWong/iac-memory-mcp-server'

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