Skip to main content
Glama
debabrata-oss

ansible-log-mcp

ansible-log-mcp

MCP server that lets Claude Desktop trigger Ansible-driven log scans across an inventory group (e.g. patching_group, up to 200+ hosts) and returns combined results.

Architecture

Claude Desktop -> MCP server (stdio) -> Ansible playbook -> target hosts (parallel forks) -> combined result -> back up the same chain.

Related MCP server: log-analyzer-mcp

Setup

git clone <this-repo>
cd ansible-log-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Edit config.yaml:

  • playbook_dir / inventory_path — point at real paths

  • allowed_groups — restrict to groups this server may touch

Symlink the real inventory instead of duplicating it:

ln -sf /etc/ansible/hosts playbooks/inventory/hosts.ini

Test before wiring into Claude Desktop

# 1. Playbook directly, against a small test group
ansible-playbook playbooks/logscan.yml \
  -i playbooks/inventory/hosts.ini \
  -e target_group=dev_test_hosts -e search_pattern=error -f 5

# 2. Unit tests
pytest tests/

# 3. MCP server via inspector (browser UI, no Claude Desktop needed)
npx @modelcontextprotocol/inspector python3 server/ansible_mcp.py

Wire into Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "ansible-logs": {
      "command": "/absolute/path/to/.venv/bin/python3",
      "args": ["/absolute/path/to/ansible-log-mcp/server/ansible_mcp.py"]
    }
  }
}

Restart Claude Desktop. Ask: "scan patching_group for kernel panics in the last day."

Security notes

  • Runs as a dedicated claude-agent SSH user, key-based auth only

  • allowed_groups in config.yaml is the only guardrail on scope — keep it tight

  • No become: true by default; add sudo only for specific read commands if needed, not blanket root

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    F
    maintenance
    Enables comprehensive Ansible automation management through natural language, including playbook creation and execution, inventory management, role scaffolding, and project workflows. Supports both local inventories and full project lifecycle management with syntax validation and idempotency testing.
    30
    -
  • F
    license
    B
    quality
    D
    maintenance
    Enables log analysis, searching, counting, and system metrics retrieval (CPU, memory, disk) via natural language, using 5 tools that can be integrated with Claude Code.
    5
    -