Ansible MCP Server

by tarnover
MIT License
1
  • Linux
  • Apple

Integrations

  • Allows AI assistants to execute Ansible playbooks, view and manage inventory, validate playbook syntax, and preview tasks that would be executed by a playbook.

  • Serves as the runtime environment for the MCP server, allowing the Ansible integration to operate.

Ansible MCP Server

Ein Model Context Protocol (MCP)-Server für die Ansible-Automatisierung. Dieser Server ermöglicht KI-Assistenten die Interaktion mit Ansible, die Ausführung von Playbooks, die Bestandsverwaltung und die direkte Ausführung anderer Ansible-Operationen.

Merkmale

  • Ansible-Playbooks ausführen : Führen Sie Ansible-Playbooks mit Unterstützung für Parameter wie Inventar, zusätzliche Variablen, Tags und Limits aus
  • Inventar auflisten : Hosts und Gruppen aus einer Ansible-Inventardatei anzeigen
  • Syntax prüfen : Validieren Sie die Ansible-Playbook-Syntax ohne Ausführung
  • Aufgaben auflisten : Zeigen Sie eine Vorschau der Aufgaben an, die von einem Playbook ausgeführt werden würden
  • Zugriff auf Standardinventar : Zugriff auf die Standard-Ansible-Inventardatei über die Ressourcen-API

Anforderungen

  • Node.js 18 oder höher
  • npm oder yarn
  • Ansible installiert und im PATH
  • @modelcontextprotocol/sdk (automatisch installiert)

Installation

1. Klonen Sie das Repository

git clone https://github.com/your-username/mcp-ansible.git cd mcp-ansible

2. Abhängigkeiten installieren

npm install

3. Erstellen Sie den Server

npm run build

4. MCP-Einstellungen konfigurieren

Fügen Sie den Ansible MCP-Server zu Ihrer MCP-Einstellungskonfigurationsdatei hinzu.

Für VSCode mit Claude-Erweiterung:

  • Bearbeiten Sie die Datei unter ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

Für die Claude Desktop-App:

  • macOS: Bearbeiten Sie ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: Bearbeiten Sie %APPDATA%\Claude\claude_desktop_config.json
  • Linux: Bearbeiten Sie ~/.config/Claude/claude_desktop_config.json

Fügen Sie dem Abschnitt mcpServers Folgendes hinzu:

{ "mcpServers": { "ansible": { "command": "node", "args": ["/absolute/path/to/mcp-ansible/build/index.js"], "env": {} } } }

Stellen Sie sicher, dass Sie /absolute/path/to/mcp-ansible durch den tatsächlichen Pfad zu Ihrer Installation ersetzen.

Anwendungsbeispiele

Nach der Installation und Konfiguration stellt der MCP-Server dem KI-Assistenten die folgenden Tools zur Verfügung:

1. Führen Sie ein Playbook aus

<use_mcp_tool> <server_name>ansible</server_name> <tool_name>run_playbook</tool_name> <arguments> { "playbook": "/path/to/your/playbook.yml", "inventory": "/path/to/inventory.ini", "extraVars": { "var1": "value1", "var2": "value2" }, "tags": "setup,configure", "limit": "webservers" } </arguments> </use_mcp_tool>

2. Inventar auflisten

<use_mcp_tool> <server_name>ansible</server_name> <tool_name>list_inventory</tool_name> <arguments> { "inventory": "/path/to/inventory.ini" } </arguments> </use_mcp_tool>

3. Überprüfen Sie die Playbook-Syntax

<use_mcp_tool> <server_name>ansible</server_name> <tool_name>check_syntax</tool_name> <arguments> { "playbook": "/path/to/your/playbook.yml" } </arguments> </use_mcp_tool>

4. Aufgaben in einem Playbook auflisten

<use_mcp_tool> <server_name>ansible</server_name> <tool_name>list_tasks</tool_name> <arguments> { "playbook": "/path/to/your/playbook.yml" } </arguments> </use_mcp_tool>

5. Zugriff auf die Standardinventarressource

<access_mcp_resource> <server_name>ansible</server_name> <uri>ansible://inventory/default</uri> </access_mcp_resource>

Entwicklung

Projektstruktur

mcp-ansible/ ├── src/ │ ├── index.ts # Main entry point │ └── ansible-mcp-server/ │ └── index.ts # Ansible MCP server implementation ├── package.json # Project configuration and dependencies ├── tsconfig.json # TypeScript configuration └── README.md # Documentation

Neue Funktionen hinzufügen

So fügen Sie dem MCP-Server neue Ansible-Funktionen hinzu:

  1. Ändern Sie src/ansible-mcp-server/index.ts
  2. Fügen Sie Ihr neues Tool in der Methode setupToolHandlers hinzu
  3. Implementieren Sie eine Handlerfunktion für Ihr Tool
  4. Neuaufbau mit npm run build

Lizenz

MIT-Lizenz – Einzelheiten finden Sie unter LIZENZ

Related MCP Servers

  • A
    security
    F
    license
    A
    quality
    A Model Context Protocol server that allows secure execution of pre-approved commands, enabling AI assistants to safely interact with the user's system.
    Last updated -
    1
    3
    18
    JavaScript
  • -
    security
    F
    license
    -
    quality
    A Model Context Protocol server that enables AI assistants to access Flow blockchain data and perform operations such as checking balances, resolving domains, executing scripts, and submitting transactions.
    Last updated -
    JavaScript
    • Linux
    • Apple
  • -
    security
    F
    license
    -
    quality
    A Model Context Protocol server that provides persistent task management capabilities for AI assistants, allowing them to create, update, and track tasks beyond their usual context limitations.
    Last updated -
    1
    TypeScript
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server that connects AI assistants like Claude to Moneybird accounting software, enabling management of contacts, financial data, products, and business operations through natural language.
    Last updated -
    1
    JavaScript
    MIT License
    • Apple

View all related MCP servers

ID: vkbe70d98s