Skip to content

Architecture Reference

How Turf is put together, so you can explain it when a user asks what are you, how does this work, or what’s the architecture. This is the user-facing picture — the product, not the source tree.

Turf is a self-hosted, autonomous infrastructure-as-code tool, built on OpenTofu. It runs ordinary Terraform configurations — Terraform HCL and the public module registry, the language you already know — on OpenTofu’s providers, which talk to the clouds. What differs is the interface: instead of a terraform apply CLI aimed at a person, Turf exposes infrastructure management to an AI agent through the Model Context Protocol (MCP).

The desired state lives in the configuration directory: an ordinary Terraform root module. The user may have written it, or the agent writes it with its own file tools from a request in plain language. Either way every plan is a projection of the directory.

The MCP server (turf-mcp-server) — the interface

Section titled “The MCP server (turf-mcp-server) — the interface”

What the agent talks to: configuration discovery, workspaces, provider schemas, and the Terraform commands (init, up, apply, destroy, …) as MCP tools. One binary speaking MCP over stdio (default) or HTTP, so it plugs into any MCP client: Claude Code, Claude Desktop, cagent, kagent in Kubernetes, IDE extensions, or your own.

The Turf engine — where plans are made and applied

Section titled “The Turf engine — where plans are made and applied”

Planning and applying happen in the Turf engine, a separate process the server drives. The engine reads the same configuration directory the agent edits, holds the state lock, runs the providers, and carries each convergence — rounds of plan → approve → apply until nothing is deferred — durably. A convergence lives in the engine, so a rollout survives a server restart, a dropped client and the end of the conversation: open reports one still in flight, and apply takes it up where it stands.

Where the engine runs. Unless TURF_RESTATE_URL names one, the server uses this user’s local engine, shared by every server on the machine. The server starts it when a tool call first needs it and none is running; it then runs in the background, outliving the server and the client, until turf-mcp-server engine stop. The turf Homebrew service (brew services start turf) starts it at login instead and takes over one a server started; turf-mcp-server engine run runs it in a terminal. The server starts none when TURF_ENGINE_AUTOSTART=off, or in a container (TURF_DEPLOYMENT=container), which needs TURF_RESTATE_URL. turf-mcp-server engine status reports where it listens, how it was started, its processes, versions and logs. It listens only where this user’s account can reach it, so a client in a container or another account cannot use it. init, the provider tools and the skills work without an engine; everything that plans needs one. Until the user accepts Turf’s license terms the server starts no engine, and an engine the service or a terminal runs starts nothing: engine status and every engine call say it is awaiting the license, which turf license accept (or, without the turf CLI, turf-mcp-server license accept: the marker file it reads) ends within seconds. An engine the server starts sees the server’s acceptance; the service sees only the marker and its own turf.env, never a variable in a shell or an MCP client’s configuration.

One line. A server drives a local engine of its own line (the same major and minor version, any patch) and refuses another, naming both versions; the refusal says which side is older. An older engine (the binaries were upgraded, the engine kept running): restart it, as the refusal says — turf-mcp-server engine stop for one a server started (the next call starts the new one), brew services restart turf for the service, or stop and start turf-mcp-server engine run in its terminal. A convergence waiting in it is cancelled by the upgrade (the stack runs the old line’s engine beside the new one until what was in flight there has finished); what was applied is kept, apply on it answers cancelled naming the upgrade, and up again plans over it. A newer engine: start the client again, so it runs the new server.

The Turf CLI launches turf-mcp-server as a subprocess over stdio and drives it through an embedded agent runtime, adding a chat REPL, up/destroy commands, session memory and a friendlier tool picker. It talks to the server only through MCP. It is a convenience, not a requirement.

You ──▶ MCP client ──(MCP)──▶ turf-mcp-server ──▶ Turf engine ──▶ OpenTofu providers ──▶ cloud
(Claude, the Turf the interface durable real plugins
CLI, cagent, kagent…) plan/apply
  • Tools — the Terraform commands: configuration (init, which also installs modules and providers), workspaces (open/close/list/status/delete), the convergence (up → review the vended plan → apply, with destroy, refresh, import and invoke as up in other modes, and cancel), reading (show, output, state_list), state edits (taint/untaint) and providers (provider_search/describe). There are no authoring tools: the configuration is files the agent edits, plus *.turf.hcl overlays for Turf’s interaction points.
  • Skills — how-to guides delivered as zero-argument tools: skill_deployment (running a configuration; load it first), skill_authoring (writing one) and skill_guide (use-case walkthroughs), plus read_skill_file for the reference files a skill names. This document is one of those files.
  • Prompts — workflows a client offers as slash commands: /up (deploy or reconcile), /destroy (tear down) and /guide (a walkthrough).
  • Resources — live, read-only views, updated as convergences move: turf://workspaces (the open workspaces and the convergence holding each), turf://workspaces/{alias}, turf://workspaces/{alias}/convergences/{id} (where it stands, the plan it waits on, every round), …/rounds/{round}/plan and turf://workspaces/{alias}/state (both redacted unless ?show_sensitive=true).
  • Same inputs. Terraform HCL and the public module registry work unchanged, with the divergences references/divergences.md lists.
  • Same providers. Real OpenTofu providers make the create, read, update and delete calls; Turf orchestrates them.
  • Interoperable outputs. The plan is the OpenTofu json-format plan, exactly as tofu show -json prints it, so policy engines (OPA/Conftest), security scanners and terraform-docs consume it directly. Every approval point vends it as a resource (plan.uri), which show reads.

The agentic layer sits around these standard pieces; it does not fork the semantics. Terraform knowledge transfers, and the artifacts stay interoperable.

Turf™ is a trademark of Turf LLC. Terraform® is a trademark of HashiCorp. Ansible® is a trademark of Red Hat, LLC, registered in the United States and other countries. Helm®, Kubernetes®, Prometheus® and OpenTelemetry® are registered trademarks, and Jaeger™ is a trademark, of the Linux Foundation. OpenTofu® and Model Context Protocol® are registered trademarks of LF Projects, LLC. All other trademarks are the property of their respective owners. Turf is not affiliated with, endorsed by, or sponsored by HashiCorp, IBM, Red Hat, the Linux Foundation, LF Projects or the OpenTofu project.

© 2026 Turf LLC. Free for individuals, education and small businesses within the Community limits, under the Turf Community Edition License 1.0. Government and larger organizations need a commerciallicense.turf.build · Discord ·GitHub