Skip to main content
Glama
AgentWong

IAC Memory MCP Server

by AgentWong

get_ansible_collection_info

Retrieve comprehensive information about an Ansible collection, including its structure and components, to support Infrastructure-as-Code management and development workflows.

Instructions

Retrieve comprehensive information about an Ansible collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYesName of the Ansible collection

Implementation Reference

  • The async handler function that executes the get_ansible_collection_info tool logic, retrieving collection data from the database and formatting it into a text response.
    async def handle_get_ansible_collection_info(
        db: Any, arguments: Dict[str, Any], operation_id: str
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle get_ansible_collection_info tool."""
        try:
            logger.info(
                "Getting Ansible collection info",
                extra={
                    "collection_name": arguments["collection_name"],
                    "operation_id": operation_id,
                },
            )
    
            # Get collection info
            collection = get_ansible_collection_info(db, arguments["collection_name"])
    
            # Format output
            output = [
                f"Collection: {collection['name']}",
                f"Version: {collection['version']}",
                f"Source: {collection['source_url']}",
                f"Documentation: {collection['doc_url']}",
                f"Total Modules: {collection['module_count']}",
                f"Last Updated: {collection['updated_at']}",
            ]
    
            if collection["recent_modules"]:
                output.extend(
                    [
                        "\nRecent Modules:",
                        *[
                            f"- {m['name']} ({m['type']}) v{m['version']}"
                            for m in collection["recent_modules"]
                        ],
                    ]
                )
    
            return [TextContent(type="text", text="\n".join(output))]
    
        except Exception as e:
            error_msg = f"Failed to get collection info: {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_ansible_collection_info",
                        "operation_id": operation_id,
                    },
                )
            )
  • JSON schema defining the input parameters for the get_ansible_collection_info tool, requiring 'collection_name'.
    "get_ansible_collection_info": {
        "type": "object",
        "description": "Retrieve comprehensive information about an Ansible collection",
        "required": ["collection_name"],
        "properties": {
            "collection_name": {
                "type": "string",
                "description": "Name of the Ansible collection",
            }
        },
    },
  • Registration of the 'get_ansible_collection_info' handler in the ansible_tool_handlers dictionary used by the MCP server.
    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 SQL queries to fetch Ansible collection details including module count and recent modules.
    def get_ansible_collection_info(db: DatabaseManager, collection_name: str) -> Dict:
        """Get comprehensive information about an Ansible collection.
    
        Args:
            db: Database manager instance
            collection_name: Name of the collection to retrieve
    
        Returns:
            Dictionary containing collection information including metadata and module count
        """
        logger.info(
            "Getting Ansible collection info",
            extra={
                "collection_name": collection_name,
                "operation": "get_ansible_collection_info",
            },
        )
    
        try:
            with db.get_connection() as conn:
                conn.execute("PRAGMA busy_timeout = 5000")  # 5 second timeout
    
                # Get collection info with module count
                result = conn.execute(
                    """
                    SELECT
                        c.*,
                        COUNT(m.id) as module_count
                    FROM ansible_collections c
                    LEFT JOIN ansible_modules m ON c.id = m.collection_id
                    WHERE c.name = ?
                    GROUP BY c.id
                    """,
                    (collection_name,),
                ).fetchone()
    
                if not result:
                    raise DatabaseError(f"Collection '{collection_name}' not found")
    
                collection_info = dict(result)
    
                # Get recent modules
                recent_modules = conn.execute(
                    """
                    SELECT name, type, version
                    FROM ansible_modules
                    WHERE collection_id = ?
                    ORDER BY updated_at DESC
                    LIMIT 5
                    """,
                    (collection_info["id"],),
                ).fetchall()
    
                collection_info["recent_modules"] = [dict(m) for m in recent_modules]
    
                return collection_info
    
        except sqlite3.Error as e:
            error_msg = f"Failed to get collection info: {str(e)}"
            logger.error(error_msg)
            raise DatabaseError(error_msg)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves information, implying a read-only operation, but doesn't specify what 'comprehensive information' includes, potential rate limits, authentication needs, or error conditions. This is inadequate for a tool with no 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 is appropriately sized and front-loaded, making it easy for an agent 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 lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what 'comprehensive information' entails, how results are structured, or any behavioral traits, leaving significant gaps for the agent to operate effectively with this tool.

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 the parameter 'collection_name' documented as 'Name of the Ansible collection'. The description adds no additional semantic context beyond what the schema provides, such as format examples or constraints, so it meets the baseline of 3 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 verb ('retrieve') and resource ('comprehensive information about an Ansible collection'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_ansible_module_info' or 'list_ansible_collections', which would require a 5.

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 'get_ansible_module_info' or 'list_ansible_collections'. It lacks any context about prerequisites, exclusions, or specific use cases, leaving the agent to infer usage from the tool name alone.

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