Transcend Docs

Author policies with an AI agent

Use a coding agent, the Policy Engine agent skill, and the Transcend Model Context Protocol (MCP) server to write, test, and publish Policy Engine policies.

Describe the rules you want in plain language, and let a coding agent write and test the Rego. We recommend this path for most teams. For how decisions work, see Policy Engine.

The agent uses two things from Transcend:

  • The Policy Engine agent skill teaches the agent the bundle layout, the Permissions API contract, Rego v1 rules, and the CLI checks. It works with Cursor, Claude Code, Codex, and other agents that read skills.
  • The Transcend MCP server lets the agent list, upload, and activate bundle versions in your organization. It is optional. Without it, the agent publishes with the CLI, or your CI publishes after review.

Prerequisites

  • A coding agent that can run shell commands in your repository.
  • Node.js 22.12 or later, OPA version 1 or later, and Regal. The agent can install these for you.
  • To publish from the agent, a Transcend user with the Activate Policy scope.

1. Ask your agent to set up the workspace

Give your agent this prompt:

Use the Transcend Policy Engine skill (https://github.com/transcend-io/tools/blob/main/skills/transcend-policy-engine/SKILL.md) to set up Policy Engine in this repository with a Permissions bundle.

The skill has the agent install the Transcend CLI, then run transcend policy init and transcend policy new --template permissions. To install the skill yourself, run transcend policy init --skill. The CLI writes it to .agents/skills/transcend-policy-engine and links it for the agents it finds in your repository.

2. Connect the MCP server

Skip this step if you publish only from CI.

Set up an OAuth client and your MCP client as described in the MCP Guide. Then add the unified Transcend server:

{
  "mcpServers": {
    "transcend": {
      "command": "npx",
      "args": ["-y", "@transcend-io/mcp"],
      "env": {
        "TRANSCEND_OAUTH_CLIENT_ID": "your-client-id",
        "TRANSCEND_OAUTH_CLIENT_SECRET": "your-client-secret",
        "TRANSCEND_OAUTH_REDIRECT_PORT": "5555"
      }
    }
  }
}

We recommend the unified server over the policy-only @transcend-io/mcp-server-policy package. With it, the agent can read your organization's purposes and Preference Stores, so the policy uses your real purpose names. On the first tool call, a browser window asks you to sign in and approve access.

The Policy Engine tools are in beta:

ToolDoes
policy_get_templatesReturns the starter templates. Needs no network access.
policy_list_bundlesLists bundles, their versions, and download links.
policy_publishUploads a new version from a folder. The version is not live.
policy_set_liveActivates a version, or deactivates a bundle.

policy_publish and policy_set_live ask you to confirm before they run. Read the bundle name and version in the request before you approve.

3. Describe the policy

Tell the agent what each purpose should decide, and say which context fields your application sends. Name the purposes the way your Preference Store does. With the MCP server connected, the agent can look them up for you. For example:

In the permissions bundle, add a SaleOfInfo purpose. Allow it only after an explicit opt-in. If the user never chose and context.region is US-CA, escalate. Deny everything else. Add tests for each case.

The skill tells the agent to keep decisions fail-closed. It also asks for tests of malformed and incomplete input, not only the allow cases.

4. Review the tests and output

Ask the agent to run transcend policy check until it passes. Then ask it to run transcend policy eval with a few sample inputs and show you the result.

Review the Rego and the tests as you would any other code change. Check that each purpose returns the decision you expect for an opt-in, an opt-out, and no choice.

5. Publish and activate

Ask the agent to publish the bundle as the remote bundle permissions. With the MCP server, the agent calls policy_publish. Without it, the agent runs transcend policy publish.

When you are ready to go live, ask the agent to activate the new version. Confirm the policy_set_live request. Your application gets the new decisions after a short delay.

To publish only from reviewed code on your main branch, stop after step 4 and follow Publish policies from git and CI.

On this page