← Back to Blog

MCP, Tools and Skills for Infrastructure Automation: Applying the Pattern to Ansible, Terraform and OpenShift

MCP, Tools and Skills for Infrastructure Automation

Infrastructure automation already solved its layering problem years ago: Terraform for declarative state, Ansible for procedural configuration, and a pile of institutional knowledge on top - the correct order to run things, which flags matter for which environment, and what to check before you trust that “apply” actually worked. Handing the same work to an AI agent does not erase that layering. It adds another decision: which steps the agent should call as deterministic tools, and which it should follow as a written playbook.

MCP as the interface to your infrastructure state

Anything that touches real infrastructure state belongs behind a Terraform or Ansible MCP server: applying a plan, running a playbook against a target inventory, querying the current state of a Kubernetes or OpenShift resource. That is the same argument as for Kafka administration and enterprise API access elsewhere on this blog. Deterministic, schema-bound actions with real consequences should go through a proper interface, not an agent improvising shell commands against a live cluster.

An MCP server that exposes terraform plan, terraform apply, and kubectl/oc get style reads as separate, auditable tool calls gives each agent-made change the same traceability as a change through your existing CI/CD pipeline. Ideally it is going through that pipeline, with the agent as another kind of operator rather than a shortcut around it.

Tools for the small, safe, local operations

Plenty of cluster deployment steps do not need MCP ceremony. Validating a namespace name against your organisation’s naming convention, checking that a registry pull secret is present before a longer process starts, or converting a human-supplied storage size into the right StorageClass format are fine as plain tools - fast, local, low consequence, no protocol overhead.

Skills as the encoded deployment runbook

Infrastructure automation gets the most from Skills here, because a good deployment script is already a skill that lacks the metadata to be discovered automatically. Take a typical operator-based install on OpenShift or Kubernetes: add the operator source or catalog, install the operators your stack needs, wait until those operators are ready, create the custom resources for each component, then wire secrets and credentials - in that order, often with a long settle time because controllers and webhooks really do need it. None of that sequence is arbitrary, and none of it is something you want an agent reinventing from first principles under time pressure.

Written up as a Skill - correct order, flags for optional components, and the specific kubectl/oc get checks that confirm each piece is healthy before the next step - it becomes a playbook the agent should load and follow rather than invent. The general rule holds: any automation good enough to hand a junior engineer as a runbook is good enough to become a Skill.

Where the three come together

A realistic request - “deploy the event platform to the tools namespace with the API gateway enabled” - should use all three layers. The Skill matches on the deployment intent and loads the sequence: operator source first, verify it before installing operators, install operators in the documented order, wait for readiness before creating instances, then check known failure modes - image pull errors from a missing or expired pull secret, pods stuck Pending because no storage class was specified. Following that sequence, the agent calls MCP tools that wrap the actual kubectl/oc and Terraform operations, each one a discrete, auditable action rather than a raw shell command invented on the fly. Small tools handle local bookkeeping: namespace validation, flag parsing, and formatting the final access URLs and credentials once the deployment finishes.

Why infrastructure is less forgiving

Infrastructure mistakes cost more than a bad email draft. An agent that “figures out” a Kubernetes deployment sequence by trial and error is a production incident waiting to happen, especially on OpenShift, where operators, subscriptions and custom resources have ordering dependencies that are not obvious from the object definitions alone. Treat Skills as first-class deployment documentation, and keep MCP tool calls narrow, auditable, and under the same approval and rollback rules your CI/CD pipeline already uses. The agent is a new kind of operator. It should not get a lower bar than the humans it works alongside.