Skip to main content
Glama

Ensure Collection

ensure_collection
Idempotent

Installs an Ansible collection into a temporary session directory and pins the resolved version, skipping reinstall when that version is already present.

Instructions

Install a collection to a temporary directory for this session.

Installs once and pins the resolved version. Subsequent calls with the same namespace skip unless a different version is explicitly requested. If a different version is requested than currently installed, the collection will be reinstalled.

Returns dict with keys:

  • namespace: str — the collection namespace

  • version: str — the installed/active version (always set)

  • status: 'installed' (freshly installed or upgraded) or 'already_installed' (same version already present, no action taken)

  • message: str — human-readable summary including the active version

  • handle: str — opaque session handle; pass it as collection_handle to subsequent tool calls on remote connections On failure returns {"error": str}.

Pass collection_handle when re-invoking ensure_collection on a remote connection with a handle obtained from a prior call (e.g. to install an additional collection into the same session). Omit it on local stdio, or on remote when you want a brand-new session handle minted.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "collection_namespace": "<collection_namespace>"
    },
    "name": "ensure_collection"
  }
}

Input Schema

NameRequiredDescriptionDefault
versionNoOptional version (e.g. '4.1.0'). If omitted, installs latest and pins the resolved version.
collection_handleNoSession handle returned by ensure_collection. Omit on local stdio; required on remote.
collection_namespaceYesCollection namespace (e.g. 'netbox.netbox')

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.11.0
    • addedInput schema / properties / collection_handle
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Session handle returned by ensure_collection. Omit on local stdio; required on remote."
      +}
    • changedOutput schema / properties / result / anyOf
      Previous value: -[
      -  {
      -    "description": "Result of ensure_collection tool.",
      -    "properties": {
      -      "message": {
      -        "type": "string"
      -      },
      -      "namespace": {
      -        "type": "string"
      -      },
      -      "status": {
      -        "type": "string"
      -      },
      -      "version": {
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "namespace",
      -      "version",
      -      "status",
      -      "message"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "description": "Standard error shape returned by all tools on failure.",
      -    "properties": {
      -      "error": {
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "error"
      -    ],
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "description": "Result of ensure_collection tool.",
      +    "properties": {
      +      "handle": {
      +        "type": "string"
      +      },
      +      "message": {
      +        "type": "string"
      +      },
      +      "namespace": {
      +        "type": "string"
      +      },
      +      "status": {
      +        "type": "string"
      +      },
      +      "version": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "namespace",
      +      "version",
      +      "status",
      +      "message"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "description": "Standard error shape returned by all tools on failure.",
      +    "properties": {
      +      "error": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "error"
      +    ],
      +    "type": "object"
      +  }
      +]
  2. First observedv0.7.0

TDQS

A4.5/5.0
Behavior5/5

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

Beyond the annotations (idempotentHint, destructiveHint=false, openWorldHint), the description discloses the actual lifecycle mechanics: temp-directory install, version pinning, upgrade-on-mismatch, and no-op status 'already_installed'. It also covers the failure shape ({"error": str}) and the opaque session handle, which the annotations cannot express.

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?

Front-loaded with the core action, then a structured return-key list, then the handle rules — easy to scan. It is somewhat verbose, and the return-key enumeration partially duplicates the existing output schema, but no sentence is harmful.

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

Completeness4/5

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

For a non-idempotent-looking install tool with session handling, it covers the important pieces: idempotency, version pinning, handle propagation, and the error return. Remaining gaps are minor, such as when the temporary directory is cleaned up or whether installs require network access.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already defines all three parameters, but the description adds real semantics: what happens when version is omitted (installs latest, pins resolved version), and the remote-vs-local and new-session-minting rules for collection_handle. That goes beyond the schema's terse field descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence names a concrete verb (install), a resource (a collection), and the scope/mechanism (temporary directory, this session). That framing is clearly distinct from sibling tools like search_collections, get_collection_docs, or generate_skill, so an agent can route on the first line alone.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives strong repeat-call guidance: installs once and pins the version, subsequent calls with the same namespace skip, and a different requested version forces a reinstall. It also states explicitly when to pass collection_handle versus omit it (local stdio, or minting a fresh remote session). It does not say when this tool should be used relative to sibling tools (e.g., that install precedes get_collection_docs), which keeps it from a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.