Skip to main content
Glama
AgentWong
by AgentWong

list_provider_resources

Retrieve Terraform provider resources with optional filtering by type pattern to manage infrastructure components.

Instructions

List all resources associated with a specific Terraform provider

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
provider_nameYesName of the Terraform provider
filter_criteriaNoOptional filtering criteria

Implementation Reference

  • The handler function that implements the tool logic: retrieves provider resources from the database, applies optional regex filtering on resource types, formats a text list of resources with names, types, versions, and documentation URLs, or returns an error message.
    async def handle_list_provider_resources(
        db: Any, arguments: Dict[str, Any], operation_id: str
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle list_provider_resources tool."""
        try:
            logger.info(
                "Listing provider resources",
                extra={
                    "provider_name": arguments["provider_name"],
                    "operation_id": operation_id,
                },
            )
    
            # Get resources
            resources = get_provider_resources(db, arguments["provider_name"])
    
            # Apply any filters
            filter_criteria = arguments.get("filter_criteria", {})
            if filter_criteria:
                if "type_pattern" in filter_criteria:
                    pattern = re.compile(filter_criteria["type_pattern"])
                    resources = [r for r in resources if pattern.match(r["resource_type"])]
    
            # Format output
            if not resources:
                return [types.TextContent(
                    type="text",
                    text=f"No resources found for provider {arguments['provider_name']}"
                )]
    
            output = [f"Resources for provider {arguments['provider_name']}:"]
            for r in resources:
                output.append(
                    f"\n- {r['name']} ({r['resource_type']})"
                    f"\n  Version: {r['version']}"
                    f"\n  Documentation: {r['doc_url']}"
                )
    
            return [types.TextContent(
                type="text",
                text="\n".join(output)
            )]
    
        except Exception as e:
            error_msg = f"Failed to list provider resources: {str(e)}"
            logger.error(error_msg, extra={"operation_id": operation_id})
            return [types.TextContent(type="text", text=error_msg)]
  • Input schema validation for the tool, requiring 'provider_name' and optionally 'filter_criteria' with 'type_pattern' for regex filtering.
    "list_provider_resources": {
        "type": "object",
        "description": "List all resources associated with a specific Terraform provider",
        "required": ["provider_name"],
        "properties": {
            "provider_name": {
                "type": "string",
                "description": "Name of the Terraform provider",
            },
            "filter_criteria": {
                "type": "object",
                "description": "Optional filtering criteria",
                "properties": {
                    "type_pattern": {
                        "type": "string",
                        "description": "Regex pattern to filter resource types",
                    }
                },
            },
        },
    },
  • Registers the 'list_provider_resources' tool handler within the terraform_tool_handlers dictionary used for tool dispatching.
    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,
    }

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-project'

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