A Model Context Protocol (MCP) service that provides access to Ansible Automation Platform (AAP) APIs through OpenAPI specifications.
- Node.js 18 or higher
- Access to an Ansible Automation Platform instance
- Valid AAP authentication token
- Clone the repository:
git clone <repository-url>
cd aap-mcp-server- Install dependencies:
npm install- Build the project:
npm run buildThe service uses a YAML configuration file (aap-mcp.yaml) for flexible configuration management. Copy the sample configuration to get started:
cp aap-mcp.sample.yaml aap-mcp.yamlThe configuration file supports the following options:
# Enable API query logging (optional, defaults to false)
record_api_queries: true
# Disable HTTPS certificate validation for development (optional, defaults to false)
ignore-certificate-errors: true
# Enable web UI dashboard (optional, defaults to false)
enable_ui: true
# AAP base URL (optional, defaults to https://localhost)
# Lower priority than BASE_URL environment variable
base_url: "https://your-aap-instance.com"Configure which AAP services to load and how to access their OpenAPI specifications:
services:
- name: controller
url: "https://custom-controller.example.com/api/v2/schema/" # Optional: custom URL
local_path: "data/controller-schema.json" # Optional: local file path
enabled: true # Optional: enable/disable service
- name: galaxy
url: "https://custom-galaxy.example.com/api/v3/openapi.json"
local_path: "data/galaxy-schema.json"
enabled: true
- name: gateway
# Uses default URLs if not specified
enabled: true
- name: eda
enabled: false # Disable this serviceService Configuration Rules:
- name: Must be one of:
controller,galaxy,gateway,eda - url: Custom OpenAPI specification URL (optional, uses service defaults if not specified)
- local_path: Path to local OpenAPI file (optional, if set, loads from file instead of URL)
- enabled: Enable/disable the service (optional, defaults to true)
Define custom tool categories that group related functionality:
categories:
job_management:
- controller.job_templates_launch_create
- controller.workflow_job_templates_launch_create
- controller.jobs_read
- controller.workflow_jobs_read
inventory_management:
- controller.inventories_list
- controller.hosts_list
- controller.groups_list
system_monitoring:
- controller.ping_list
- controller.config_list
- gateway.activitystream_listEnvironment variables take precedence over configuration file settings:
# AAP Gateway Authentication token (required)
BEARER_TOKEN_OAUTH2_AUTHENTICATION=your_aap_token_here
# AAP base URL (highest priority)
BASE_URL=https://your-aap-instance.com
# MCP server port (optional, defaults to 3000)
MCP_PORT=3000Configuration values are resolved in the following order (highest to lowest priority):
- Environment Variables (e.g.,
BASE_URL,BEARER_TOKEN_OAUTH2_AUTHENTICATION) - Configuration File (
aap-mcp.yaml) - Default Values (built-in defaults)
The service supports role-based access control through user categories.
- Configure the service by copying and editing the sample configuration:
cp aap-mcp.sample.yaml aap-mcp.yaml
# Edit aap-mcp.yaml with your AAP instance details- Set your authentication token:
export BEARER_TOKEN_OAUTH2_AUTHENTICATION=your_aap_token_here- Start the service:
# Development mode
npm run dev
# Production mode
npm startWhen enable_ui: true is set in the configuration, the service provides a web interface:
- Dashboard:
http://localhost:3000/- Service overview and statistics - Tools List:
http://localhost:3000/tools- Browse all available tools - Categories:
http://localhost:3000/category- View tools by category - Services:
http://localhost:3000/services- Service-specific tool listings - Logs:
http://localhost:3000/logs- API query logs (when logging is enabled) - Health:
http://localhost:3000/api/v1/health- Service health check
The service provides several MCP endpoints:
- Standard MCP:
/mcp(POST, GET, DELETE) - Category-specific:
/mcp/{category}where category matches your configured categories
Include your AAP token in the Authorization header:
Authorization: Bearer your_aap_token_here
The service uses session-based authentication:
- Initialize a session with a POST request containing your token
- Use the returned
Mcp-Session-Idheader for subsequent requests - The service validates tokens and determines user permissions automatically
claude mcp add aap-mcp -t http http://localhost:3000/mcp -H 'Authorization: Bearer your_aap_token_here'- Configure the token as an environment variable:
export BEARER_TOKEN_OAUTH2_AUTHENTICATION=your_aap_token_here- Start the service:
npm run dev- Register with Claude:
claude mcp add aap-mcp -t http http://localhost:3000/mcpTo use specific tool categories defined in your configuration:
# Use job management tools only
claude mcp add aap-mcp-jobs -t http http://localhost:3000/mcp/job_management
# Use inventory management tools
claude mcp add aap-mcp-inventory -t http http://localhost:3000/mcp/inventory_management
# Use system monitoring tools
claude mcp add aap-mcp-monitoring -t http http://localhost:3000/mcp/system_monitoringThe service generates tools from AAP OpenAPI specifications for:
- EDA (Event-Driven Ansible): Activations, projects, rulebooks, decision environments
- Controller: Jobs, job templates, inventories, projects, organizations
- Gateway: User and team management, organizations, role definitions
- Galaxy: Collection management and versions
Tool availability depends on your configured categories and user permissions. When the web UI is enabled, you can browse available tools at http://localhost:3000/tools.
- Flexible Configuration: YAML-based configuration with environment variable overrides
- Service Selection: Enable/disable specific AAP services
- Local File Support: Load OpenAPI specs from local files or remote URLs
- Web UI Dashboard: Optional web interface for browsing tools and logs
- Role-based Access Control: Custom categories and permission-based tool filtering
- Session Management: Token validation and user permission detection
- API Query Logging: Optional logging of all tool usage
- Health Monitoring: Built-in health check endpoint for container orchestration
The configuration system follows a hierarchical approach:
-
Environment Variables (highest priority)
BASE_URL: AAP instance URLBEARER_TOKEN_OAUTH2_AUTHENTICATION: Authentication tokenMCP_PORT: Server port
-
YAML Configuration File (
aap-mcp.yaml)- Service definitions with custom URLs and local file paths
- Custom tool categories for role-based access
- Feature toggles (UI, logging, certificate validation)
-
Built-in Defaults (lowest priority)
- Default OpenAPI specification URLs for each service
- Standard port (3000) and base URL (https://localhost)
Build the image with:
podman build -f Containerfile . -t aap-mcp# Basic run with environment variables
podman run -d \
-e BASE_URL=https://your-aap-instance.com \
-e BEARER_TOKEN_OAUTH2_AUTHENTICATION=your_token_here \
-p 3000:3000 \
localhost/aap-mcp
# Run with custom configuration file
podman run -d \
-v /path/to/your/aap-mcp.yaml:/app/aap-mcp.yaml:ro \
-e BEARER_TOKEN_OAUTH2_AUTHENTICATION=your_token_here \
-p 3000:3000 \
localhost/aap-mcpThe project includes a complete Kubernetes deployment configuration in kubernetes/deployment.yaml:
# Deploy to Kubernetes
kubectl apply -f kubernetes/deployment.yaml
# Check deployment status
kubectl get pods -l app=aap-mcp
kubectl logs -l app=aap-mcpThe Kubernetes deployment includes:
- ConfigMap: Stores the YAML configuration
- Deployment: Runs the service with health checks
- PersistentVolumeClaim: Stores API query logs
- Service: Internal cluster networking
- Route: External access (OpenShift)
-
Authentication failed:
- Verify your AAP token is valid and has appropriate permissions
- Check that
BEARER_TOKEN_OAUTH2_AUTHENTICATIONis set correctly - Ensure the token has access to the AAP services you're trying to use
-
No tools available:
- Check that your token provides the expected user permissions
- Verify services are enabled in your configuration
- Check the category configuration matches your intended tool access
-
Connection refused:
- Ensure AAP is running and accessible at the configured base URL
- Check
base_urlin configuration orBASE_URLenvironment variable - Verify network connectivity and firewall settings
-
OpenAPI spec loading failed:
- Check if
local_pathfiles exist and are readable - Verify URLs are accessible if not using local files
- Review certificate validation settings for HTTPS endpoints
- Check if
-
Missing dependencies:
- Run
npm installto install required packages - Ensure Node.js version 18 or higher is installed
- Run
Validate your YAML configuration:
# Check YAML syntax
yq eval . aap-mcp.yaml
# Validate against sample
diff aap-mcp.sample.yaml aap-mcp.yamlThe service provides detailed console logging for:
- Configuration loading and validation
- OpenAPI specification loading (local files vs URLs)
- Service enabling/disabling
- Session initialization and cleanup
- Tool filtering by category
- API request execution and responses
Enable additional logging:
# In aap-mcp.yaml
record_api_queries: true # Enable API query logging
enable_ui: true # Access logs via web UI at /logsThe service includes a health check endpoint:
# Check service health
curl http://localhost:3000/api/v1/health
# Expected response
{"status":"ok"}Apache-2.0