
bsahane/mcp-ansible 是从 https://github.com/bsahane/mcp-ansible. 导入的 MCP 服务器候选
概览
bsahane/mcp-ansible 是从 https://github.com/bsahane/mcp-ansible. 导入的 MCP 服务器候选
概述(AI 翻译)
MCP Ansible 服务器
Python高级Ansible模型上下文协议(MCP)服务器,提供用于库存、剧本、角色和项目工作流程的Ansible工具。
快速入门
要求
- Python 3.10+
- macOS/Linux
设置
运行服务器
光标配置 (/Users/bsahane/.cursor/mcp.json)
Claude for Desktop config
加到~/Library/Application Support/Claude/claude_desktop_config.json:
工具(名称)
核心Ansible工具:
- 创建playbook:从YAML字符串或指令创建playbook。
- 验证-playbook:验证playbook语法(ansible-playbook --syntax-check)
- ansible-playbook:执行剧本
- ansible-task:运行临时任务(localhost默认为connection=local)
- ansible-role:通过生成的临时操作手册执行角色
- create-role-structure:支架角色目录树
- ansible-inventory:列出库存主机和组
- register-project:注册一个 Ansible 项目以便轻松重用
- 列表项目:显示已注册项目和默认状态
- 项目-playbooks:在项目根下发现playbooks(项目根)
- 项目-运行-操作手册:使用已注册项目的库存/环境运行剧本
本地库存套件(无AAP/AWX):
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MCP Ansible Server
Advanced Ansible Model Context Protocol (MCP) server in Python exposing Ansible utilities for inventories, playbooks, roles, and project workflows.
Quick start
git clone https://github.com/bsahane/mcp-ansible.git
cd mcp-ansible
# Create and activate Python virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies via requirements.txt
python -m pip install -U pip
pip install -r requirements.txt
# (Optional) install the project package locally
pip install -e .
# Run the MCP server
python src/ansible_mcp/server.py
Requirements
- Python 3.10+
- macOS/Linux
Setup
cd /Users/bsahane/Developer/cursor/mcp-ansible
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
pip install "mcp[cli]>=1.2.0" "PyYAML>=6.0.1" "ansible-core>=2.16.0"
pip install -e .
Run the server
python src/ansible_mcp/server.py
Cursor config (/Users/bsahane/.cursor/mcp.json)
{
"mcpServers": {
"ansible-mcp": {
"command": "python",
"args": [
"/Users/bsahane/Developer/cursor/mcp-ansible/src/ansible_mcp/server.py"
],
"env": {
"MCP_ANSIBLE_PROJECT_ROOT": "/Users/bsahane/GitLab/projectAIOPS/mcp-ansible-server",
"MCP_ANSIBLE_INVENTORY": "/Users/bsahane/GitLab/projectAIOPS/mcp-ansible-server/inventory/hosts.ini",
"MCP_ANSIBLE_PROJECT_NAME": "projectAIOPS"
}
}
}
}
Claude for Desktop config
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"ansible-mcp": {
"command": "python",
"args": [
"/Users/bsahane/Developer/cursor/mcp-ansible/src/ansible_mcp/server.py"
],
"env": {
"MCP_ANSIBLE_PROJECT_ROOT": "/Users/bsahane/GitLab/projectAIOPS/mcp-ansible-server",
"MCP_ANSIBLE_INVENTORY": "/Users/bsahane/GitLab/projectAIOPS/mcp-ansible-server/inventory/hosts.ini",
"MCP_ANSIBLE_PROJECT_NAME": "projectAIOPS"
}
}
}
}
Tools (names)
Core Ansible Tools:
- create-playbook: Create playbooks from YAML strings or dicts
- validate-playbook: Validate playbook syntax (ansible-playbook --syntax-check)
- ansible-playbook: Execute playbooks
- ansible-task: Run ad-hoc tasks (defaults to connection=local for localhost)
- ansible-role: Execute roles via generated temporary playbook
- create-role-structure: Scaffold role directory tree
- ansible-inventory: List inventory hosts and groups
- register-project: Register an Ansible project for easy reuse
- list-projects: Show registered projects and default
- project-playbooks: Discover playbooks under a project root
- project-run-playbook: Run a playbook using a registered project’s inventory/env
Local inventory suite (no AAP/AWX):
- inventory-parse: Parse inventories (ansible.cfg-aware), return hosts/groups/hostvars
- inventory-graph: Show group/host graph
- inventory-find-host: Show a host’s groups and merged vars
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"ansible-mcp": {
"command": "python",
"args": [
"/Users/bsahane/Developer/cursor/mcp-ansible/src/ansible_mcp/server.py"
],
"env": {
"MCP_ANSIBLE_PROJECT_ROOT": "/Users/bsahane/GitLab/projectAIOPS/mcp-ansible-server",
"MCP_ANSIBLE_INVENTORY": "/Users/bsahane/GitLab/projectAIOPS/mcp-ansible-server/inventory/hosts.ini",
"MCP_ANSIBLE_PROJECT_NAME": "projectAIOPS"
}
}
}
}