Skip to main content
Glama
AgentWong

IAC Memory MCP Server

by AgentWong

get_collection_version_history

Retrieve version history for an Ansible collection to track changes and manage infrastructure-as-code updates.

Instructions

Retrieve version history for a specific Ansible collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYesName of the Ansible collection

Implementation Reference

  • Handler function that executes the get_collection_version_history tool logic. Logs the request, fetches version history from DB, formats as text output, handles errors.
    async def handle_get_collection_version_history(
        db: Any, arguments: Dict[str, Any], operation_id: str
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle get_collection_version_history tool."""
        try:
            logger.info(
                "Getting collection version history",
                extra={
                    "collection_name": arguments["collection_name"],
                    "operation_id": operation_id,
                },
            )
    
            # Get version history
            versions = get_collection_version_history(db, arguments["collection_name"])
    
            # Format output
            output = [f"Version History for {arguments['collection_name']}:"]
            for v in versions:
                output.append(
                    f"\nVersion: {v['version']}"
                    f"\n  Added: {v['created_at']}"
                    f"\n  Last Updated: {v['updated_at']}"
                    f"\n  Source: {v['source_url']}"
                    f"\n  Docs: {v['doc_url']}"
                )
    
            return [TextContent(type="text", text="\n".join(output))]
    
        except Exception as e:
            error_msg = f"Failed to get collection version history: {str(e)}"
            logger.error(error_msg, extra={"operation_id": operation_id})
            raise McpError(
                types.ErrorData(
                    code=types.INTERNAL_ERROR,
                    message=error_msg,
                    data={
                        "tool": "get_collection_version_history",
                        "operation_id": operation_id,
                    },
                )
            )
  • JSON schema definition for the get_collection_version_history tool input parameters.
    "get_collection_version_history": {
        "type": "object",
        "description": "Retrieve version history for a specific Ansible collection",
        "required": ["collection_name"],
        "properties": {
            "collection_name": {
                "type": "string",
                "description": "Name of the Ansible collection",
            }
        },
    },
  • Registration of the tool handler in the ansible_tool_handlers dictionary.
    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 queries the version history for a given Ansible collection from the database.
    def get_collection_version_history(
        db: DatabaseManager, collection_name: str
    ) -> List[Dict]:
        """Get version history for a specific Ansible collection.
    
        Args:
            db: Database manager instance
            collection_name: Name of the collection
    
        Returns:
            List of version entries with timestamps and URLs
        """
        logger.info(
            "Getting collection version history",
            extra={
                "collection_name": collection_name,
                "operation": "get_collection_version_history",
            },
        )
    
        try:
            with db.get_connection() as conn:
                conn.execute("PRAGMA busy_timeout = 5000")  # 5 second timeout
    
                versions = conn.execute(
                    """
                    SELECT version, source_url, doc_url, created_at, updated_at
                    FROM ansible_collections
                    WHERE name = ?
                    ORDER BY created_at DESC
                    """,
                    (collection_name,),
                ).fetchall()
    
                if not versions:
                    raise DatabaseError(f"Collection '{collection_name}' not found")
    
                return [dict(v) for v in versions]
    
        except sqlite3.Error as e:
            error_msg = f"Failed to get collection version history: {str(e)}"
            logger.error(error_msg)
            raise DatabaseError(error_msg)

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