Ansible MCP Server
MCP 系统操作员
用于基础设施即代码操作的模型上下文协议 (MCP) 服务器。该服务器允许 AI 助手与 Ansible 和 Terraform 交互,执行剧本和 Terraform 计划,管理云资源,并直接执行其他基础设施操作。
(该项目以前称为mcp-ansible )
演示项目
演示中的所有代码均使用 Claude 3.7 Sonnet(通过 OpenRouter)、Cline 和 SysOperator 生成
AWS LAMP Stack - 在 AWS 中部署示例 LAMP 堆栈的所有 Ansible 代码
AWS Terraform LAMP - Terraform 和 Ansible 代码来回复 LAMP 堆栈
Related MCP server: AAP MCP Server
特征
运行 Ansible Playbooks :执行 Ansible Playbooks,支持库存、额外变量、标签和限制等参数
列出清单:从 Ansible 清单文件中查看主机和组
检查语法:无需执行即可验证 Ansible playbook 语法
列出任务:预览剧本将执行的任务
访问默认库存:通过资源 API 访问默认的 Ansible 库存文件
AWS 集成:管理 AWS 资源(EC2、S3、VPC、CloudFormation 等)
Terraform 支持:执行 Terraform 命令(init、plan、apply、destroy、output 等)
tflocal 集成:使用 LocalStack 测试 Terraform 配置以进行本地云开发
LocalStack 支持:使用 LocalStack 在本地测试 AWS 操作,无需真实的 AWS 凭证
要求
Node.js 18 或更高版本
npm 或 yarn
Ansible 已安装并位于 PATH 中
@modelcontextprotocol/sdk(自动安装)
对于 AWS 操作:AWS CLI 和有效凭证
对于 LocalStack:LocalStack 已安装并正在运行,awslocal CLI
安装
1. 克隆存储库
git clone https://github.com/tarnover/mcp-sysoperator.git
cd mcp-sysoperator2.安装依赖项
npm install3. 构建服务器
npm run build4. 配置 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.jsonWindows:编辑
%APPDATA%\Claude\claude_desktop_config.jsonLinux:编辑
~/.config/Claude/claude_desktop_config.json
将以下内容添加到mcpServers部分:
{
"mcpServers": {
"sysoperator": {
"command": "node",
"args": ["/absolute/path/to/mcp-sysoperator/build/index.js"],
"env": {}
}
}
}确保将/absolute/path/to/mcp-sysoperator替换为安装的实际路径。
使用示例
一旦安装并配置完成,MCP 服务器将向 AI 助手提供以下工具:
1. 运行剧本
<use_mcp_tool>
<server_name>sysoperator</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>sysoperator</server_name>
<tool_name>list_inventory</tool_name>
<arguments>
{
"inventory": "/path/to/inventory.ini"
}
</arguments>
</use_mcp_tool>3.检查剧本语法
<use_mcp_tool>
<server_name>sysoperator</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>sysoperator</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>sysoperator</server_name>
<uri>sysoperator://inventory/default</uri>
</access_mcp_resource>6.AWS S3 操作
<use_mcp_tool>
<server_name>sysoperator</server_name>
<tool_name>aws_s3</tool_name>
<arguments>
{
"action": "list_buckets",
"region": "us-east-1"
}
</arguments>
</use_mcp_tool>7. Terraform 初始化和规划
<use_mcp_tool>
<server_name>sysoperator</server_name>
<tool_name>terraform</tool_name>
<arguments>
{
"action": "init",
"workingDir": "/path/to/terraform/project"
}
</arguments>
</use_mcp_tool>
<use_mcp_tool>
<server_name>sysoperator</server_name>
<tool_name>terraform</tool_name>
<arguments>
{
"action": "plan",
"workingDir": "/path/to/terraform/project",
"vars": {
"instance_type": "t2.micro",
"region": "us-west-2"
}
}
</arguments>
</use_mcp_tool>8. Terraform 应用
<use_mcp_tool>
<server_name>sysoperator</server_name>
<tool_name>terraform</tool_name>
<arguments>
{
"action": "apply",
"workingDir": "/path/to/terraform/project",
"autoApprove": true,
"vars": {
"instance_type": "t2.micro",
"region": "us-west-2"
}
}
</arguments>
</use_mcp_tool>9. 带有 LocalStack 的 Terraform(tflocal)
<use_mcp_tool>
<server_name>sysoperator</server_name>
<tool_name>terraform</tool_name>
<arguments>
{
"action": "apply",
"workingDir": "/path/to/terraform/project",
"useLocalstack": true,
"autoApprove": true,
"vars": {
"instance_type": "t2.micro",
"region": "us-west-2"
}
}
</arguments>
</use_mcp_tool>LocalStack 集成
该项目包含与 LocalStack 的集成,用于在本地测试 AWS 操作,无需真实的 AWS 凭证。LocalStack 集成允许您:
在本地测试使用 AWS 服务的 Ansible 剧本
无需承担 AWS 成本即可开发和测试 AWS 操作
无需真实 AWS 凭证即可运行测试
在部署到真正的 AWS 之前验证您的基础设施代码
使用 LocalStack
有关使用 LocalStack 集成的详细说明,请参阅LocalStack README 。
快速入门:
# Install LocalStack and awslocal CLI
pip install localstack awscli-local
# Start LocalStack
localstack start
# Run the sample playbook
node localstack/run_sample_playbook.mjs发展
项目结构
mcp-sysoperator/
├── src/
│ ├── index.ts # Main entry point
│ └── ansible-mcp-server/ # Will be renamed in filesystem in future updates
│ ├── index.ts # MCP SysOperator server implementation
│ ├── common/ # Common utilities and types
│ │ ├── errors.ts # Error definitions
│ │ ├── types.ts # Type and schema definitions
│ │ ├── utils.ts # Utility functions
│ │ └── version.ts # Version information
│ └── operations/ # Operation handlers
│ ├── ad_hoc.ts # Ansible ad-hoc commands
│ ├── aws.ts # AWS operations
│ ├── inventory.ts # Ansible inventory operations
│ ├── playbooks.ts # Ansible playbook operations
│ ├── terraform.ts # Terraform operations
│ └── vault.ts # Ansible vault operations
├── localstack/ # LocalStack integration
│ ├── README.md # LocalStack documentation
│ ├── sample_playbook.yml # Sample playbook for LocalStack
│ ├── inventory.ini # Sample inventory for LocalStack
│ ├── run_sample_playbook.mjs # Script to run sample playbook
│ └── utils.localstack.ts # Modified utils for LocalStack
├── package.json # Project configuration and dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # Documentation添加新功能
要向 MCP 服务器添加新功能:
修改
src/ansible-mcp-server/index.ts(未来:src/sysoperator/index.ts)在
setupToolHandlers方法中添加新工具在适当的操作文件中为您的工具实现处理程序函数
在
common/types.ts中添加模式定义使用
npm run build重建
⚠️ 免责声明
SysOperator 目前正在积极开发和广泛测试中。目前不建议在生产环境中使用。该软件可能会出现重大变更、功能不完善或出现意外行为。
使用风险自负。
执照
MIT 许可证 - 详情请参阅许可证
Available Tools
18 toolsaws_cloudformationC
Manage AWS CloudFormation stacks
Inputs: action (required), region (required), capabilities, parameters, +4 more.
aws_dynamic_inventoryC
Create AWS dynamic inventory
Inputs: region (required), compose, filters, hostnames, +1 more.
aws_ec2C
Manage AWS EC2 instances (list, create, start, stop, terminate)
Inputs: action (required), region (required), count, filters, +9 more.
aws_elbC
Manage AWS Elastic Load Balancers
Inputs: action (required), region (required), healthCheck, lbType, +7 more.
aws_iamC
Manage AWS IAM roles and policies
Inputs: action (required), region (required), assumeRolePolicyDocument, managedPolicies, +5 more.
aws_lambdaC
Manage AWS Lambda functions
Inputs: action (required), region (required), description, environment, +12 more.
aws_rdsC
Manage AWS RDS database instances
Inputs: action (required), region (required), allocatedStorage, backupRetentionPeriod, +10 more.
aws_route53C
Manage AWS Route53 DNS records and zones
Inputs: action (required), region (required), comment, recordName, +6 more.
aws_s3C
Manage AWS S3 buckets and objects
Inputs: action (required), region (required), acl, bucket, +5 more.
aws_vpcC
Manage AWS VPC networks
Inputs: action (required), region (required), cidrBlock, dnsHostnames, +5 more.
check_syntaxA
Check syntax of an Ansible playbook without executing it
Inputs: playbook (required).
list_inventoryC
List Ansible inventory hosts and groups
Inputs: inventory.
list_tasksC
List all tasks that would be executed by a playbook
Inputs: playbook (required).
run_ad_hocC
Run an Ansible ad-hoc command against specified hosts
Inputs: pattern (required), args, become, extra_vars, +2 more.
run_playbookC
Run an Ansible playbook
Inputs: playbook (required), extraVars, inventory, limit, +1 more.
terraformC
Execute Terraform commands (init, plan, apply, destroy, validate, output, etc.)
Inputs: action (required), workingDir (required), autoApprove, backendConfig, +8 more.
vault_decrypt_stringC
Decrypt a string encrypted with Ansible Vault
Inputs: string (required), vault_id, vault_password_file.
vault_encrypt_stringC
Encrypt a string using Ansible Vault
Inputs: string (required), name, vault_id, vault_password_file.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Most tools are clearly distinct by AWS service or Ansible function, with minimal overlap. However, aws_ec2's broad scope (list, create, start, stop, terminate) could be confused with more specific AWS tools, and terraform seems out of place in an Ansible-focused server, creating some ambiguity.
Tools follow a consistent snake_case pattern throughout, with clear verb_noun structures (e.g., run_playbook, list_inventory). The main deviation is the terraform tool, which lacks a verb prefix, slightly breaking the pattern.
With 18 tools, the count is borderline high for an Ansible server, especially since it includes AWS-specific tools that might be better scoped separately. It feels slightly heavy, but still manageable given the domain coverage.
The toolset covers core Ansible operations (syntax checking, inventory, tasks, ad-hoc commands, playbooks, vault) and extensive AWS management, but lacks tools for other cloud providers or non-AWS infrastructure, which could be gaps for broader automation needs.
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
A Model Context Protocol server for Wix AI tools
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
Related MCP Servers
- AlicenseCqualityNot gradedmaintenanceAn 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-
- 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
- FlicenseAqualityDmaintenanceAn 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-
- AlicenseAqualityCmaintenanceMCP server that exposes Ansible modules to AI agents with a search-schema-check-execute workflow, enabling safe ad-hoc runs via check mode by default. It provides tools to search modules, fetch schemas, run modules, and list collections.53Apache 2.0