ansible-mcp
Summary: This read-only Ansible MCP server inspects the local checkout and installed collections so agents can verify what is actually true before writing tasks, roles, inventories, or upgrade plans.
Get an Ansible project overview: core version, config file, collection/role paths, binaries, playbooks, inventories, roles, and requirements files.
Look up exact installed module/plugin options, defaults, required fields, choices, aliases, suboptions, returns, and examples.
Search installed modules/plugins by name, description, or collection.
Check task YAML or task files against installed module docs for unknown, missing, mistyped, deprecated, or invalid arguments, including YAML 1.1 traps.
Inspect role interfaces: argument specs, defaults, dependencies, vars, and galaxy metadata, with redaction.
Inspect inventory groups, hosts, and vars with secrets redacted; dynamic inventory is disabled by default.
Parse playbook structure via syntax-check/list modes: plays, hosts, tasks, modules, file:line, tags, and deprecation warnings.
Show effective Ansible config and origins, with galaxy credentials redacted and safety overrides flagged.
Compare requirements.yml against installed collections/roles and detect missing, violating, or shadowed collections.
Summarize offline ansible-lint results by rule, severity, and location without fixing anything.
Assess collection upgrade impact for an exact target version, including breaking option/module changes tied to project file:line and requirements constraints.
Stay read-only by design: never runs plays or modules, never connects to managed hosts, never supplies vault secrets, and only the upgrade-impact tool may access the network.
Provides read-only tools for inspecting an Ansible checkout on a control node: installed module option specs, task-argument checks, role interfaces, inventory and play structure, effective configuration, dependency drift, and collection upgrade impact. It uses ansible-doc, ansible-config, ansible-inventory, ansible-playbook syntax checks, and ansible-lint to validate and analyze Ansible projects without running plays or connecting to managed hosts.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ansible-mcp check my tasks/main.yml for invalid module args"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@yawlabs/ansible-mcp
One click adds this to your local Yaw MCP config so it's available in every Yaw Terminal session. Tested with Yaw MCP 1.1.13 or newer. Or install manually below.
What is actually true in THIS Ansible checkout on THIS control node: the exact option specs of the modules you have INSTALLED (so coding agents stop writing options that do not exist in your collection version), task-argument checks, role interfaces, inventory structure and vars (redacted), play structure, effective config, requirements drift, and what a collection upgrade would break in your tasks. It is read-only: it never runs a play, never runs --check, never connects to a managed host and never supplies a vault secret. It complements Red Hat's servers rather than replacing them: AAP MCP answers what is true in the controller, ADT MCP takes actions (lint --fix, navigator runs, scaffolding, EE builds). Run them together.
Built and maintained by Yaw Labs.
Why this one?
Your checkout has community.general 9.5.2; the model's training data has whatever version it saw most. Agents then write git_config: list_all: true (removed in 11.0.0), forget name (required since 12.0.0), or set state: present on rhsm_repository (no longer accepted). The VS Code language server knows the exact specs, but only a person in the editor sees them. This server lets the agent check before it writes, against what is installed.
Installed, not latest -- the source of truth is
ansible-doc --jsonrun against your collections paths, with redirects (ufw->community.general.ufw) and tombstones resolved.Checks what lint skips --
ansible-lint'sargsrule skips modules with action plugins (copy,template);ansible_check_task_argscatches their unknown options and bad values, and says plainly which cross-option rules ansible-doc cannot express.YAML 1.1 aware -- Ansible parses YAML 1.1, so unquoted
offisfalseand0755is the integer 493. The server reads YAML the same way and says when that is probably a bug.Read-only by construction -- configured vault password scripts never run (a server-owned dummy password file replaces them), script and plugin inventory sources are off by default, and play-level lookups are refused before Ansible parses a playbook (as is any playbook or lint target the pre-scan cannot fully read).
Collection upgrade impact -- downloads only the target version into its own cache and diffs the arg specs of the modules your tasks actually use, tied to file:line.
macOS, Linux, and Windows through WSL -- Ansible has no Windows control node; on Windows the server spawns it through
wsl.exe --exec(no shell anywhere).
Related MCP server: MCP DevOps Toolbox
Tools
Tool | What it does |
| ansible-core version, effective config file, collections and roles paths, installed |
| Every option of one module or plugin as installed: type, required, default, choices, aliases, suboptions, deprecations, |
| Find installed modules/plugins by name or description, ranked exact, prefix, token, then description. |
| Check inline task YAML or a tasks file / playbook against the installed docs: unknown options, missing required ones (aliases count), bad choices and types, suboptions, |
| A role's argument_specs entry points and options, defaults (redacted, |
| Groups, hosts, and inventory-level vars (names or values), always redacted. Whole-file vaults degrade to a per-file view instead of failing. |
|
|
| Effective config with origins (ansible.cfg, env, default); galaxy credentials always redacted; settings the server overrides for safety are flagged. |
| requirements.yml vs installed: ok / VIOLATES / MISSING with file:line, galaxy constraint semantics, and shadowed copies across collections paths. |
|
|
| What breaks in this project's tasks if a collection moves to an exact version: removed/moved modules (runtime.yml redirects and tombstones), removed options and aliases, newly required options, dropped choices, type and default changes, requirements constraints, |
Every tool takes an optional dir (the project). Tool names carry an ansible_ prefix and never reuse ADT MCP's names (ansible_lint, ansible_navigator, ...), so both can sit behind one aggregator.
Division of authority
Question | Authority |
Controller jobs, job templates, controller inventories, RBAC | AAP MCP |
Scaffold content, | ADT MCP |
Interactive editing for a person | VS Code Ansible extension (language server) |
Generate new content from intent | Ansible Lightspeed |
Execute modules against hosts | not this server |
Installed specs, task-argument validity, role interfaces, local inventory, play structure, effective config, dependency drift, collection upgrade impact | ansible-mcp (read-only) |
What is read-only, and what touches the network
Never run: plays, modules,
--check,--diff, fact gathering. The only Ansible commands areansible --version,ansible-config dump,ansible-doc,ansible-inventory --list/--host/--graph,ansible-playbook --syntax-check/--list-*,ansible-galaxy collection list/role list,ansible-lint --offline, and (only inansible_upgrade_impact)ansible-galaxy collection install --no-deps -p <server cache>.Never written: your project, your collections and roles paths, requirements files, and anything inside an existing
~/.ansible. Ansible's local temp, galaxy cache and (when you have none) galaxy token file are redirected to the server's cache. The one residue: Ansible creates an empty~/.ansiblewhen it does not exist, and ansible-lint creates empty~/.ansible/roles/~/.ansible/collectionswhen they are missing.Vault: no secret is ever supplied, and a
vault_password_file/vault_identity_listscript named in ansible.cfg never runs (it is replaced by a server-owned file holding a random password). Inline!vaultvalues print as<vaulted>; whole-file vaults are listed, not read.Dynamic inventory (script, constructed, cloud plugins) runs code and calls APIs, so it is off unless
ANSIBLE_MCP_ALLOW_DYNAMIC_INVENTORY=1; skipped sources are named in the answer.Residual risk, stated:
ansible-playbook --syntax-check(and ansible-lint, which runs it) evaluates Jinja in play-levelname,hostsandvars_filesand imports playbook-adjacentvars_plugins/. Treatdiras code you would run--syntax-checkon. Lookups in those fields are refused before Ansible sees them unlessANSIBLE_MCP_ALLOW_PLAY_LOOKUPS=1, and local plugin files are listed in the answer.Redaction (
ansible_inventory,ansible_role_interface,ansible_config, lint messages): vault markers, plus any string equal to a hidden one, plus values under secret-like names (ansible_become_password,api_token,vault_db_password, ... but notvault_addrorprivate_key_file), plus secret-shaped strings (private keys, JWTs, GitHub/GitLab/Slack/npm tokens; URL passwords masked in place). Galaxy server tokens and passwords are always redacted. There is no "show secrets" switch.Network: only
ansible_upgrade_impact, on a cache miss, to Galaxy or the servers in your ansible.cfg (openWorldHint: true). The cache is never evicted automatically; deleting it is safe.
Example ansible_check_task_args output (real docs, community.general 9.5.2):
playbooks/tasks/bad_args.yml: 7 tasks checked against installed docs (ansible-core 2.21.5): 5 problems in 3 tasks
:3 ansible.builtin.copy [has action plugin; ansible-lint skips its arguments]
unknown option owner_name (line 7)
unknown option state (line 9)
backup (line 8): expected bool, got a string that is not a boolean ('maybe')
:12 ansible.posix.mount
missing required option path (aliases: name)
:18 ansible.builtin.file (key=value form): ok (dest is an alias of path)
:21 ansible.builtin.copy: ok by docs [not checked: src and content are mutually exclusive in the module's argument_spec, which ansible-doc does not expose]
:32 ansible.builtin.apt: ok; 2 templated values not checked (state, update_cache)
:38 community.general.ufw (from short name ufw)
proto (line 41): 'tcpx' is not one of any|tcp|udp|ipv6|esp|ah|gre|igmpExample ansible_upgrade_impact output (real 9.5.2 -> 12.0.0 docs):
upgrade community.general 9.5.2 -> 12.0.0 (major) for /work/site
target: requires_ansible '>=2.17.0' ok (ansible-core 2.21.5); dependencies: none; downloaded (cache: ...)
constraints: requirements.yml:3 pins '>=9.0.0,<10.0.0' (change it to allow 12.0.0)
used modules (7): git_config, proxmox_kvm, consul_acl, slack, rhsm_repository (playbooks/site.yml); timezone (roles/common/tasks/main.yml); ufw (roles/webapp/tasks/main.yml, via short name ufw)
BREAKING (5):
playbooks/site.yml:17 community.general.git_config: option list_all removed (line 19)
playbooks/site.yml:17 community.general.git_config: name is newly required, not set
playbooks/site.yml:23 community.general.proxmox_kvm: moved to community.proxmox.proxmox_kvm; community.proxmox is not installed (add it to requirements.yml)
playbooks/site.yml:31 community.general.consul_acl: removed in 10.0.0 (tombstone): Use community.general.consul_token and/or community.general.consul_policy instead.
playbooks/site.yml:43 community.general.rhsm_repository: state=present no longer accepted (choices: enabled, disabled) (line 45)
BEHAVIOR CHANGES (1):
playbooks/site.yml:37 community.general.slack: prepend_hash not set; default 'auto' -> 'never'
syntax-check with 12.0.0 (playbooks/site.yml): first error playbooks/site.yml:22: couldn't resolve module/action 'community.general.proxmox_kvm' (syntax-check stops at the first error and does not check options)
verdict: BREAKING (5)Quick start
1. Have ansible-core where the server can run it. On macOS / Linux, ansible-core (and optionally ansible-lint) on PATH, or in a venv you point ANSIBLE_MCP_BIN_DIR at. On Windows, inside WSL:
# inside WSL (any distro); a venv under $HOME survives WSL restarts, /tmp does not
python3 -m venv ~/.venvs/ansible && ~/.venvs/ansible/bin/pip install ansible-core ansible-lint2. Add the server. Claude Code, from the project:
# macOS / Linux
claude mcp add ansible -- npx -y @yawlabs/ansible-mcp@latest
# Windows (Ansible inside WSL)
claude mcp add ansible -e ANSIBLE_MCP_COMMAND_PREFIX='["wsl.exe","-d","Ubuntu","--exec"]' -e ANSIBLE_MCP_BIN_DIR=/home/me/.venvs/ansible/bin -- cmd /c npx -y @yawlabs/ansible-mcp@latestOr add it to .mcp.json in the project (or anywhere, and set ANSIBLE_MCP_DIR):
macOS / Linux:
{
"mcpServers": {
"ansible": {
"command": "npx",
"args": ["-y", "@yawlabs/ansible-mcp@latest"]
}
}
}Windows (Ansible inside WSL):
{
"mcpServers": {
"ansible": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@yawlabs/ansible-mcp@latest"],
"env": {
"ANSIBLE_MCP_COMMAND_PREFIX": "[\"wsl.exe\",\"-d\",\"Ubuntu\",\"--exec\"]",
"ANSIBLE_MCP_BIN_DIR": "/home/me/.venvs/ansible/bin"
}
}
}
}Why the extra step on Windows? Since Node 20,
child_process.spawncannot directly execute.cmdfiles (that's whatnpxis on Windows). Wrapping withcmd /cis the standard workaround.
3. Restart your MCP client and ask, for example: "Add a task that opens port 8443 with ufw -- check the arguments against our installed collections first."
Windows and WSL, in detail
The prefix must use
wsl.exe --exec(or-e), never--: with--, WSL re-parses the arguments with bash and a value likeit'sbreaks the command. The server refuses a prefix without--exec.Nothing from the Windows environment crosses into WSL. Variables the Ansible side needs (proxies,
ANSIBLE_COLLECTIONS_PATH) are forwarded by name withANSIBLE_MCP_PASS_ENV.Windows paths are translated with the mount root
wslpathreports (C:\work\site->/mnt/c/work/site). A project inside WSL works too: passdiras\\wsl.localhost\Ubuntu\home\me\site(the distro must match the prefix's-d).On a Windows drive every folder looks world-writable to WSL, and Ansible then ignores
ansible.cfg. When the project has one, the server setsANSIBLE_CONFIGto it explicitly and says so.The server's Ansible-side cache lives under the WSL user's
~/.cache/ansible-mcp(never/tmp, which WSL empties on restart).
Tell your agent to use it
Paste this into the project's CLAUDE.md (or AGENTS.md):
## Ansible
Module options drift between collection versions. Use the ansible MCP server:
- Call `ansible_project_info` once per session.
- Before writing or editing a task, call `ansible_module_doc` for its module, then
run `ansible_check_task_args` on the task (or the file). Fix every problem it
reports; quote values it flags as YAML 1.1 traps.
- Before using a role, read `ansible_role_interface`.
- Before bumping a collection in requirements.yml, run `ansible_upgrade_impact`.
- Never run plays, `--check` or `ansible-lint --fix` on your own; ask first.Configuration
All optional.
Env var | Default | Purpose |
| the server's working directory | Project used when a tool call passes no |
| (unset: native) | JSON array prepended to every Ansible command, e.g. |
| (unset: | Ansible-side directory holding |
|
|
|
| (unset) | Comma-separated names of server env vars to forward to the Ansible side in prefix mode. |
|
| Kill any Ansible command after this long (the upgrade download gets 3x). |
|
| Server-side cache (and the Ansible-side one in native mode): the dummy vault file, local temp, upgrade targets. Safe to delete. |
|
| The Ansible-side cache in prefix mode. |
| (unset) |
|
| (unset) |
|
Runtime (oam or Node):
The ansible-mcp command prefers oam when it finds a
usable one and otherwise runs on Node. It never serves on an oam older than 0.20.2.
Env var | Default | Purpose |
|
|
|
| (unset) | Path to the oam binary to use. Otherwise the launcher checks |
An outdated oam is fixed with oam self-update. Under Yaw MCP, which runs servers
on oam by default, yaw-mcp set <namespace> runtime=node switches this server to
Node. There is no --permission sandbox option: the server spawns Ansible and
reads whatever directory a call names, so there is nothing narrow to grant.
Requirements
Node.js 20+
ansible-core on the control node (verified with 2.21.5); ansible-lint for
ansible_lint_summary(verified with 26.10.1)Windows: WSL with ansible-core installed in a distro, and
ANSIBLE_MCP_COMMAND_PREFIXset. Without it, onlyansible_project_info(static half) andansible_role_interface(local files) answer; the rest say what to set.ansible_upgrade_impact: Galaxy (or your configured servers) reachable the first time a target version is requested; later runs for that version are offline
Contributing
git clone https://github.com/YawLabs/ansible-mcp.git
cd ansible-mcp
npm install
npm run lint # Biome check
npm run lint:fix # Auto-fix
npm run build # tsup bundle + declarations
npm test # Vitest (integration tests run only when Ansible is reachable)
npm run typecheck # oam check . when oam is installed, else tsc --noEmit
npm run check:oam-floor # the oam floor agrees across the repo and matches the latest oam releaseSee CONTRIBUTING.md for the full workflow, including release process.
License
MIT
Available Tools
11 toolsansible_check_task_argsCheck task argumentsARead-onlyIdempotent
Check tasks (inline YAML, or a tasks file / playbook) against the INSTALLED module docs: unknown options, missing required ones, bad choices and types (YAML 1.1 aware: unquoted off/yes/0755), suboptions, deprecated options. ansible-doc cannot express cross-option rules (mutually_exclusive, required_if), so the answer says what it could not check; it catches action-plugin modules (copy, template) that ansible-lint's args rule skips.
Inputs: dir, file, line, task.
ansible_collectionsCollections vs requirementsARead-onlyIdempotent
requirements.yml (collections and roles) against what is installed: ok, VIOLATES (with file:line) or MISSING, using galaxy constraint rules, plus collections shadowed across collections paths (the first in COLLECTIONS_PATHS wins). Never installs anything.
Inputs: dir, requirements, include_extras.
ansible_configEffective Ansible configARead-onlyIdempotent
The effective configuration for this dir (ansible-config dump) with each setting's origin (ansible.cfg, env, default); galaxy server tokens and passwords are always redacted. Settings this server overrides for safety in its other tools (vault password files, inventory and vars plugins) are flagged.
Inputs: all, dir, limit, filter.
ansible_inventoryInventory structure and varsARead-onlyIdempotent
Groups, hosts and inventory-level vars (ansible-inventory --graph/--list/--host), always redacted: vault values, secret-like names and secret-shaped values are hidden, templates are shown unrendered. Script and plugin inventory sources run code, so they are skipped unless ANSIBLE_MCP_ALLOW_DYNAMIC_INVENTORY=1 (which can also call cloud APIs); vault secrets are never supplied, so whole-file vaults degrade to a per-file view.
Inputs: dir, host, vars, group, +2 more.
ansible_lint_summaryansible-lint summaryARead-onlyIdempotent
ansible-lint (offline) grouped by rule with counts, severities and file:line locations; never fixes anything (ADT MCP's ansible_lint fixes). 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.
Inputs: dir, paths, profile, max_locations.
ansible_module_docInstalled module/plugin specARead-onlyIdempotent
Exact options (type, required, default, choices, aliases, suboptions) of a module or plugin as INSTALLED here (ansible-doc), with the collection version that provides it and redirects resolved. Use before writing a task; options drift between collection versions, so training-data guesses are often wrong.
Inputs: name (required), dir, type, include_return, +2 more.
ansible_module_searchSearch installed pluginsARead-onlyIdempotent
Find installed modules or plugins by name or description (ansible-doc -l), ranked exact name, prefix, token, then description match. Pass query, collection, or both.
Inputs: dir, type, limit, query, +1 more.
ansible_playbook_structurePlaybook structureARead-onlyIdempotent
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.
Inputs: playbook (required), dir, tags, limit, +3 more.
ansible_project_infoAnsible project overviewARead-onlyIdempotent
What this Ansible checkout contains and how Ansible sees it: ansible-core version, effective config file, collections and roles paths, installed ansible-* binaries, detected playbooks, inventories, roles and requirements files. Call it first. Read-only; never connects to a managed host (AAP MCP covers controller state, ADT MCP takes actions).
Inputs: dir.
ansible_role_interfaceRole interfaceARead-onlyIdempotent
A role's interface: argument_specs entry points and options (no_log honoured), defaults with redacted values, which defaults are undocumented, dependencies, vars names and galaxy_info. Works for local roles (roles_path, dir/roles, or a path) and collection roles (ns.collection.role).
Inputs: role (required), dir, entry_point, description_chars.
ansible_upgrade_impactCollection upgrade impactARead-onlyIdempotent
What breaks in THIS project's tasks if one collection moves to an exact version: removed or moved modules (meta/runtime.yml redirects and tombstones), removed options and aliases, newly required options, dropped choices, type and default changes, each tied to the task's file:line, plus requirements.yml constraints and a verdict. Downloads the target collection from Galaxy (or the configured servers) into this server's cache on first use; never touches dir, requirements files or your collections paths.
Inputs: version (required), collection (required), dir, playbooks, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool targets a clearly distinct facet of Ansible project analysis: inventory, config, project info, playbook structure, role interface, module docs/search, task-arg validation, collections requirements, lint summary, and upgrade impact. The descriptions explicitly differentiate overlapping-sounding tools (e.g., ansible_check_task_args vs ansible_lint_summary, ansible_module_doc vs ansible_module_search), leaving no real ambiguity.
All tools use a consistent ansible_ prefix and snake_case, which is highly predictable. The only minor deviation is mixed verb/noun construction (ansible_check_task_args and ansible_module_search are verb-led, while most others are noun phrases), but this remains readable and consistent enough.
11 tools is well within the ideal 3-15 range for a read-only Ansible project analysis server. Each tool earns its place by covering a distinct inspection or validation concern, with no obvious redundancy.
The surface is broad and complete for read-only analysis: project info, config, inventory, playbook structure, roles, modules, task args, collections, lint, and upgrade impact are all covered. Minor gaps exist, such as no explicit variable-precedence or host-fact inspection tool, but these are largely workaroundable or intentionally out of scope.
Maintenance
Related MCP Connectors
Read-only MCP server for repository context: context packs, graph impact analysis, and validation.
The Cortex MCP server provides read-only access to real-time engineering context from the Cortex developer portal, allowing AI coding assistants to answer natural language questions about your organization's catalog (microservices, libraries, domains, teams, infrastructure), scorecards (engineering standards and best practices), initiatives (goals and deadlines), and Engineering Intelligence metrics. It includes tools for querying documentation, tracking personal entities, and accessing AI-assisted insights across the entire Cortex ecosystem.
Live checks for agent-written code: missing packages, end-of-life versions, stale Actions, secrets.
Read-only AI coding tools for change verification, release readiness, capacity, and guidance.
Related MCP Servers
- AlicenseCqualityFmaintenanceThis Model Context Protocol server enables AI assistants to interact directly with Ansible, allowing them to execute playbooks, manage inventory, check syntax, and perform other Ansible operations.1827MIT
- AlicenseNot gradedqualityCmaintenanceEnables safe, local DevOps inspection through a JSON-lines server with schema validation, path isolation, and redaction, supporting read-only Git operations, Kubernetes YAML validation, Terraform plan summaries, and sanitized log analysis.MIT
- AlicenseAqualityBmaintenanceRead-only MCP server for the markdown files coding agents load: CLAUDE.md, AGENTS.md, GEMINI.md, SKILL.md, rules, commands and memory. Lints frontmatter, broken imports, invisible characters and hidden comments, shows which files load per tool and folder, and estimates token budgets. Never writes, deletes or touches the network.74MIT
- AlicenseNot gradedqualityBmaintenanceRead-only MCP server that exposes the scan_text and scan_paths tools so AI coding agents can scan text, files, staged Git changes, local history and archives for secrets entirely offline, returning redacted findings with rules, positions and fingerprints and flagging incomplete scans. Results can be emitted as JSON, JSONL or SARIF without ever serializing raw secret values or source snippets.Apache 2.0