Skip to main content
Glama

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 build

Run with stdio transport (default)

node dist/index.js

Run with HTTP transport

node dist/index.js --http
# or
MCP_TRANSPORT=http node dist/index.js

The 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 8080

The binary has no runtime dependencies — no Node.js or Bun needed on the target machine.

Run in development

npm run dev

Related MCP server: MCP SysOperator

Tools

Tool

Description

search_collections

Search Galaxy for collections by keyword

get_collection_modules

List all modules in a collection

get_collection_roles

List all roles in a collection

get_module_spec

Get full input/output contract for a module

get_role_spec

Get full input/output contract for a role

grade_collection

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-mcp

Configuration

All configuration is via environment variables.

Variable

Default

Description

ANSIBLE_SOURCE_TYPE

galaxy

Data source: galaxy, local, or chain

ANSIBLE_GALAXY_URL

https://galaxy.ansible.com

Galaxy API base URL

ANSIBLE_HUB_URL

(none)

Private Automation Hub URL (used with chain source)

ANSIBLE_ROLES_PATH

./roles

Local roles directory (used with local or chain source)

ANSIBLE_GALAXY_TOKEN

(none)

Bearer token for authenticated Galaxy/Hub API access

ANSIBLE_GALAXY_TIMEOUT

30000

HTTP request timeout in milliseconds

MCP_TRANSPORT

stdio

Transport: stdio or http

MCP_HTTP_PORT

8080

HTTP listen port

MCP_HTTP_HOST

::

HTTP bind address (dual-stack by default)

ANSIBLE_OUTPUT_SPECS

false

Enable proposed output_specs features (see below)

LOG_LEVEL

info

Log verbosity: debug, info, warn, error

Authentication

The Galaxy/Hub API token is resolved in this order:

  1. ANSIBLE_GALAXY_TOKEN environment variable

  2. ~/.ansible/galaxy_token file (plain text)

  3. token field in ansible.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 output_specs.yml lookup

Skipped

Enabled

Role grading

Based on argument_specs.yml only

Penalizes missing output_specs.yml

Module grading

Has RETURN block or not

Checks enriched fields (contains, required, sample)

grade_collection role scoring

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 test

HTTP transport endpoints

When running with --http:

Endpoint

Method

Description

/mcp

POST

MCP Streamable HTTP — send JSON-RPC messages

/mcp

GET

MCP SSE stream — receive server-initiated messages

/mcp

DELETE

Close an MCP session

/healthz

GET

Liveness probe — always returns {"status": "ok"}

/readyz

GET

Readiness probe — returns {"status": "ready"}

/metrics

GET

Prometheus-format metrics

Kubernetes deployment

livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
readinessProbe:
  httpGet:
    path: /readyz
    port: 8080

Architecture

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 parser

Available Tools

6 tools
get_collection_modulesList collection modulesB

List all modules in a collection with their descriptions.

ParametersJSON Schema
NameRequiredDescriptionDefault
namespaceYesCollection namespace
nameYesCollection name

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and the description does not disclose behavioral traits such as pagination, error handling, or authentication requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no wasted words, directly addresses the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema, the description only mentions 'descriptions' without elaborating on the return structure or pagination, leaving the agent with incomplete behavioral context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with clear parameter descriptions ('Collection namespace', 'Collection name'), meeting the baseline; the description adds no additional meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List'), the resource ('modules in a collection'), and includes that descriptions are returned, distinguishing it from sibling tools like get_collection_roles.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives or any prerequisites; lacks usage scenarios or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_collection_rolesList collection rolesA

List all roles in a collection with their descriptions.

