Skip to main content
Glama
AgentWong

IAC Memory MCP Server

by AgentWong

update_collection_version

Modify version details and documentation links for Ansible collections stored in the Infrastructure-as-Code cache to maintain accurate IaC information.

Instructions

Update an existing Ansible collection's version information and documentation links

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_idYesCollection ID
new_versionYesNew version
new_source_urlNoNew source URL
new_doc_urlNoNew documentation URL

Implementation Reference

  • MCP tool handler function that processes arguments, calls the database update function, handles errors, and returns success message.
    async def handle_update_collection_version(
        db: Any, arguments: Dict[str, Any], operation_id: str
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle update_collection_version tool."""
        try:
            logger.info(
                "Updating collection version",
                extra={
                    "collection_id": arguments["collection_id"],
                    "new_version": arguments["new_version"],
                    "operation_id": operation_id,
                },
            )
    
            # Update collection version
            result = update_collection_version(
                db,
                arguments["collection_id"],
                arguments["new_version"],
                arguments.get("new_source_url"),
                arguments.get("new_doc_url"),
            )
    
            return [TextContent(
                type="text",
                text=f"Updated collection version: {result}"
            )]
    
        except Exception as e:
            error_msg = f"Failed to update collection 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_collection_version",
                        "operation_id": operation_id,
                    },
                )
            )
  • JSON schema defining input parameters for the update_collection_version tool, including required fields and descriptions.
    "update_collection_version": {
        "type": "object",
        "description": "Update an existing Ansible collection's version information and documentation links",
        "required": ["collection_id", "new_version"],
        "properties": {
            "collection_id": {"type": "string", "description": "Collection ID"},
            "new_version": {"type": "string", "description": "New version"},
            "new_source_url": {"type": "string", "description": "New source URL"},
            "new_doc_url": {"type": "string", "description": "New documentation URL"},
        },
    },
  • Dictionary mapping tool names to their handler functions, registering update_collection_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,
    }
  • Core database function that performs the SQL UPDATE on ansible_collections table to update version and optional URLs, with transaction handling and error management.
    def update_collection_version(
        db: DatabaseManager,
        collection_id: str,
        new_version: str,
        new_source_url: Optional[str] = None,
        new_doc_url: Optional[str] = None,
    ) -> bool:
        """Update an Ansible collection's version and optional URLs."""
        try:
            updates = ["version = ?"]
            params = [new_version]
    
            if new_source_url:
                updates.append("source_url = ?")
                params.append(new_source_url)
            if new_doc_url:
                updates.append("doc_url = ?")
                params.append(new_doc_url)
    
            updates.append("updated_at = CURRENT_TIMESTAMP")
            params.append(collection_id)
    
            with db.get_connection() as conn:
                # Set busy timeout before any operations
                conn.execute(
                    "PRAGMA busy_timeout = 5000"
                )  # 5 second timeout per testing rules
                conn.execute("BEGIN IMMEDIATE")  # Start transaction
                try:
                    cursor = conn.execute(
                        f"""UPDATE ansible_collections
                        SET {', '.join(updates)}
                        WHERE id = ?""",
                        tuple(params),
                    )
                    success = cursor.rowcount > 0
                    conn.commit()
                    return success
                except Exception:
                    conn.rollback()
                    raise
        except sqlite3.Error as e:
            raise DatabaseError(
                f"Failed to update collection version: {str(e)}. "
                f"Operation timed out after 5 seconds."
            )
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 but doesn't clarify whether it requires specific permissions, if changes are reversible, what happens to existing data not mentioned, or any 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 that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, 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?

For a mutation tool with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits, error handling, return values, and differentiation from siblings. Given the complexity of updating version information, more context is needed for the agent to use this tool effectively.

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 schema description coverage is 100%, so the schema already documents all four parameters. The description adds no additional meaning beyond what the schema provides, such as format examples or constraints. This meets the baseline for high schema coverage but doesn't enhance parameter understanding.

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 ('Ansible collection's version information and documentation links'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'update_entity' or 'update_module_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_module_version'. It doesn't mention prerequisites, exclusions, or specific scenarios where this tool is preferred, leaving the agent without contextual usage cues.

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