Skip to main content

Standalone, vendor-agnostic MCP server for Ansible tooling

Project description

ansible-mcp

Standalone MCP server for Ansible tooling (lint, playbook operations, inventory parsing) with plugin-based routing and token-aware responses.

Install from package index (standalone)

After first release to PyPI, install directly with:

uv tool install ansible-mcp
# or
pip install ansible-mcp

Run:

ansible-mcp serve --stdio

Install from source (development)

cd /Users/sunny/Ansible/ansible-mcp
python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]

Run (stdio)

ansible-mcp serve --stdio

Requirements files

This project uses pyproject.toml as the dependency source of truth.

For teams/tools that expect pip-style requirement files, optional exports are included:

  • requirements.txt (runtime)
  • requirements-dev.txt (development)

Install with pip if needed:

pip install -r requirements.txt
# or
pip install -r requirements-dev.txt

VS Code MCP config (project)

Create .vscode/mcp.json:

{
  "servers": {
    "ansible-mcp": {
      "command": "ansible-mcp",
      "args": ["serve", "--stdio"],
      "type": "stdio",
      "env": {
        "WORKSPACE_ROOT": "${workspaceFolder}"
      }
    }
  }
}

Current tools (MVP)

  • lint — run ansible-lint on a file/directory
  • playbook_syntax_check — run ansible-playbook --syntax-check
  • playbook_run — run ansible-playbook
  • inventory_parse — run ansible-inventory --list
  • inventory_graph — run ansible-inventory --graph

Upstream-compatible tools (parity track)

  • list_available_tools — list upstream endpoints and current availability
  • zen_of_ansible — upstream philosophy endpoint
  • ansible_content_best_practices — upstream guidance endpoint
  • ansible_lint — upstream-compatible wrapper (mapped to lint)
  • ade_environment_info — environment diagnostics endpoint
  • ade_setup_environment — development environment setup endpoint
  • adt_check_env — ADT check/install endpoint
  • ansible_create_playbook — playbook project scaffold endpoint
  • ansible_create_collection — collection project scaffold endpoint
  • define_and_build_execution_env — execution environment definition endpoint
  • ansible_navigator — navigator execution/info endpoint

Detailed parity status is available at ansible://docs/upstream-parity.

Upstream vs standalone (this project)

Area VS Code Ansible MCP (upstream model) ansible-mcp (this repo)
Packaging Coupled to extension/monorepo workflows Standalone Python package (ansible-mcp)
Client scope Primarily VS Code/Copilot flows Any MCP-compatible client (VS Code, Claude, Cursor, CLI, etc.)
Transport Typically extension-managed STDIO STDIO, Streamable HTTP, SSE
Tool architecture Extension-shaped integration Plugin router + entry-point based expansion
Token strategy More verbose tool metadata by default Compact tool descriptions + capped/truncated responses
Docs delivery Mostly extension/context-driven docs MCP resources (ansible://docs/*) on demand

Token efficiency targets

  • Tool description budget: < 60 tokens per tool
  • tools/list total budget target: < 800 tokens
  • Per-tool response budget target: < 500 tokens (before truncation markers)

These budgets are enforced through TokenBudget and formatting/truncation helpers in the server runtime.

Roadmap: upstream parity first

Before adding non-upstream capabilities, this project will complete parity with the current upstream endpoint surface.

Phase 1 — upstream endpoint parity (completed)

  • zen_of_ansible
  • ansible_content_best_practices
  • list_available_tools
  • ansible_lint ✅ (mapped to local lint)
  • ade_environment_info
  • ade_setup_environment
  • adt_check_env
  • ansible_create_playbook
  • ansible_create_collection
  • define_and_build_execution_env
  • ansible_navigator

With parity complete, additional standalone-only tool families can be layered in without changing upstream-compatible contracts.

Definition of done for each new plugin/tool

  1. Tool schema and compact description added to plugin metadata
  2. Unit tests for argument validation and result shaping
  3. Integration tests against real backend executable/API
  4. MCP resource docs added under ansible://docs/*
  5. Token budgets respected in tool listing and responses
  6. Included in CI lanes (quality, unit, integration)

Tests

  • Fast unit lane:

    pytest tests/unit -v --tb=short
    
  • Integration lane (real Ansible executables):

    pytest tests/integration -v --tb=short -m integration
    

Integration tests require ansible-lint, ansible-playbook, and ansible-inventory. Tests are skipped automatically when required executables are missing.

Pre-commit hooks

Install the shared hooks once per clone:

uv run --extra dev pre-commit install --hook-type pre-commit --hook-type pre-push

What runs automatically:

  • pre-commit: ruff, mypy, and tests/unit
  • pre-push: tests/integration -m integration

Run all hooks manually:

uv run --extra dev pre-commit run --all-files
uv run --extra dev pre-commit run --all-files --hook-stage pre-push

Publish to PyPI

This repo includes .github/workflows/publish.yml for package publishing.

One-time setup

  1. In PyPI and TestPyPI, create the ansible-mcp project (or reserve the name).
  2. Configure Trusted Publishing for this GitHub repository and workflow.
  3. Create GitHub environments expected by the workflow:
  • testpypi
  • pypi

Publish flow

  • Manual test publish: run Publish Package workflow with repository=testpypi.
  • Production publish: push a version tag (for example v0.1.1) to trigger PyPI publish.
git tag v0.1.1
git push origin v0.1.1

Notes

  • Tool descriptions are intentionally compact for token efficiency.
  • Detailed docs are available as MCP resources:
    • ansible://docs/lint
    • ansible://docs/playbook
    • ansible://docs/inventory
    • ansible://docs/environment
    • ansible://docs/project-generators
    • ansible://docs/execution-environment
    • ansible://docs/navigator
    • schema://execution-environment
    • sample://execution-environment
    • rules://execution-environment
    • guidelines://ansible-content-best-practices

Developer guidelines

  • Use Python 3.12+ and uv for dependency and environment management.
  • Keep tool descriptions compact and schema-first.
  • Return structured outputs; avoid unbounded free-text payloads.
  • Keep subprocess execution safe (create_subprocess_exec, no shell=True).
  • Add tests for every new tool path (unit + integration).
  • Keep client-agnostic behavior: no VS Code-only assumptions in core runtime.

License

MIT (declared in pyproject.toml).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansible_mcp-0.1.0.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansible_mcp-0.1.0-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file ansible_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: ansible_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ansible_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e49853432d7454a4bc1d55022d795b1ab70cca4b8a3911275e5160010c32e2aa
MD5 636dcd64222abd3540ac6aa8057b0d95
BLAKE2b-256 eb07f25cbfdea2a1e2f066b477e3a2fed25cd9744d9bbb4033cd862882db55bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ansible_mcp-0.1.0.tar.gz:

Publisher: publish.yml on shreyanshjain7174/ansible-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ansible_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ansible_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ansible_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8cc50dcd6a8b158cec7b6a2d449174eb03580c35d590aaababf47faa22b698e0
MD5 0f4c82e6a239fee09848db63ed53a6d9
BLAKE2b-256 d5b2de5949af3baef0676616dfcee5afa2861c4b9f7136d136ef6cc2b9f9ae9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ansible_mcp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on shreyanshjain7174/ansible-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page