ansible-mcp-server
Ansible NLP MCP
本地 MCP 服务器,允许 Codex 通过自然语言与此 Ansible 仓库交互,使用安全工具而不是暴露通用 shell。
工具
health:显示根目录、超时时间以及是否启用可变执行。list_playbooks:列出可执行的 playbook 和工作流。inspect_playbook:总结 plays、主机、vars_files、初始任务和常见的必需变量。suggest_playbooks:根据自然语言请求对 playbook 进行排名。inventory_graph:执行ansible-inventory --graph。inventory_summary:总结清单中的组和主机。syntax_check:执行ansible-playbook --syntax-check。check_playbook:执行ansible-playbook --check。run_playbook:执行实际的 playbook,默认阻止。ping_hosts:执行ansible -m ping或ansible.windows.win_ping。list_logs和tail_log:查询logs/中的日志。
Related MCP server: AAP MCP Server
安装
cd /root/ansible
python3 -m venv .venv-mcp
. .venv-mcp/bin/activate
pip install -r ansible_mcp/requirements.txt本地测试
cd /root/ansible
. .venv-mcp/bin/activate
python -m ansible_mcp.server此命令通过 stdio 启动 MCP 服务器,并等待 MCP 客户端。
在 Codex 中配置
项目中的 .codex/config.toml 示例,如果要全局启用,则放在 ~/.codex/config.toml:
[mcp_servers.ansible]
command = "/root/ansible/.venv-mcp/bin/python"
args = ["/root/ansible/ansible_mcp/server.py"]
cwd = "/root/ansible"
enabled = true
startup_timeout_sec = 10
tool_timeout_sec = 900
env = { ANSIBLE_MCP_ROOT = "/root/ansible", ANSIBLE_MCP_ALLOW_RUN = "0" }使用 ANSIBLE_MCP_ALLOW_RUN = "0" 时,MCP 允许检查、清单、ping、语法检查和检查模式,但会阻止实际执行 playbook。
要允许可变执行:
[mcp_servers.ansible]
command = "/root/ansible/.venv-mcp/bin/python"
args = ["/root/ansible/ansible_mcp/server.py"]
cwd = "/root/ansible"
enabled = true
startup_timeout_sec = 10
tool_timeout_sec = 900
env = { ANSIBLE_MCP_ROOT = "/root/ansible", ANSIBLE_MCP_ALLOW_RUN = "1" }即使启用,run_playbook 在调用工具时仍需要 confirm = "RUN"。
NLP 意图示例
“我该用哪个 playbook 来更新 wuday1 的 Windows?”
“对 Windows Update 的 playbook 使用
day=wuday1进行语法检查。”“仅在 rocky 组上以检查模式运行 Linux 更新。”
“显示 Citrix Day 的最新日志。”
“列出清单组以及每个组中有多少台主机。”
This server cannot be deployed
Maintenance
Related MCP Connectors
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
Official Microsoft MCP Server to query Microsoft Entra data using natural language
MCP server for generating rough-draft project plans from natural-language prompts.
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
- AlicenseBqualityDmaintenanceEnterprise-grade MCP server exposing Ansible Automation Platform 2.x as a complete AI interface for LLMs, enabling natural language management of automation resources.861Apache 2.0
- AlicenseAqualityDmaintenanceAn 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.6296 npmMIT
- FlicenseNot gradedqualityDmaintenanceIndustry-standard MCP server for AWX/AAP/Ansible Tower automation, enabling AI agents to manage job templates, launch and monitor jobs, and handle inventories and projects through natural language.12-