Skip to main content
Glama
AgentWong
by AgentWong

update_resource_schema

Modify Terraform resource schemas and related metadata to maintain accurate Infrastructure-as-Code documentation and version tracking.

Instructions

Update an existing Terraform resource's schema and related information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resource_idYesResource ID
new_schemaYesNew schema
new_versionNoNew version
new_doc_urlNoNew documentation URL

Implementation Reference

  • The core handler function that updates the schema of a Terraform resource in the database. This implements the main logic for the 'update_resource_schema' tool.
    def update_resource_schema(
        db: DatabaseManager,
        resource_id: str,
        new_schema: str,
        new_version: Optional[str] = None,
        new_doc_url: Optional[str] = None,
    ) -> bool:
        """Update a Terraform resource's schema and optional fields."""
        logger.info(
            "Updating resource schema",
            extra={
                "resource_id": resource_id,
                "has_new_version": bool(new_version),
                "has_new_doc_url": bool(new_doc_url),
                "operation": "update_resource_schema",
            },
        )
        try:
            updates = ["schema = ?"]
            params = [new_schema]
    
            if new_version:
                updates.append("version = ?")
                params.append(new_version)
            if new_doc_url:
                updates.append("doc_url = ?")
                params.append(new_doc_url)
    
            updates.append("updated_at = CURRENT_TIMESTAMP")
            params.append(resource_id)
    
            with db.get_connection() as conn:
                cursor = conn.execute(
                    f"""UPDATE terraform_resources
                    SET {', '.join(updates)}
                    WHERE id = ?""",
                    tuple(params),
                )
                return cursor.rowcount > 0
        except sqlite3.Error as e:
            error_msg = f"Failed to update resource schema: {str(e)}"
            logger.error(error_msg)
            raise DatabaseError(error_msg)
  • JSON schema defining the input parameters and validation for the update_resource_schema tool.
    "update_resource_schema": {
        "type": "object",
        "description": "Update an existing Terraform resource's schema and related information",
        "required": ["resource_id", "new_schema"],
        "properties": {
            "resource_id": {"type": "string", "description": "Resource ID"},
            "new_schema": {"type": "string", "description": "New schema"},
            "new_version": {"type": "string", "description": "New version"},
            "new_doc_url": {"type": "string", "description": "New documentation URL"},
        },
    },
  • Import and export of the update_resource_schema function in the db package __init__.py, making it available for use in tool handlers.
        add_terraform_provider,
        add_terraform_resource,
        get_provider_resources,
        get_resource_info,
        update_provider_version,
        update_resource_schema,
    )
  • Supporting method in DatabaseManager class that duplicates the resource schema update logic.
    def update_resource_schema(
        self,
        resource_id: str,
        new_schema: str,
        new_version: str | None = None,
        new_doc_url: str | None = None,
    ) -> bool:
        """Update a resource's schema."""
        try:
            with self.get_connection() as conn:
                conn.execute("BEGIN IMMEDIATE")
                try:
                    # Build update query dynamically
                    updates = ["schema = ?"]
                    params = [new_schema]
    
                    if new_version:
                        updates.append("version = ?")
                        params.append(new_version)
                    if new_doc_url:
                        updates.append("doc_url = ?")
                        params.append(new_doc_url)
    
                    updates.append("updated_at = CURRENT_TIMESTAMP")
                    params.append(resource_id)  # Add resource_id last
    
                    query = f"""UPDATE terraform_resources 
                              SET {', '.join(updates)}
                              WHERE id = ?"""
    
                    cursor = conn.execute(query, tuple(params))
                    conn.commit()
                    return cursor.rowcount > 0
                except Exception:
                    conn.rollback()
                    raise
        except sqlite3.Error as e:
            raise DatabaseError(f"Failed to update resource schema: {str(e)}")
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a mutation ('Update') but doesn't disclose critical traits like required permissions, whether changes are reversible, potential side effects, or rate limits. This is inadequate for a mutation tool with zero annotation coverage.

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 with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., permissions, side effects), usage context, and doesn't compensate for the absence of structured safety or output information.

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?

Schema description coverage is 100%, so the schema already documents all four parameters. The description adds no additional meaning beyond what the schema provides (e.g., no examples, format details, or constraints). Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Update') and target ('an existing Terraform resource's schema and related information'), providing specific verb+resource. However, it doesn't explicitly differentiate from sibling tools like 'update_entity' or 'update_provider_version', which could handle similar updates in different contexts.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing resource), exclusions, or compare it to siblings like 'update_entity' or 'update_provider_version' that might handle related updates.

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

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