ansible-galaxy-mcp
An MCP server that lets AI agents discover Ansible Galaxy collection input/output contracts, including module arguments, return values, and role facts, to help generate accurate playbooks.
README
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
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:
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 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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。