ansible-galaxy-mcp
Provides tools for searching Ansible Galaxy collections, listing modules and roles, retrieving module and role specifications (arguments, return values, facts), and grading documentation quality, enabling AI agents to generate accurate playbooks.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ansible-galaxy-mcp Show me the arguments for the yum module"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ansible-galaxy-mcp
MCP server that exposes Ansible Galaxy collection input/output contracts. Lets AI agents discover module arguments, return values, and role facts before generating playbooks.
Quick start
npm install
npm run buildRun with stdio transport (default)
node dist/index.jsRun with HTTP transport
node dist/index.js --http
# or
MCP_TRANSPORT=http node dist/index.jsThe HTTP transport exposes the MCP Streamable HTTP endpoint at /mcp plus operational endpoints (/healthz, /readyz, /metrics).
Build a standalone binary
Requires Bun:
bun build src/index.ts --compile --outfile dist/ansible-galaxy-mcp
./dist/ansible-galaxy-mcp # stdio
./dist/ansible-galaxy-mcp --http # HTTP on port 8080The binary has no runtime dependencies — no Node.js or Bun needed on the target machine.
Run in development
npm run devRelated MCP server: MCP SysOperator
Tools
Tool | Description |
| Search Galaxy for collections by keyword |
| List all modules in a collection |
| List all roles in a collection |
| Get full input/output contract for a module |
| Get full input/output contract for a role |
| Grade a collection's documentation quality (A-F) |
MCP client configuration
Claude Code
Add to your Claude Code settings (~/.claude/settings.json or project .claude/settings.json):
{
"mcpServers": {
"ansible-galaxy": {
"command": "/path/to/dist/ansible-galaxy-mcp"
}
}
}Or with Node.js:
{
"mcpServers": {
"ansible-galaxy": {
"command": "node",
"args": ["/path/to/mcp-server/dist/index.js"]
}
}
}Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"ansible-galaxy": {
"command": "/path/to/dist/ansible-galaxy-mcp",
"env": {
"LOG_LEVEL": "info"
}
}
}
}Container (HTTP transport)
The Containerfile compiles a standalone binary with Bun and copies it into a UBI 10 micro image. The container starts in HTTP mode by default:
podman build -t ansible-galaxy-mcp .
podman run --rm -p 8080:8080 ansible-galaxy-mcpConfiguration
All configuration is via environment variables.
Variable | Default | Description |
|
| Data source: |
|
| Galaxy API base URL |
| (none) | Private Automation Hub URL (used with |
|
| Local roles directory (used with |
| (none) | Bearer token for authenticated Galaxy/Hub API access |
|
| HTTP request timeout in milliseconds |
|
| Transport: |
|
| HTTP listen port |
|
| HTTP bind address (dual-stack by default) |
|
| Enable proposed output_specs features (see below) |
|
| Log verbosity: |
Authentication
The Galaxy/Hub API token is resolved in this order:
ANSIBLE_GALAXY_TOKENenvironment variable~/.ansible/galaxy_tokenfile (plain text)tokenfield inansible.cfg([galaxy]or[galaxy_server.*]section), searched in:$ANSIBLE_CONFIG./ansible.cfg~/.ansible.cfg/etc/ansible/ansible.cfg
This follows Ansible's own precedence. In containers, use the env var or mount the token file.
Output specs feature gate
The server supports proposed Ansible output spec features behind a feature gate. By default these are off, so the server works with existing collections today.
Set ANSIBLE_OUTPUT_SPECS=true to enable:
Behavior | Gate off (default) | Gate on |
Role | Skipped | Enabled |
Role grading | Based on | Penalizes missing |
Module grading | Has RETURN block or not | Checks enriched fields ( |
| Roles not factored into grade | Roles weighted at 40% of overall grade |
This lets you use the server today with any Galaxy collection, and progressively enable the proposed spec as collections adopt it.
Source types
galaxy(default) — Fetches data from Ansible Galaxy (or a compatible API like Private Automation Hub).local— Reads roles from a local directory. Useful for development or roles not published to Galaxy.chain— Tries local first, then Hub (if configured), then Galaxy. Useful when you have private roles that override public ones.
Tests
npm testHTTP transport endpoints
When running with --http:
Endpoint | Method | Description |
| POST | MCP Streamable HTTP — send JSON-RPC messages |
| GET | MCP SSE stream — receive server-initiated messages |
| DELETE | Close an MCP session |
| GET | Liveness probe — always returns |
| GET | Readiness probe — returns |
| GET | Prometheus-format metrics |
Kubernetes deployment
livenessProbe:
httpGet:
path: /healthz
port: 8080
readinessProbe:
httpGet:
path: /readyz
port: 8080Architecture
src/
index.ts Entry point, tool registration, transport selection
http.ts Streamable HTTP transport + health/metrics endpoints
metrics.ts Prometheus-format counter registry
errors.ts Typed error classes (NotFoundError, GalaxyApiError, etc.)
logger.ts Leveled stderr logger (debug/info/warn/error)
cache.ts Generic LRU cache with TTL and metrics
types.ts TypeScript interfaces
galaxy/
client.ts Galaxy API client with caching, retry, and timeouts
source.ts Source abstraction (Galaxy, Local, Chain)
parser.ts Ansible docstring and YAML parserAvailable Tools
6 toolsget_collection_modulesList collection modulesB
List all modules in a collection with their descriptions.
Inputs: namespace (required), name (required).
get_collection_rolesList collection rolesA
List all roles in a collection with their descriptions.
Inputs: namespace (required), name (required).
get_module_specGet module input/output contractA
Get the full input/output contract for a module. Returns argument_spec (inputs) and RETURN docstring (outputs) with a documentation quality grade.
Inputs: fqcn (required).
get_role_specGet role input/output contractA
Get the full input/output contract for a role. Returns argument_specs.yml (inputs) and output_specs.yml (outputs) with a documentation quality grade. Call this for EACH role before generating a playbook to discover the exact fact names the role sets.
Inputs: fqcn (required).
grade_collectionGrade collection documentationA
Grade a collection on documentation quality. Returns A-F grade based on module RETURN documentation. With ANSIBLE_OUTPUT_SPECS=true, also checks whether roles have output_specs.yml.
Inputs: namespace (required), name (required).
search_collectionsSearch Ansible GalaxyA
Search for Ansible collections by keyword. Returns collection names, descriptions, and versions.
Inputs: query (required), limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: search collections, list modules or roles in a collection, retrieve detailed specs for a specific module or role, and grade collection documentation. No overlap or ambiguity.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., get_collection_modules, get_module_spec). The naming is predictable and easy to understand.
Six tools is an appropriate count for an Ansible Galaxy collection explorer—covering search, listing, specs, and grading without being excessive or insufficient.
The tool set provides comprehensive coverage for exploring and preparing to use Ansible collections: search, list modules/roles, get detailed specs, and grade documentation quality. No obvious gaps.
Maintenance
Related MCP Connectors
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
A registry of AI agent tools — MCP servers, APIs, CLIs, SDKs — kept current by automated ingestion.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- AlicenseCqualityFmaintenanceThis Model Context Protocol server enables AI assistants to interact directly with Ansible, allowing them to execute playbooks, manage inventory, check syntax, and perform other Ansible operations.1827MIT
- 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
- 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