Skip to main content
Glama
AgentWong

IAC Memory MCP Server

by AgentWong

add_ansible_collection

Store Ansible collection metadata including version, source repository, and documentation links in the IaC memory cache for reference and management.

Instructions

Add a new Ansible collection to the memory store with version and documentation information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCollection name
versionYesCollection version
source_urlYesSource repository URL
doc_urlYesDocumentation URL

Implementation Reference

  • MCP tool handler function that validates input arguments, calls the database function to add the Ansible collection, logs the operation, and returns a success message with the collection ID or an error.
    async def handle_add_ansible_collection(db: Any, arguments: Dict[str, Any], operation_id: str) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle add_ansible_collection tool."""
        # Validate required arguments
        required_args = ["name", "version", "source_url", "doc_url"]
        missing_args = [arg for arg in required_args if arg not in arguments]
        if missing_args:
            error_msg = f"Missing required arguments for add_ansible_collection: {', '.join(missing_args)}"
            logger.error(error_msg, extra={"operation_id": operation_id})
            return [TextContent(type="text", text=error_msg)]
    
        try:
            logger.info(
                "Adding Ansible collection",
                extra={
                    "collection_name": arguments["name"],
                    "version": arguments["version"],
                    "operation_id": operation_id,
                },
            )
    
            # Add collection
            collection_id = add_ansible_collection(
                db,
                arguments["name"],
                arguments["version"],
                arguments["source_url"],
                arguments["doc_url"],
            )
    
            return [TextContent(
                type="text",
                text=f"Added collection {arguments['name']} with ID: {collection_id}"
            )]
    
        except Exception as e:
            error_msg = f"Failed to add collection: {str(e)}"
            logger.error(error_msg, extra={"operation_id": operation_id})
            raise McpError(
                types.ErrorData(
                    code=types.INTERNAL_ERROR,
                    message=error_msg,
                    data={
                        "tool": "add_ansible_collection",
                        "operation_id": operation_id,
                    },
                )
            )
  • JSON schema definition for the add_ansible_collection tool, specifying required parameters (name, version, source_url, doc_url) and their descriptions.
    "add_ansible_collection": {
        "type": "object",
        "description": "Add a new Ansible collection to the memory store with version and documentation information",
        "required": ["name", "version", "source_url", "doc_url"],
        "properties": {
            "name": {"type": "string", "description": "Collection name"},
            "version": {"type": "string", "description": "Collection version"},
            "source_url": {"type": "string", "description": "Source repository URL"},
            "doc_url": {"type": "string", "description": "Documentation URL"},
        },
    },
  • Registration of the add_ansible_collection tool handler in the ansible_tool_handlers dictionary, mapping the 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,
        "update_collection_version": handle_update_collection_version,
        "update_module_version": handle_update_module_version,
    }
  • Database helper function that performs the SQL INSERT into ansible_collections table to add the new collection and returns the generated ID.
    def add_ansible_collection(
        db: DatabaseManager, name: str, version: str, source_url: str, doc_url: str
    ) -> str:
        """Add a new Ansible collection."""
        try:
            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(
                        """INSERT INTO ansible_collections
                        (name, version, source_url, doc_url)
                        VALUES (?, ?, ?, ?)""",
                        (name, version, source_url, doc_url),
                    )
                    collection_id = str(cursor.lastrowid)
                    conn.commit()
                    return collection_id
                except Exception:
                    conn.rollback()
                    raise
        except sqlite3.Error as e:
            raise DatabaseError(
                f"Failed to add Ansible collection: {str(e)}. Operation timed out after 5 seconds."
            )
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 adds a collection 'to the memory store' but doesn't explain what this entails—e.g., whether it's a persistent write, requires specific permissions, has side effects like indexing, or handles duplicates. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 front-loads the core action and purpose without unnecessary words. Every part earns its place by specifying the resource type and key attributes, making it highly concise and well-structured for quick understanding.

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 tool's complexity as a mutation operation with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits, error handling, or what the tool returns, leaving gaps in understanding how to use it effectively in context with sibling tools.

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%, with all parameters documented in the schema. The description adds no additional meaning beyond the schema, such as format examples or constraints. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't detract either.

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 ('Add a new Ansible collection') and the target ('to the memory store'), specifying what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'add_ansible_module' or 'add_terraform_provider', which follow similar patterns but for different resource types. The purpose is clear but lacks sibling distinction.

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. It doesn't mention prerequisites, such as whether the collection must be pre-existing or validated, or contrast with tools like 'update_collection_version' or 'get_ansible_collection_info'. Without such context, users must 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