AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible MCP Server: AI-Driven Automation with Model Context Protocol (Complete Guide)

By Luca Berton · Published 2024-01-01 · Category: installation

Learn how the MCP server in AAP 2.7 enables AI-driven automation with natural language, VS Code, and cloud integrations.

The Model Context Protocol (MCP) server for Ansible Automation Platform, introduced as a Technology Preview in AAP 2.7, enables AI-driven automation through natural language interactions. This guide covers what MCP is, how it works with Ansible, and what it means for automation teams.

What is MCP?

The Model Context Protocol is an open standard that allows AI models (like ChatGPT, Claude, or Ansible Lightspeed) to interact with external tools, APIs, and data sources. Think of it as a universal adapter between AI and your infrastructure.

┌─────────────┐     MCP Protocol     ┌─────────────────┐
│   AI Model  │ ◄──────────────────► │  MCP Server     │
│  (LLM/Agent)│                      │  (AAP 2.7)      │
└─────────────┘                      └────────┬────────┘
                                              │
                                     ┌────────▼────────┐
                                     │  Ansible        │
                                     │  Automation     │
                                     │  Platform       │
                                     └─────────────────┘

See also: What Is MCP in Red Hat Ansible Automation Platform? Model Context Protocol Explained

What Can the MCP Server Do?

The AAP MCP server exposes automation platform operations as AI-accessible tools:

Job Management

User: "Show me all failed jobs from the last 24 hours"
MCP:  Queries AAP API → Returns job list with failure details

User: "Relaunch the patching job for host db-server-03" MCP: Identifies job template → Launches with specific host limit

Troubleshooting

User: "Why did the database backup fail on prod-db-01?"
MCP:  Retrieves job output → Analyzes error → Suggests fix

User: "Check if host web-04 is reachable and show recent job history" MCP: Runs ad-hoc ping → Queries job history → Returns combined report

Workflow Orchestration

User: "Deploy version 2.5 to staging, run tests, then promote to production if tests pass"
MCP:  Creates workflow → Launches staging deploy → Monitors tests → Conditional production deploy

MCP with VS Code

The MCP server-enabled VS Code extension integrates AI assistance into your development workflow:

// .vscode/settings.json
{
  "ansible.mcp.enabled": true,
  "ansible.mcp.serverUrl": "https://aap.example.com/api/mcp/v1",
  "ansible.mcp.authentication": "oidc"
}

With this integration, developers can: • Ask the AI to generate playbooks based on natural language descriptions • Get explanations of existing automation content • Troubleshoot playbook errors with context from the platform • Query inventory and job history directly from the editor

See also: Ansible Development Tools MCP Server: Use Claude Code, Cursor, Copilot, and Gemini for Ansible Development

Cloud Provider MCP Integrations

AAP 2.7 provides a framework for integrating MCP servers from major cloud providers:

AWS MCP Server

# Manage AWS resources via MCP
# "Create an EC2 instance in us-east-1 with the web-server security group"
- name: EC2 instance (generated via MCP)
  amazon.aws.ec2_instance:
    name: web-server-05
    instance_type: t3.medium
    image_id: ami-0abcdef1234567890
    region: us-east-1
    security_group: web-server
    state: running

Azure MCP Server

# "Deploy a resource group with a virtual network in westeurope"
- name: Azure resources (generated via MCP)
  azure.azcollection.azure_rm_resourcegroup:
    name: production-rg
    location: westeurope

- name: Create virtual network azure.azcollection.azure_rm_virtualnetwork: resource_group: production-rg name: prod-vnet address_prefixes: "10.0.0.0/16"

Security Considerations

Since MCP enables AI agents to perform operations, security is critical: • RBAC enforcement: MCP operations respect AAP role-based access control • Audit logging: All MCP-initiated actions are logged with the originating user/agent • Token-scoped access: Combined with OIDC, MCP operations use short-lived tokens • Technology Preview: Test thoroughly before using in production environments

See also: MCP Server for Ansible Automation Platform: Traditional vs AI-Driven Automation

FAQ

Is MCP the same as Ansible Lightspeed?

No. Lightspeed focuses on content generation (writing playbooks). MCP focuses on operations (managing jobs, inventory, and workflows). They complement each other.

Can I use MCP with my own AI model?

The MCP protocol is an open standard. While AAP 2.7's MCP server is designed for the platform, the protocol itself can work with any compatible AI model.

Does MCP replace the AAP API?

No. MCP uses the AAP API under the hood. It adds an AI-friendly interface layer on top of existing APIs, making them accessible via natural language.

Is MCP available in AWX?

As of this writing, MCP server is a Technology Preview feature in the commercial Ansible Automation Platform. Check AWX release notes for community availability.

What are the prerequisites for MCP?

• Ansible Automation Platform 2.7+ • RHEL 9 or RHEL 10 • Network access between the MCP client (VS Code, AI agent) and AAP

Related Articles

Red Hat Ansible Automation Platform 2.7: What's NewInstall Ansible Automation Controller on a Single HostWhat is Ansible AWX

Ansible Development Tools MCP Server

The VS Code Extension MCP (Technical Preview) exposes Ansible Development Tools as MCP tools — including scaffold, test, and lint capabilities.

Key Features

Bring Your Own LLM: Any MCP client connects with any model • Model-agnostic: Code generation happens through the client's AI model of choice • Development tools as MCP tools: Scaffold new roles/collections, run tests, lint playbooks — all via AI

Compatible MCP Clients

The Ansible MCP server has been tested with:

| Client | Type | |---|---| | Claude Code | AI coding agent | | Cursor | AI-powered IDE | | GitHub Copilot | Code completion + chat | | Gemini CLI | Google AI terminal tool | | Windsurf | AI coding IDE | | IBM Bob | IBM AI assistant |

How It Works

┌─────────────────┐     MCP Protocol     ┌──────────────────────┐
│  MCP Client     │ ◄──────────────────► │  Ansible Dev Tools   │
│  (Cursor,       │                      │  MCP Server          │
│   Claude Code,  │                      │                      │
│   Copilot...)   │                      │  Tools:              │
└─────────────────┘                      │  • scaffold (role,   │
                                         │    collection)       │
                                         │  • test (molecule)   │
                                         │  • lint (ansible-    │
                                         │    lint)             │
                                         └──────────────────────┘

Example Interactions

# In Cursor/Claude Code with Ansible MCP server connected:

User: "Scaffold a new role for deploying PostgreSQL on RHEL 9" MCP: → Calls scaffold tool → Creates role structure with tasks, handlers, defaults, molecule tests

User: "Lint my playbook and fix any issues" MCP: → Calls lint tool → Returns violations → Generates fixes

User: "Run molecule tests for the nginx role" MCP: → Calls test tool → Executes molecule → Returns results

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home