Skip to main content
Glama
AgentWong

IAC Memory MCP Server

by AgentWong

update_resource_schema

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

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

  • MCP tool handler for update_resource_schema. Validates input JSON schema, calls the DB update function, logs operation, and returns success/error text content.
    async def handle_update_resource_schema(
        db: Any, arguments: Dict[str, Any], operation_id: str
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle update_resource_schema tool."""
        try:
            logger.info(
                "Updating resource schema",
                extra={
                    "resource_id": arguments["resource_id"],
                    "operation_id": operation_id,
                },
            )
    
            # Validate schema is valid JSON
            try:
                import json
                json.loads(arguments["new_schema"])
            except json.JSONDecodeError:
                error_msg = "Invalid schema format. Schema must be valid JSON."
                logger.error(error_msg, extra={"operation_id": operation_id})
                return [types.TextContent(type="text", text=error_msg)]
    
            # Update resource schema
            success = update_resource_schema(
                db,
                arguments["resource_id"],
                arguments["new_schema"],
                arguments.get("new_version"),
                arguments.get("new_doc_url"),
            )
    
            if success:
                return [types.TextContent(
                    type="text",
                    text=f"Successfully updated schema for resource ID: {arguments['resource_id']}"
                )]
            else:
                error_msg = f"Resource with ID {arguments['resource_id']} not found"
                logger.error(error_msg, extra={"operation_id": operation_id})
                return [types.TextContent(type="text", text=error_msg)]
    
        except Exception as e:
            error_msg = f"Failed to update resource schema: {str(e)}"
            logger.error(error_msg, extra={"operation_id": operation_id})
            return [types.TextContent(type="text", text=error_msg)]
  • Registration of the update_resource_schema tool handler in the terraform_tool_handlers dictionary.
    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,
    }
  • Core database helper function that performs the SQL UPDATE on the terraform_resources table to update schema, version, doc_url, and timestamp.
    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 definition for the update_resource_schema tool input parameters, used for validation.
    "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"},
        },
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is an update operation, implying mutation, but fails to mention potential impacts like whether this overwrites existing data, requires specific permissions, or has side effects on related resources. This leaves significant gaps for a tool that modifies schemas.

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 directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

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 complexity of updating a Terraform resource schema (a mutation operation with no annotations and no output schema), the description is insufficient. It lacks details on behavioral traits, error conditions, or what the update entails, leaving the agent with incomplete context for safe and effective use.

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 input schema has 100% description coverage, with each parameter documented (e.g., 'resource_id', 'new_schema'). The description adds no additional meaning beyond the schema's descriptions, such as explaining format expectations or interrelationships between parameters. This meets the baseline for high schema coverage.

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 the target ('an existing Terraform resource's schema and related information'), which is specific and unambiguous. 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 like 'update_entity' or 'update_provider_version', nor does it mention prerequisites such as needing an existing resource ID. It lacks context about appropriate scenarios or exclusions.

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'

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