Skip to main content
Glama
AgentWong
by AgentWong

add_ansible_module

Add new Ansible module definitions with schema and version information to persistent IaC memory storage for version tracking and relationship mapping.

Instructions

Add a new Ansible module definition with its schema and version information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection ID or name
nameYesModule name
module_typeYesModule type
schemaYesModule schema
versionYesModule version
doc_urlYesDocumentation URL

Implementation Reference

  • MCP tool handler for add_ansible_module. Validates module type against VALID_MODULE_TYPES, calls the database add_ansible_module function, returns success message with module ID or raises McpError on failure.
    async def handle_add_ansible_module(db: Any, arguments: Dict[str, Any], operation_id: str) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle add_ansible_module tool."""
        try:
            # Validate module type
            if arguments["module_type"] not in VALID_MODULE_TYPES:
                error_msg = f"Invalid module type: {arguments['module_type']}. Valid types are: {', '.join(sorted(VALID_MODULE_TYPES))}"
                logger.error(error_msg, extra={"operation_id": operation_id})
                return [TextContent(type="text", text=error_msg)]
    
            logger.info(
                "Adding Ansible module",
                extra={
                    "collection": arguments["collection"],
                    "module_name": arguments["name"],
                    "operation_id": operation_id,
                },
            )
    
            # Add module
            module_id = add_ansible_module(
                db,
                arguments["collection"],
                arguments["name"],
                arguments["module_type"],
                arguments["schema"],
                arguments["version"],
                arguments["doc_url"],
            )
    
            return [TextContent(
                type="text",
                text=f"Added module {arguments['name']} with ID: {module_id}"
            )]
    
        except Exception as e:
            error_msg = f"Failed to add module: {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_module",
                        "operation_id": operation_id,
                    },
                )
            )
  • JSON schema definition for the add_ansible_module tool input parameters, including required fields and descriptions.
    "add_ansible_module": {
        "type": "object",
        "description": "Add a new Ansible module definition with its schema and version information",
        "required": [
            "collection",
            "name",
            "module_type",
            "schema",
            "version",
            "doc_url",
        ],
        "properties": {
            "collection": {"type": "string", "description": "Collection ID or name"},
            "name": {"type": "string", "description": "Module name"},
            "module_type": {"type": "string", "description": "Module type"},
            "schema": {"type": "string", "description": "Module schema"},
            "version": {"type": "string", "description": "Module version"},
            "doc_url": {"type": "string", "description": "Documentation URL"},
        },
    },
  • Registration of the add_ansible_module handler in the ansible_tool_handlers dictionary used for tool dispatching.
    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,
    }
  • Core helper function that performs the database insertion of a new Ansible module after looking up the collection ID, handles transactions, and returns the new module ID.
    def add_ansible_module(
        db: DatabaseManager,
        collection_id: str,
        name: str,
        module_type: str,
        schema: str,
        version: str,
        doc_url: str,
    ) -> str:
        """Add a new Ansible module."""
        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:
                    # Look up collection by ID or name
                    collection = conn.execute(
                        """SELECT id FROM ansible_collections
                        WHERE id = ? OR name = ?""",
                        (collection_id, collection_id),
                    ).fetchone()
    
                    if not collection:
                        raise DatabaseError(
                            f"Collection '{collection_id}' not found. "
                            f"Operation timed out after 5 seconds."
                        )
    
                    collection_id = collection["id"]  # Ensure we have the numeric ID
    
                    cursor = conn.execute(
                        """INSERT INTO ansible_modules
                        (collection_id, name, type, schema, description, version, doc_url)
                        VALUES (?, ?, ?, ?, ?, ?, ?)""",
                        (
                            collection_id,
                            name,
                            module_type,
                            schema,
                            module_type,  # Using type as description for now
                            version,
                            doc_url,
                        ),
                    )
                    module_id = str(cursor.lastrowid)
                    conn.commit()
                    return module_id
                except Exception:
                    conn.rollback()
                    raise
        except sqlite3.Error as e:
            raise DatabaseError(
                f"Failed to add Ansible module: {str(e)}. "
                f"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 module definition but doesn't cover critical aspects like whether this is a write operation, what permissions are required, how conflicts are handled (e.g., if the module already exists), or what the response looks like. This is a significant gap 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 is front-loaded and wastes no space, 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 complexity of adding a module (a write operation with 6 required parameters), no annotations, and no output schema, the description is insufficient. It lacks details on behavior, error handling, or return values, leaving the agent with incomplete context for proper tool invocation.

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 6 parameters clearly documented in the input schema. The description mentions 'schema and version information' but doesn't add meaningful details beyond what the schema provides, such as explaining the relationships between parameters or their expected formats. This meets the baseline 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 action ('Add') and resource ('new Ansible module definition with its schema and version information'), making the purpose evident. However, it doesn't explicitly differentiate this tool from sibling tools like 'add_ansible_collection' or 'create_entity', which would be needed for a score of 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. It doesn't mention prerequisites, context (e.g., when adding modules is appropriate), or comparisons to siblings like 'add_ansible_collection' or 'create_entity', leaving the agent without usage direction.

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