ansible-mcp_python
Provides tools for managing Ansible infrastructure, including inventory listing, host pinging, ad-hoc command execution, playbook validation and execution, playbook file management, and version querying.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ansible-mcp_pythonPing all hosts in the inventory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🧩 Ansible MCP Server
一个完全遵循 Model Context Protocol (MCP) 标准的 Ansible 控制服务,通过 SSE 协议暴露工具接口,可接入任何支持 MCP 协议的 AI 客户端(如 Claude Desktop、Dify、Coze 等)。
工具列表
工具 | 说明 |
| 列出 Ansible Inventory 主机组结构(JSON) |
| 列出 Inventory 中所有主机 |
| Ping 测试所有主机 |
| 执行 Ansible ad-hoc 命令(模块白名单保护) |
| 语法检查 Playbook 文件 |
| 执行 Playbook 并返回结果 |
| 列出 playbooks 目录下的可用文件 |
| 生成 Playbook 文件到 playbooks 目录 |
| 删除 playbooks 目录下的文件 |
| 查询 Ansible 版本信息 |
Related MCP server: MCP SysOperator
MCP 协议端点
端点 | 方法 | 说明 |
| GET | SSE 连接入口 |
| POST | 发送 JSON-RPC 消息 |
| GET | 健康检查 |
调用方式
MCP 工具支持两种调用格式:
方式一:标准 MCP 协议
{"method": "tools/call", "params": {"name": "list_hosts", "arguments": {}}}方式二:直接方法名(兼容)
{"method": "list_hosts", "params": {}}安全特性
路径越界防护:所有文件路径校验,阻止目录遍历攻击
模块白名单:ad-hoc 命令仅允许 45 个常用安全模块
超时保护:所有命令默认 60s 超时,Ping 默认 30s
异常保护:所有错误返回 JSON-RPC 标准错误响应
参数安全:所有工具参数均使用
.get()安全访问,缺失参数返回明确错误提示
配置(环境变量)
变量 | 默认值 | 说明 |
|
| 命令超时时间(秒) |
|
| Playbook 存储目录 |
|
| 默认 Inventory 文件路径 |
启动方式
使用 uv(推荐)
uv venv
uv pip install -r requirements.txt
uv run uvicorn main:app --host 0.0.0.0 --port 8080后台运行
nohup uv run uvicorn main:app --host 0.0.0.0 --port 8080 \
>/tmp/ansible_mcp.log 2>&1 &Docker
docker build -t ansible-mcp .
docker run -p 8080:8080 ansible-mcp接入 MCP 客户端
在支持 MCP 的客户端中配置 SSE 连接地址:
http://<your-server-ip>:8080/sse客户端会自动完成以下握手流程:
连接
/sse获取session_id发送
initialize请求完成握手调用
tools/list自动发现工具列表调用
tools/call执行具体工具
项目结构
ansible-mcp_python/
├── main.py # FastAPI 入口
├── mcp_server.py # 核心逻辑(MCP 协议 + 工具实现 + 安全校验)
├── inventory.ini # Ansible 清单文件
├── playbooks/ # Playbook 存储目录(gitignored)
├── requirements.txt # Python 依赖
├── Dockerfile # 容器构建文件
├── README.md # 文档
└── AGENTS.md # 贡献者指南This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseCqualityFmaintenanceThis 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.1826MIT
- AlicenseCquality-maintenanceAn MCP server for Infrastructure as Code that enables AI assistants to manage cloud resources through Ansible and Terraform operations. It supports executing playbooks, managing AWS services, and running Terraform commands with optional LocalStack integration.18
- Alicense-qualityBmaintenanceEnterprise-grade MCP server exposing Ansible Automation Platform 2.x as a complete AI interface for LLMs, enabling natural language management of automation resources.1Apache 2.0
- FlicenseAqualityCmaintenanceAn MCP server that lets AI agents discover Ansible Galaxy collection input/output contracts, including module arguments, return values, and role facts, to help generate accurate playbooks.6
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for Pentest-Tools.com: run scans, manage findings and reports via your preffered LLM.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/xiaofengbiancheng/ansible-mcp_python'
If you have feedback or need assistance with the MCP directory API, please join our Discord server