Skip to main content
Glama

add_terraform_provider

Add a Terraform provider to the memory store with version, source repository, and documentation details for efficient IaC resource management.

Instructions

Add a new Terraform provider to the memory store with version and documentation information

Input Schema

NameRequiredDescriptionDefault
doc_urlYesDocumentation URL
nameYesProvider name
source_urlYesSource repository URL
versionYesProvider version

Input Schema (JSON Schema)

{ "description": "Add a new Terraform provider to the memory store with version and documentation information", "properties": { "doc_url": { "description": "Documentation URL", "type": "string" }, "name": { "description": "Provider name", "type": "string" }, "source_url": { "description": "Source repository URL", "type": "string" }, "version": { "description": "Provider version", "type": "string" } }, "required": [ "name", "version", "source_url", "doc_url" ], "type": "object" }

Implementation Reference

  • MCP tool handler that validates arguments (name, version, source_url, doc_url), checks version format, logs the operation, calls the DB helper, and returns success/error TextContent.
    async def handle_add_terraform_provider(db: Any, arguments: Dict[str, Any], operation_id: str) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """Handle add_terraform_provider tool.""" # Validate required arguments required_args = ["name", "version", "source_url", "doc_url"] missing_args = [arg for arg in required_args if arg not in arguments] if missing_args: error_msg = f"Missing required arguments for add_terraform_provider: {', '.join(missing_args)}" logger.error(error_msg, extra={"operation_id": operation_id}) return [types.TextContent(type="text", text=error_msg)] # Validate version format (x.y.z) version_pattern = re.compile(r'^\d+\.\d+\.\d+$') if not version_pattern.match(arguments["version"]): error_msg = "Invalid version format. Version must be in x.y.z format (e.g. 1.0.0)" logger.error(error_msg, extra={"operation_id": operation_id}) return [types.TextContent( type="text", text=error_msg )] try: # Add provider logger.info( "Adding Terraform provider", extra={ "provider_name": arguments["name"], "version": arguments["version"], "operation_id": operation_id, }, ) provider_id = add_terraform_provider( db, arguments["name"], arguments["version"], arguments["source_url"], arguments["doc_url"], ) return [types.TextContent( type="text", text=f"Added provider {arguments['name']} with ID: {provider_id}" )] except Exception as e: error_msg = f"Failed to add provider: {str(e)}" logger.error(error_msg, extra={"operation_id": operation_id}) return [types.TextContent(type="text", text=error_msg)]
  • Database helper function that performs the actual INSERT into terraform_providers table, handles transactions, logging, and errors, returns the new provider ID.
    def add_terraform_provider( db: DatabaseManager, name: str, version: str, source_url: str, doc_url: str, ) -> str: """Add a new Terraform provider with proper error handling.""" logger.info( "Adding Terraform provider", extra={"provider_name": name, "version": version, "source_url": source_url}, ) try: with db.get_connection() as conn: conn.execute("BEGIN IMMEDIATE") try: cursor = conn.execute( """INSERT INTO terraform_providers (name, version, source_url, doc_url, updated_at) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)""", (name, version, source_url, doc_url), ) conn.commit() provider_id = str(cursor.lastrowid) logger.info( f"Successfully added provider {name}", extra={"provider_id": provider_id, "provider_name": name}, ) return provider_id except Exception: conn.rollback() raise except sqlite3.Error as e: error_msg = f"Failed to add Terraform provider: {str(e)}" logger.error(error_msg) raise DatabaseError(error_msg)
  • JSON schema defining the input parameters for the tool: required name, version, source_url, doc_url as strings.
    "add_terraform_provider": { "type": "object", "description": "Add a new Terraform provider to the memory store with version and documentation information", "required": ["name", "version", "source_url", "doc_url"], "properties": { "name": {"type": "string", "description": "Provider name"}, "version": {"type": "string", "description": "Provider version"}, "source_url": {"type": "string", "description": "Source repository URL"}, "doc_url": {"type": "string", "description": "Documentation URL"}, },
  • Local registration mapping the tool name 'add_terraform_provider' to its handler function in the terraform_tool_handlers dictionary, likely used by the MCP server.
    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