Skip to main content
Glama
tarnover
by tarnover

list_inventory

Retrieve and display Ansible inventory hosts and groups using the specified inventory file for efficient server management.

Instructions

List Ansible inventory hosts and groups

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inventoryNo

Implementation Reference

  • The handler function that runs 'ansible-inventory --list' on the specified inventory path, parses the JSON output if possible, and returns formatted inventory data or raw output. Handles validation and errors.
    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 list_inventory tool input: optional 'inventory' path string. Includes TypeScript type inference.
    export const ListInventorySchema = z.object({
      inventory: z.string().optional(),
    });
    
    export type ListInventoryOptions = z.infer<typeof ListInventorySchema>;
  • Tool registration in toolDefinitions map, specifying name 'list_inventory', 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. While 'List' implies a read-only operation, the description doesn't specify whether this requires specific permissions, what format the output takes (structured data vs plain text), whether it supports pagination, or how it handles errors. For a tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 extremely concise at just 6 words, front-loading the essential information with zero wasted words. Every word earns its place by specifying the action ('List'), domain ('Ansible inventory'), and targets ('hosts and groups').

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 lack of annotations, 0% schema description coverage, no output schema, and the presence of potentially overlapping sibling tools, the description is insufficiently complete. It doesn't explain the tool's relationship to other inventory-related tools, provide parameter guidance, or describe what the output looks like, leaving too many contextual gaps for effective tool selection and invocation.

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 schema has 0% description coverage for its single parameter 'inventory', and the tool description provides no information about what this parameter represents, what values it accepts, or whether it's required. With low schema coverage and no parameter explanation in the description, users must guess what 'inventory' means in this context.

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 resource ('Ansible inventory hosts and groups'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential sibling inventory tools like 'aws_dynamic_inventory' or explain what distinguishes 'list_inventory' from other listing operations in the Ansible context.

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 sibling tools like 'aws_dynamic_inventory' and 'aws_ec2' that might also provide inventory-related functionality, there's no indication of when this specific Ansible inventory tool is appropriate versus AWS-specific inventory tools or other operations like 'list_tasks'.

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

Related 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-ansible'

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