Ansible Automation Platform MCP server

Integrates with Ansible Automation Platform, OpenShift, and Event-Driven Ansible to enable advanced automation workflows, inventory management, and job template execution for DevOps teams.
Back to servers
Setup instructions
Provider
Ricardo Lopez
Release date
Feb 27, 2025
Language
Python
Stats
18 stars

The Model Context Protocol (MCP) server enables seamless integration between Claude Desktop and your infrastructure tools like Ansible Automation Platform and OpenShift. This server acts as a bridge, allowing Claude to directly access and manage your automation workflows and Kubernetes resources through natural language commands.

Installation

Prerequisites

  • An Ansible Automation Platform (AAP) environment
  • An OpenShift Cluster with OpenShift Virtualization
  • Claude Desktop installed on your laptop (Pro Plan recommended)
  • Python 3.10 or higher
  • Authentication configured for your OpenShift cluster

Step 1: Setup Your Development Environment

First, install the uv package manager and jbang:

curl -LsSf https://astral.sh/uv/install.sh | sh

Install jbang (needed for the Kubernetes MCP Server). Using Homebrew is recommended:

brew install jbang

Restart your terminal to ensure both commands are available.

Step 2: Create Your Project

# Create a new directory for the project
uv init ansible
cd ansible

# Create virtual environment and activate it
uv venv
source .venv/bin/activate

# Install dependencies
uv add "mcp[cli]" httpx

# Create the server file
touch ansible.py

Step 3: Building the Ansible MCP Server

Create an ansible.py file with the MCP server code. The code provides tools for interacting with your Ansible Automation Platform, including:

  • Listing and managing inventories
  • Running jobs and checking their status
  • Creating and managing projects
  • Creating job templates
  • Syncing inventory sources

For self-signed SSL certificates, modify the async client to use httpx.AsyncClient(verify=False).

Configuration

Step 4: Configure Claude Desktop

Locate and edit the Claude Desktop configuration file:

# On macOS
nano ~/Library/Application\ Support/Claude/claude_desktop_config.json

Add the following configuration:

{
  "mcpServers": {
    "ansible": {
        "command": "/absolute/path/to/uv",
        "args": [
            "--directory",
            "/absolute/path/to/ansible_mcp",
            "run",
            "ansible.py"
        ],
        "env": {
            "AAP_TOKEN": "<aap-token>",
            "AAP_URL": "https://<aap-url>/api/controller/v2"
        }
    },
    "kubernetes": {
      "command": "jbang",
      "args": [
        "--quiet",
        "https://github.com/quarkiverse/quarkus-mcp-servers/blob/main/kubernetes/src/main/java/io/quarkiverse/mcp/servers/kubernetes/MCPServerKubernetes.java"
      ]
    }
  }
}

Be sure to:

  • Replace /absolute/path/to/uv with the output of which uv
  • Replace /absolute/path/to/ansible_mcp with your project directory
  • Add your AAP token and URL

To create an AAP token:

  1. Go to AAP Dashboard
  2. Select Access Management → Users → [your_user] → Tokens
  3. Click "Create token"
  4. Select "Write" scope and click "Create token"

Step 5: Launch Claude Desktop

Restart Claude Desktop to apply the changes. Verify the MCP servers are loaded by checking for the hammer icon with a number indicating available tools.

Usage

Testing Your Environment

Try asking Claude questions such as:

  • "How many Job Templates are available?"
  • "How many VMs are on my OpenShift cluster?"

Adding Event-Driven Ansible Support

You can extend your setup with Event-Driven Ansible support:

  1. Create an eda.py file in your project directory
  2. Update your Claude Desktop configuration to include the EDA server
  3. Restart Claude Desktop

The EDA MCP Server provides tools for:

  • Managing activations
  • Working with decision environments
  • Listing and accessing rulebooks
  • Managing event streams

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "ansible" '{"command":"/absolute/path/to/uv","args":["--directory","/absolute/path/to/ansible_mcp","run","ansible.py"],"env":{"AAP_TOKEN":"<aap-token>","AAP_URL":"https://<aap-url>/api/controller/v2"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "ansible": {
            "command": "/absolute/path/to/uv",
            "args": [
                "--directory",
                "/absolute/path/to/ansible_mcp",
                "run",
                "ansible.py"
            ],
            "env": {
                "AAP_TOKEN": "<aap-token>",
                "AAP_URL": "https://<aap-url>/api/controller/v2"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your 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

2. Add this to your configuration file:

{
    "mcpServers": {
        "ansible": {
            "command": "/absolute/path/to/uv",
            "args": [
                "--directory",
                "/absolute/path/to/ansible_mcp",
                "run",
                "ansible.py"
            ],
            "env": {
                "AAP_TOKEN": "<aap-token>",
                "AAP_URL": "https://<aap-url>/api/controller/v2"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later