Skip to main content
Glama
AgentWong

IAC Memory MCP Server

by AgentWong

update_module_version

Update an existing Ansible module's schema, version, and documentation URL in the Infrastructure-as-Code memory cache.

Instructions

Update an existing Ansible module's schema and related information

Input Schema

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

Implementation Reference

  • MCP tool handler that validates arguments, calls the database update function, logs the operation, and returns success/error messages.
    async def handle_update_module_version(
        db: Any, arguments: Dict[str, Any], operation_id: str
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle update_module_version tool."""
        try:
            logger.info(
                "Updating module version",
                extra={
                    "module_id": arguments["module_id"],
                    "new_schema": "...",  # Truncated for log
                    "operation_id": operation_id,
                },
            )
    
            # Update module version
            result = update_module_version(
                db,
                arguments["module_id"],
                arguments["new_schema"],
                arguments.get("new_version"),
                arguments.get("new_doc_url"),
            )
    
            return [TextContent(
                type="text",
                text=f"Updated module version: {result}"
            )]
    
        except Exception as e:
            error_msg = f"Failed to update module version: {str(e)}"
            logger.error(error_msg, extra={"operation_id": operation_id})
            raise McpError(
                types.ErrorData(
                    code=types.INTERNAL_ERROR,
                    message=error_msg,
                    data={
                        "tool": "update_module_version",
                        "operation_id": operation_id,
                    },
                )
            )
  • JSON schema defining the input parameters for the update_module_version tool, including required fields like module_id and new_schema.
    "update_module_version": {
        "type": "object",
        "description": "Update an existing Ansible module's schema and related information",
        "required": ["module_id", "new_schema"],
        "properties": {
            "module_id": {"type": "string", "description": "Module ID"},
            "new_schema": {"type": "string", "description": "New schema"},
            "new_version": {"type": "string", "description": "New version"},
            "new_doc_url": {"type": "string", "description": "New documentation URL"},
        },
    },
  • Dictionary mapping tool names to their handler functions, registering update_module_version with its handler.
    ansible_tool_handlers = {
        "get_ansible_collection_info": handle_get_ansible_collection_info,
        "list_ansible_collections": handle_list_ansible_collections,
        "get_collection_version_history": handle_get_collection_version_history,
        "get_ansible_module_info": handle_get_ansible_module_info,
        "list_collection_modules": handle_list_collection_modules,
        "get_module_version_compatibility": handle_get_module_version_compatibility,
        "add_ansible_collection": handle_add_ansible_collection,
        "add_ansible_module": handle_add_ansible_module,
        "update_collection_version": handle_update_collection_version,
        "update_module_version": handle_update_module_version,
    }
  • Database helper function that performs the SQL UPDATE on the ansible_modules table to update schema, version, doc_url, and timestamp.
    def update_module_version(
        db: DatabaseManager,
        module_id: str,
        new_schema: str,
        new_version: Optional[str] = None,
        new_doc_url: Optional[str] = None,
    ) -> bool:
        """Update an Ansible module's schema and optional fields."""
        try:
            with db.get_connection() as conn:
                conn.execute("BEGIN IMMEDIATE")  # Start transaction
                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(module_id)
    
                    cursor = conn.execute(
                        f"""UPDATE ansible_modules
                        SET {', '.join(updates)}
                        WHERE id = ?""",
                        tuple(params),
                    )
                    conn.commit()
                    return cursor.rowcount > 0
                except Exception:
                    conn.rollback()
                    raise
        except sqlite3.Error as e:
            raise DatabaseError(f"Failed to update module version: {str(e)}")

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
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 mentions updating schema and related information but doesn't specify whether this is a destructive operation, what happens to existing data, or if there are rate limits or authentication requirements. 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 that directly states the tool's purpose without unnecessary words. It's front-loaded and earns its place by clearly conveying the core action, making it highly concise and well-structured.

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 module (a mutation operation) with no annotations and no output schema, the description is incomplete. It doesn't address behavioral aspects like side effects, error handling, or return values, leaving significant gaps for an AI agent to understand the tool's full context.

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 input schema already documents all parameters. The description doesn't add any additional meaning beyond what the schema provides, such as explaining the format of 'new_schema' or how 'new_version' interacts with existing versions. Baseline 3 is appropriate when the schema handles parameter documentation.

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 resource ('existing Ansible module's schema and related information'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'update_entity' or 'update_collection_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?

No guidance is provided on when to use this tool versus alternatives like 'update_entity' or 'update_collection_version'. The description lacks context about prerequisites, such as whether the module must exist or if specific permissions are needed, leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.