Skip to main content
Glama
AgentWong
by AgentWong

get_ansible_collection_info

Retrieve comprehensive information about Ansible collections, including details and metadata, to support Infrastructure-as-Code management and analysis.

Instructions

Retrieve comprehensive information about an Ansible collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYesName of the Ansible collection

Implementation Reference

  • The MCP tool handler function that processes the get_ansible_collection_info request, retrieves data using the helper function, formats the output, and handles errors.
    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 tool handler in the ansible_tool_handlers dictionary mapping tool name to its handler function.
    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,
    }
  • Database helper function that queries the database for Ansible collection information, 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?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'retrieve' implies a read operation, it doesn't specify what 'comprehensive information' includes, whether there are rate limits, authentication requirements, or error conditions. This leaves significant behavioral aspects undocumented.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point without unnecessary words. While perfectly concise, it could be slightly improved with front-loaded key information about what makes this 'comprehensive' versus other retrieval tools.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read tool with no annotations and no output schema, the description is minimally adequate. It states what the tool does but leaves important context gaps about what 'comprehensive information' means and how this differs from sibling tools, making it incomplete for optimal agent understanding.

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 schema already documents the single 'collection_name' parameter adequately. The description adds no additional parameter semantics beyond what's in the schema, maintaining the baseline score for high schema coverage situations.

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 ('Retrieve comprehensive information') and resource ('about an Ansible collection'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_ansible_module_info' or 'list_ansible_collections' beyond the resource type, which prevents a perfect score.

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. With siblings like 'list_ansible_collections' (for listing) and 'get_ansible_module_info' (for module-specific details), there's no indication of when this comprehensive collection info tool is preferred over those options.

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-project'

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