Skip to main content
Glama

list_inventory

View Ansible inventory hosts and groups to manage infrastructure configurations and deployments.

Instructions

List Ansible inventory hosts and groups

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inventoryNo

Implementation Reference

  • The handler function that runs 'ansible-inventory --list' to list hosts and groups, formats as pretty JSON, with error handling.
    export async function listInventory(options: ListInventoryOptions): Promise<string> {
      const inventoryPath = validateInventoryPath(options.inventory);
      
      // Build command
      let command = 'ansible-inventory';
      
      // Add inventory if specified
      if (inventoryPath) {
        command += ` -i ${inventoryPath}`;
      }
      
      command += ' --list';
    
      try {
        // Execute command
        const { stdout, stderr } = await execAsync(command);
        
        try {
          // Try to parse as JSON for better formatting
          const inventory = JSON.parse(stdout);
          return JSON.stringify(inventory, null, 2);
        } catch {
          // Fall back to raw output if can't parse as JSON
          return stdout || 'No inventory data returned';
        }
      } catch (error) {
        // Handle exec error
        const execError = error as { stderr?: string; message: string };
        throw new AnsibleExecutionError(
          `Error listing inventory: ${execError.message}`,
          execError.stderr
        );
      }
    }
  • Zod schema for input validation of the list_inventory tool, accepting an optional inventory path.
    export const ListInventorySchema = z.object({
      inventory: z.string().optional(),
    });
    
    export type ListInventoryOptions = z.infer<typeof ListInventorySchema>;
  • Tool registration in the toolDefinitions object, specifying name, description, schema, and handler reference.
    list_inventory: {
      description: 'List Ansible inventory hosts and groups',
      schema: ListInventorySchema,
      handler: inventory.listInventory,
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it's a 'list' operation, implying read-only behavior, but doesn't specify whether it returns all inventory, requires authentication, has pagination, or provides error handling. This leaves significant gaps in understanding the tool's behavior.

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's appropriately front-loaded and wastes no space, making it easy 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 tool has no annotations, no output schema, and incomplete parameter documentation, the description is insufficient. It doesn't cover return values, error conditions, or practical usage details, leaving the agent with inadequate information to use the tool effectively in context.

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

Parameters2/5

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

The input schema has 1 parameter with 0% description coverage, and the description provides no information about the 'inventory' parameter. It doesn't explain what 'inventory' refers to (e.g., a file path, inventory name, or source), its format, or default behavior if omitted, failing to compensate for the schema's lack of documentation.

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 'list' and the resource 'Ansible inventory hosts and groups', making the purpose evident. It doesn't explicitly distinguish from sibling tools like 'aws_dynamic_inventory' or 'list_tasks', but the specificity of 'Ansible inventory' provides some implicit differentiation.

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 sibling tools like 'aws_dynamic_inventory' (which might list AWS-specific inventory) or 'list_tasks' (which lists tasks rather than inventory), leaving the agent without explicit usage context.

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/tarnover/mcp-sysoperator'

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