Estimated time: 20–30 minutes. Complete Getting Started first — this guide assumes a working provider configuration.
Before You Begin
- A configured
provider "barndoor"block (see Getting Started) - An API key for the service your MCP server fronts (this guide uses a non-OAuth server)
- The directory entry ID of the MCP server you want to onboard, and the directory entry ID of the agent you want to register — both visible in the Barndoor app when browsing the MCP server and agent catalogs
Step 1: Onboard the MCP server
If the server is new to your organization, create it from its directory entry. If it was already onboarded in the portal, look it up with a data source instead — don’t manage the same server from both places.- New server
- Existing server (data source)
barndoor_mcp_server resource, data source
Server names are unique within an organization (case- and whitespace-insensitively), and destroying a
barndoor_mcp_server soft-deletes it: its connections and stored credentials are torn down, and the name is freed for reuse.Step 2: Connect it tenant-wide
Abarndoor_connection stores a service-account-owned credential for the server, so every authorized agent can use it without each user connecting individually:
barndoor_connection
Step 3: Register the AI Agent
Registration attaches the agent’s directory entry to your organization and creates the service account that policies bind to:barndoor_agent
An agent directory entry can have one live registration per organization. To reference an agent registered outside Terraform, use the barndoor_agent data source.
Step 4: Govern access with a policy
The policy is where the three pieces meet: it binds the agent (application_ids) to the server (mcp_server_id) and defines what’s allowed:
barndoor_policy
Conditional rules
Rules accept an optional condition tree, passed as JSON. Each node has exactly one ofexpr or a combinator (all / any / none) with of = [...]:
Lifecycle notes
- Destroy archives, it doesn’t delete. Destroying a
barndoor_policymoves it toARCHIVED— the platform’s terminal lifecycle state, kept for audit history. The name is freed for non-archived reuse. mcp_server_idis immutable on a policy; changing it forces a replacement (a new policy is created and the old one archived).- Importing existing objects: all four resources support
terraform import. Policies, servers, and agents import by ID; connections import by their server ID (or slug). See Best Practices → Importing.