ansible-aap
Enables LLMs to discover and launch Ansible job templates on Ansible Automation Platform, monitor job status, and retrieve outputs.
README
MCP Ansible Automation Platform Server
A Very basic and simple Model Context Protocol (MCP) server that provides integration with Ansible Automation Platform (AAP) via API. This server allows Large Language Models to interact with AAP to extract available templates and launch Ansible job templates with custom parameters. This is just a demo, and not a full MCP Server capabiliy, feel free to use this code as you want.

Features
- Template Discovery: Extract available job templates from configured AAP projects
- Job Launching: Launch Ansible job templates with custom extra variables and parameters
- Job Monitoring: Check job status and retrieve job outputs/logs
- Connection Testing: Verify AAP connectivity and authentication
- Error Handling: Robust error handling with retry logic and detailed error messages
Prerequisites
- Python 3.8+
- Access to an Ansible Automation Platform instance
- AAP API access token with appropriate permissions
AAP Token Generation

Installation
-
Clone this repository
-
Install dependencies:
uv pip install -r requirements.txt -
Configure environment variables:
cp env_example .env # Edit .env with your AAP configuration
Configuration
Create a .env file in the project root with the following variables:
# Ansible Automation Platform Configuration
AAP_URL=https://your-aap-instance.com
AAP_TOKEN=your-access-token-here
AAP_PROJECT_ID=your-project-id
AAP_VERIFY_SSL=True
# Optional settings
AAP_TIMEOUT=30
AAP_MAX_RETRIES=3
Configuration Parameters
AAP_URL: Base URL of your AAP instance (e.g.,https://controller.example.com)AAP_TOKEN: Bearer token for API authenticationAAP_PROJECT_ID: Default project ID to extract templates fromAAP_VERIFY_SSL: Whether to verify SSL certificates (True/False)AAP_TIMEOUT: Request timeout in seconds (default: 30)AAP_MAX_RETRIES: Number of retry attempts for failed requests (default: 3)
Usage
Testing the Server
Before integrating with Claude Desktop, test your server setup:
uv run python tools/test_mcp_server.py
This will validate:
- Environment configuration
- AAP connection
- Template extraction
- MCP server functionality
Running the Server
Start the MCP server:
uv run python server.py
The server will start and listen for MCP protocol messages on stdin/stdout.
Claude Desktop Integration
Step 1: Configure Claude Desktop
-
Locate your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
- macOS:
-
Edit the configuration file and add the MCP server:
{
"mcpServers": {
"ansible-aap": {
"command": "uv",
"args": ["run", "python", "server.py"],
"cwd": "<PATH TO THE PROJECT>",
"env": {
"AAP_URL": "https://your-aap-instance.com",
"AAP_TOKEN": "your-access-token-here",
"AAP_PROJECT_ID": "your-project-id",
"AAP_VERIFY_SSL": "True",
"AAP_TIMEOUT": "30",
"AAP_MAX_RETRIES": "3"
}
}
}
}
Important: Replace the placeholder values with your actual AAP configuration:
cwd: Use the absolute path to your MCP server directoryAAP_URL: Your AAP instance URLAAP_TOKEN: Your API access tokenAAP_PROJECT_ID: Your project ID
Step 2: Restart Claude Desktop
After saving the configuration, restart Claude Desktop completely.
Step 3: Test the Integration
Once restarted, you can test the integration by asking Claude questions like:
- "What Ansible templates are available?"
- "Show me the job templates from my AAP project"
- "Show nodes with with low disk space"
- "Check the status of job 123"
Step 4: Verify Connection
You should see Claude respond with information about your Ansible templates and be able to launch jobs. If there are issues, check:
- Claude Desktop logs for error messages
- Your AAP credentials and permissions
- Network connectivity to your AAP instance
Alternative: Using Environment File
Instead of embedding credentials in the Claude Desktop config, you can create a .env file:
{
"mcpServers": {
"ansible-aap": {
"command": "uv",
"args": ["run", "python", "server.py"],
"cwd": "<PATH TO THE PROJECT>"
}
}
}
Then create a .env file in your project directory with the AAP configuration.
Available Tools
The server provides the following tools:
1. get_job_templates
Extract available job templates from the configured AAP project.
Parameters:
project_id(optional): Override the configured project ID
Example:
{
"name": "get_job_templates",
"arguments": {
"project_id": "5"
}
}
2. launch_job_template
Launch an Ansible job template with optional parameters.
Parameters:
template_id(required): ID of the job template to launchextra_vars(optional): Extra variables to pass to the job templateinventory(optional): Inventory ID to usecredentials(optional): List of credential IDs to use
Example:
{
"name": "launch_job_template",
"arguments": {
"template_id": 10,
"extra_vars": {
"target_host": "web-server-01",
"service_name": "nginx",
"restart_service": true
},
"inventory": 2
}
}
3. get_job_status
Get the status and details of a running or completed job.
Parameters:
job_id(required): ID of the job to check
Example:
{
"name": "get_job_status",
"arguments": {
"job_id": 123
}
}
4. get_job_output
Get the output/logs of a job.
Parameters:
job_id(required): ID of the job to get output from
Example:
{
"name": "get_job_output",
"arguments": {
"job_id": 123
}
}
5. test_aap_connection
Test the connection to Ansible Automation Platform.
Parameters: None
Example:
{
"name": "test_aap_connection",
"arguments": {}
}
Integration with LLM Clients
This server can be integrated with various MCP-compatible LLM clients. The server provides a standardized interface for LLMs to:
- Discover Infrastructure: Query available Ansible templates to understand what automation is available
- Execute Operations: Launch specific templates with custom parameters based on the conversation context
- Monitor Progress: Check job status and retrieve outputs to provide feedback to users
Example LLM Interaction Flow
- Discovery: LLM calls
get_job_templatesto see what automation is available - Planning: Based on user request, LLM identifies the appropriate template and parameters
- Execution: LLM calls
launch_job_templatewith the required parameters - Monitoring: LLM uses
get_job_statusandget_job_outputto track progress and provide updates
Error Handling
The server includes comprehensive error handling:
- Connection Errors: Automatic retry with exponential backoff
- Authentication Errors: Clear error messages for token/permission issues
- Validation Errors: Parameter validation with helpful error messages
- Rate Limiting: Respectful API usage with configurable timeouts
Security Considerations
- Store AAP tokens securely in environment variables
- Use HTTPS for AAP connections
- Validate SSL certificates in production (
AAP_VERIFY_SSL=True) - Limit template access through AAP project configuration
- Monitor job launches and outputs for security compliance
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。