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 服务器

用于 Ansible 自动化的模型上下文协议 (MCP) 服务器。该服务器允许 AI 助手与 Ansible 交互、执行剧本、管理库存以及直接执行其他 Ansible 操作。

特征

  • 运行 Ansible Playbooks :执行 Ansible Playbooks,支持库存、额外变量、标签和限制等参数
  • 列出清单:从 Ansible 清单文件中查看主机和组
  • 检查语法:无需执行即可验证 Ansible playbook 语法
  • 列出任务:预览剧本将执行的任务
  • 访问默认库存:通过资源 API 访问默认的 Ansible 库存文件

要求

  • Node.js 18 或更高版本
  • npm 或 yarn
  • Ansible 已安装并位于 PATH 中
  • @modelcontextprotocol/sdk(自动安装)

安装

1. 克隆存储库

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

2.安装依赖项

npm install

3. 构建服务器

npm run build

4. 配置 MCP 设置

将 Ansible MCP 服务器添加到您的 MCP 设置配置文件。

对于带有 Claude 扩展的 VSCode:

  • 编辑文件~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

对于 Claude 桌面应用程序:

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

将以下内容添加到mcpServers部分:

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

确保将/absolute/path/to/mcp-ansible替换为安装的实际路径。

使用示例

一旦安装并配置完成,MCP 服务器将向 AI 助手提供以下工具:

1. 运行剧本

<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. 列出库存

<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.检查剧本语法

<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. 在剧本中列出任务

<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. 访问默认库存资源

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

发展

项目结构

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

添加新功能

要向 MCP 服务器添加新的 Ansible 功能:

  1. 修改src/ansible-mcp-server/index.ts
  2. setupToolHandlers方法中添加新工具
  3. 为您的工具实现处理程序函数
  4. 使用npm run build重建

执照

MIT 许可证 - 详情请参阅许可证

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

该模型上下文协议服务器使 AI 助手能够直接与 Ansible 交互,从而允许他们执行剧本、管理库存、检查语法和执行其他 Ansible 操作。

  1. 特征
    1. 要求
      1. 安装
        1. 1. 克隆存储库
        2. 2.安装依赖项
        3. 3. 构建服务器
        4. 4. 配置 MCP 设置
      2. 使用示例
        1. 1. 运行剧本
        2. 2. 列出库存
        3. 3.检查剧本语法
        4. 4. 在剧本中列出任务
        5. 5. 访问默认库存资源
      3. 发展
        1. 项目结构
        2. 添加新功能
      4. 执照

        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