# Write a Policy with Your Own AI

The Magistrate MCP server is in private preview.

You can write Magistrate policies with the AI tool you already use: Claude, ChatGPT, Gemini, Cursor, or any client that supports remote MCP servers. Your AI writes the policy, checks it with Octet's tools, and either opens it in the [Magistrate Studio](https://magistrate.octetproof.com/) or submits it for approval.

Your AI never publishes a policy. A submitted policy waits in the Studio until an owner or admin of your Octet account reviews it line by line and approves it.

## What you need

- **The connector URL:** `https://magistrate.octetproof.com/mcp`
- **An Octet account.** You sign in with it when your AI client connects. The client then acts as you, for your account.
- **The owner or admin role** on that account. Viewers can sign in to the Studio but can't connect a client.

When a client connects, it opens a consent page that names the client, then Octet sign-in. After you allow it, the client appears on your [account page](https://magistrate.octetproof.com/account) under connected AI clients, where you can disconnect it.

## The tools

Every client gets the same 10 tools:

| Tool | What it does |
|---|---|
| Authoring guide | What a policy can say, the policy schema, and worked examples |
| Regions | Country and subdivision codes with names, and the named sanctions lists |
| Place search | Coordinates for a place, to centre a circle on |
| Check | Validates a policy and returns its question, which answer is YES, and any errors with fixes |
| Preview | The answer (YES, NO or UNKNOWN) the policy gives at a point |
| Open in Studio | A link that opens the policy in the Studio's Review. The link expires after 7 days. |
| Submit for approval | Sends the policy to your account's Awaiting approval list in the Studio |
| Submission status | Whether a submission is awaiting approval, approved (live), rejected (discarded) or expired (nobody approved it within 14 days) |
| Your account | Your account and its licenses |
| Your policies | The policies live on your account |

## Claude (claude.ai and the desktop app)

Works on every Claude plan. The Free plan allows one custom connector.

1. Open **Settings -> Connectors** and click **Add custom connector**.
2. Enter the name `Octet` and the URL `https://magistrate.octetproof.com/mcp`. Leave the advanced settings empty. Claude registers itself with Octet.
3. Click **Connect** and sign in to Octet.
4. In a chat, turn on **Octet** under the tools button below the message box.

## Claude Code

1. Add the server:
   ```sh
   claude mcp add --transport http octet https://magistrate.octetproof.com/mcp
   ```
2. Start `claude`, type `/mcp`, select **octet** and choose **Authenticate**. Your browser opens Octet sign-in.
3. `/mcp` shows octet as connected.

To remove it: `claude mcp remove octet`.

## ChatGPT

Works on a free ChatGPT account. Developer mode isn't needed.

1. Open **Settings -> Plugins** (`chatgpt.com/settings/plugins-settings`) and add a custom connector.
2. Enter the name `Octet` and the URL `https://magistrate.octetproof.com/mcp`, with OAuth as the authentication.
3. Sign in to Octet when ChatGPT asks.
4. In a new chat, turn on **Octet** from the **+** menu next to the message box.

## Gemini (Antigravity)

Use Google's Antigravity CLI, `agy`. Gemini CLI doesn't accept sign-in for individual Google accounts and points to Antigravity instead.

1. Add the server:
   ```sh
   agy mcp add octet https://magistrate.octetproof.com/mcp
   ```
2. Start `agy` and choose a Gemini model.
3. If the server list shows `Unauthorized [Auth Needed]`, select **octet** and authenticate. If your version of `agy` has no authenticate action, use an [API token](#scripts-and-ci-api-tokens) instead:
   ```sh
   agy mcp add --header "Authorization: Bearer <token>" octet https://magistrate.octetproof.com/mcp
   ```

## Cursor

1. Open `~/.cursor/mcp.json` (or **Settings -> MCP -> Add new MCP server**) and add:
   ```json
   { "mcpServers": { "octet": { "url": "https://magistrate.octetproof.com/mcp" } } }
   ```
2. Cursor shows the server as needing sign-in. Click it and sign in to Octet.

## Scripts and CI: API tokens

For a script, a CI job, or a client without OAuth sign-in, use an API token.

1. Sign in at [magistrate.octetproof.com/account](https://magistrate.octetproof.com/account) as an owner or admin.
2. Under **API tokens**, enter a name, pick an expiry and click **Create token**. Copy the token: it's shown once.
3. Send it as `Authorization: Bearer <token>`, either to the MCP URL or to the REST API under `https://magistrate.octetproof.com/api/v1/authoring/`. The REST API has the same operations as the tools, and its [OpenAPI file](https://magistrate.octetproof.com/api/v1/authoring/openapi.json) lists each one.

A token acts as you, for your account, until it expires or you revoke it on the same page.

## Try it

Ask your AI:

> Using Octet, write a policy that answers YES only in Austria, Germany and Switzerland. Check it and preview it at Vienna, Munich and Paris.

It returns the policy question ("Is the device in Austria, Germany or Switzerland?") and the answers YES, YES and NO.

Then ask it to do one of two things:

- **Open it in the Studio.** Your AI gives you a link. The policy opens in Review, with every line unapproved. From there, review, sign and ship it as you would a policy you wrote in the Studio.
- **Submit it for approval.** The policy appears at the top of the Studio's sidebar under **Awaiting approval**, marked with the client that sent it. An owner or admin opens it, reviews each line, and chooses **Approve and ship** to put it live on a license, or **Discard**. A submission nobody approves expires after 14 days. Your AI can check the outcome with the submission status tool.

## Limits

- A policy can have up to 20 circles, each with a radius from 1 m to 1,000 km. Its circles are all included or all excluded, and a policy with circles has no other places. Choose a radius larger than the location accuracy of the phones you expect.
- Policies name countries, US states, circles and the named sanctions lists. Cities given by name can't be decided from the SDK's proofs. Use a circle instead.
- Calls are rate-limited per signed-in user.
