Skip to main content
Glama

Playbook structure

ansible_playbook_structure
Read-onlyIdempotent

Parse an Ansible playbook to list plays, hosts, tasks, tags, and parse-time deprecation warnings without executing any plays.

Instructions

Plays, matched hosts, tasks (with module and file:line where unambiguous) and tags of a playbook (ansible-playbook --syntax-check, then --list-hosts --list-tasks --list-tags), plus deprecation warnings Ansible printed while parsing; never runs a play. Parses playbooks with Ansible: treat dir as code you would run --syntax-check on (play-level Jinja and playbook-adjacent vars plugins are evaluated); lookups in play-level fields are refused unless ANSIBLE_MCP_ALLOW_PLAY_LOOKUPS=1.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dirNoAnsible project directory. Default: ANSIBLE_MCP_DIR, else the server's working directory.
tagsNoOnly these tags (--tags)
limitNoHost pattern (--limit)
playbookYesPlaybook path relative to dir
inventoryNoInventory source relative to dir
max_tasksNoMax tasks listed (default 300)
skip_tagsNoSkip these tags (--skip-tags)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.2

TDQS

A4.4/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), yet the description adds substantial behavioral context beyond them: the exact underlying ansible-playbook invocations, the guarantee that no play executes, the fact that play-level Jinja and adjacent vars plugins ARE evaluated during parsing, and that lookups in play-level fields are refused unless ANSIBLE_MCP_ALLOW_PLAY_LOOKUPS=1. The execution-side-effect disclosure is exactly what an agent needs.

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?

Two sentences, front-loaded with the return shape before the parsing semantics. The second sentence is dense with nested parentheticals and the env-var caveat, which makes it slightly harder to skim, but no clause is filler.

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

Completeness5/5

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

There is no output schema, so the description carries the burden of describing the return value, and it does so explicitly (plays, hosts, tasks with file:line, tags, deprecation warnings) while also disclosing the parsing model and the lookup restriction. An agent has everything needed to call this correctly.

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?

Schema description coverage is 100% and each of the 7 parameters carries its own CLI-flag mapping (--tags, --limit, --syntax-check, etc.), so the schema already does the heavy lifting. The description adds no per-parameter syntax or constraint detail, making the baseline 3 appropriate.

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?

States a specific resource and enumerates exactly what it returns: plays, matched hosts, tasks with module and file:line, tags, and parsing deprecation warnings. This is clearly distinct from siblings like ansible_lint_summary or ansible_inventory, which cover different artifacts.

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?

Gives strong context: it is a static analysis tool ('never runs a play') and explicitly frames the playbook as code you would run --syntax-check on. It does not, however, name an alternative sibling or state when to prefer e.g. ansible_lint_summary over this, so the routing guidance is contextual rather than explicit.

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