ParametersJSON Schema
NameRequiredDescriptionDefault
namespaceYesCollection namespace
nameYesCollection name

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description bears full burden. It states a read operation ('List'), but omits details about error handling, pagination, or response format. Partial transparency; adequate but not thorough.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, ten words, front-loaded with verb and resource. No wasted words; efficient and to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema; description mentions 'with their descriptions' but not structure. Lacks details on return format or edge cases. Acceptable for a simple list tool but could be more complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for both parameters (namespace, name). Tool description adds no extra meaning beyond schema, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description uses specific verb 'List' and resource 'roles in a collection' with added detail 'with their descriptions'. It clearly distinguishes from siblings like get_role_spec (which retrieves a single role spec) and get_collection_modules (which lists modules).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. Does not mention prerequisites, when not to use, or how it compares to siblings like get_role_spec for specific roles.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
fqcnYesFully qualified module name (e.g., 'community.postgresql.postgresql_db')

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden. It explains the tool returns argument_spec and RETURN docstring with a grade, but does not state that it is read-only or disclose any potential side effects. The behavior is adequately described for a read operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, concise, and front-loaded with the main purpose. Every sentence adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter, no output schema), the description adequately covers what the tool does and what it returns. It could mention that no modifications are made, but the return content is clear. Missing guidance on errors or edge cases, but overall sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single parameter 'fqcn' has 100% schema coverage with a clear description. The tool description does not add extra meaning beyond the schema, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it retrieves the full input/output contract for a module, and the tool name 'get_module_spec' aligns. It distinguishes from siblings like 'get_collection_modules' (lists modules) and 'get_role_spec' (for roles), so purpose is specific and non-overlapping.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when needing a module's contract, but does not explicitly provide when-to-use vs alternatives or exclusions. It lacks guidance on prerequisites or context, though the single parameter makes misuse unlikely.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
fqcnYesFully qualified role name (e.g., 'redhat.rhel_system_roles.firewall')

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It describes the return values (argument_specs.yml, output_specs.yml, grade) but does not disclose any behavioral traits like potential side effects, required permissions, or rate limits. The description is informative but not exhaustive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with zero waste. Every sentence adds value: first explains what the tool does, second gives a concrete usage example.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple schema (one parameter) and straightforward output (two files and a grade), the description is complete. It covers the tool's purpose, when to use it, and what it returns. No missing information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with one required parameter fqcn. The description reiterates the parameter's purpose ('Fully qualified role name') but adds the context of calling it per role, which is already implied. The baseline of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves the full input/output contract for a role, specifying the exact files (argument_specs.yml and output_specs.yml) and mentions a documentation quality grade. It distinguishes from sibling tools like get_module_spec which handles module specs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance is provided: 'Call this for EACH role before generating a playbook to discover the exact fact names the role sets.' This tells when and why to use it, though it doesn't explicitly mention when not to use it or alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
namespaceYesCollection namespace
nameYesCollection name

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the behavioral load. It describes the grading logic and optional environment variable behavior, but does not explicitly state that the tool is read-only or any other side effects. This is adequate but could be improved.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with primary purpose. Second sentence adds optional behavior. No superfluous words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with two fully described parameters and a clear output (A-F grade), the description is complete. It also covers the optional environment variable behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds no additional parameter meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'grade', the resource 'collection', and the basis for grading (module RETURN documentation and optionally output_specs.yml). It is distinct from siblings which retrieve modules, roles, or specs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains what the tool does but does not explicitly state when to use it vs alternatives. No exclusions or context about when not to use it is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_collectionsSearch Ansible GalaxyA

Search for Ansible collections by keyword. Returns collection names, descriptions, and versions.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesSearch keywords
limitNoMax results (default: 10)

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the burden. It states the tool is search-based and returns names, descriptions, versions, but fails to mention important behavioral traits like limitations (e.g., no pagination info, if it's case-sensitive, or if collections are from a specific source).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, completely front-loaded with clear purpose. No wasted words or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple search tool with only 2 parameters and no output schema, the description is adequate. It covers what the tool does and what it returns, though it could hint at result ordering or result limits.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for both parameters. The tool description adds only marginal context ('by keyword' for query, default limit) but does not further clarify parameter semantics beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the action (search) and resource (Ansible collections) with specific output fields (names, descriptions, versions). Distinguishes from sibling tools like get_collection_modules which target specific components.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for keyword-based search but does not explicitly tell when to use this tool versus siblings (e.g., after finding a collection, use get_collection_modules for details). No exclusions or alternative guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4/5.0
Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count5/5

Six tools is an appropriate count for an Ansible Galaxy collection explorer—covering search, listing, specs, and grading without being excessive or insufficient.

Completeness5/5

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

ActivityStale
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    F
    maintenance
    This 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.
    18
    26
    MIT
  • A
    license
    C
    quality
    Not graded
    maintenance
    An 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
  • A
    license
    B
    quality
    D
    maintenance
    Enterprise-grade MCP server exposing Ansible Automation Platform 2.x as a complete AI interface for LLMs, enabling natural language management of automation resources.
    86
    1
    Apache 2.0
  • A
    license
    A
    quality
    A
    maintenance
    MCP 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.
    5
    2
    Apache 2.0

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fabiendupont/mcp-ansible-galaxy'

If you have feedback or need assistance with the MCP directory API, please join our Discord server