Ansible MCP Server

Ansible MCP Server

This 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.

Category
访问服务器

Tools

run_playbook

Run an Ansible playbook

aws_rds

Manage AWS RDS database instances

aws_route53

Manage AWS Route53 DNS records and zones

aws_elb

Manage AWS Elastic Load Balancers

aws_lambda

Manage AWS Lambda functions

aws_dynamic_inventory

Create AWS dynamic inventory

list_inventory

List Ansible inventory hosts and groups

check_syntax

Check syntax of an Ansible playbook without executing it

list_tasks

List all tasks that would be executed by a playbook

run_ad_hoc

Run an Ansible ad-hoc command against specified hosts

vault_encrypt_string

Encrypt a string using Ansible Vault

vault_decrypt_string

Decrypt a string encrypted with Ansible Vault

aws_ec2

Manage AWS EC2 instances (list, create, start, stop, terminate)

aws_s3

Manage AWS S3 buckets and objects

aws_vpc

Manage AWS VPC networks

aws_cloudformation

Manage AWS CloudFormation stacks

aws_iam

Manage AWS IAM roles and policies

README

Ansible MCP Server

A Model Context Protocol (MCP) server for Ansible automation. This server allows AI assistants to interact with Ansible, execute playbooks, manage inventory, and perform other Ansible operations directly.

Features

  • Run Ansible Playbooks: Execute Ansible playbooks with support for parameters like inventory, extra vars, tags, and limits
  • List Inventory: View hosts and groups from an Ansible inventory file
  • Check Syntax: Validate Ansible playbook syntax without execution
  • List Tasks: Preview tasks that would be executed by a playbook
  • Access Default Inventory: Access the default Ansible inventory file via resource API

Requirements

  • Node.js 18 or higher
  • npm or yarn
  • Ansible installed and in PATH
  • @modelcontextprotocol/sdk (installed automatically)

Installation

1. Clone the repository

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

2. Install dependencies

npm install

3. Build the server

npm run build

4. Configure MCP settings

Add the Ansible MCP server to your MCP settings configuration file.

For VSCode with Claude extension:

  • Edit the file at ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

For Claude Desktop app:

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

Add the following to the mcpServers section:

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

Make sure to replace /absolute/path/to/mcp-ansible with the actual path to your installation.

Usage Examples

Once installed and configured, the MCP server provides the following tools to the AI assistant:

1. Run a Playbook

<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. List Inventory

<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. Check 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. List Tasks in a Playbook

<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 Default Inventory Resource

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

Development

Project Structure

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

Adding New Features

To add new Ansible capabilities to the MCP server:

  1. Modify src/ansible-mcp-server/index.ts
  2. Add your new tool in the setupToolHandlers method
  3. Implement a handler function for your tool
  4. Rebuild with npm run build

License

MIT License - See LICENSE for details

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选