# Use VAIL from Cursor

> Connect Cursor to VAIL, then scan, probe, and harden an agent from the repository you have open. The page for people is https://agents.projectvail.com/docs/guides/cursor; all guides: https://agents.projectvail.com/docs/guides.md

## Before you start

- A VAIL account. Sign up at [agents.projectvail.com](https://agents.projectvail.com); VAIL approves each new organization before its scans run. Accounts, approval, and tokens are explained in [auth.md](https://agents.projectvail.com/auth.md).
- The repository of the agent you want to test, open in Cursor.
- A sandboxed copy of that agent, if you will probe it. Probes try to make it break its rules, and its tool calls are real.

## Connect

1. Add VAIL to `~/.cursor/mcp.json`:

   ```json
   {
     "mcpServers": {
       "vail": {
         "url": "https://agents.projectvail.com/mcp"
       }
     }
   }
   ```

2. Open **Cursor Settings → MCP**, click **Connect** next to `vail`, and approve access in the browser.

3. Optional: add the VAIL skills, which explain the workflow in more detail. VAIL's MCP server describes its own tools, so they are not required.

   ```sh
   mkdir -p ~/.cursor/skills/agent-assurance ~/.cursor/skills/agent-improvement
   curl -fsSL https://raw.githubusercontent.com/projectvail/vail-agent-assurance/main/plugins/vail-agent-assurance/skills/agent-assurance/SKILL.md -o ~/.cursor/skills/agent-assurance/SKILL.md
   curl -fsSL https://raw.githubusercontent.com/projectvail/vail-agent-assurance/main/plugins/vail-agent-assurance/skills/agent-improvement/SKILL.md -o ~/.cursor/skills/agent-improvement/SKILL.md
   ```

## For CI or headless machines

For headless use. Create a token under [Access tokens](https://agents.projectvail.com/settings/tokens). It acts as you, so keep it in your shell profile as `VAIL_TOKEN`, never in chat or a committed file. Add `export VAIL_TOKEN=<your token>` to your shell profile (for example `~/.zshrc`), use this in `~/.cursor/mcp.json` instead, then fully quit and reopen Cursor:

```json
{
  "mcpServers": {
    "vail": {
      "url": "https://agents.projectvail.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:VAIL_TOKEN}"
      }
    }
  }
}
```

Or [add it to Cursor in one click](cursor://anysphere.cursor-deeplink/mcp/install?name=vail&config=eyJ1cmwiOiAiaHR0cHM6Ly9hZ2VudHMucHJvamVjdHZhaWwuY29tL21jcCIsICJoZWFkZXJzIjogeyJBdXRob3JpemF0aW9uIjogIkJlYXJlciAke2VudjpWQUlMX1RPS0VOfSJ9fQ==), with the same configuration.

## Check the connection

Ask Cursor:

```
Which VAIL organization am I connected to?
```

It calls `get_identity`, which names your organization and whether it may scan yet. Until VAIL approves a new organization, it can create agents and upload source, but scans and probe generation wait.

## Onboard your agent

Open the agent's repository in Cursor, and ask:

```
Use VAIL to onboard the AI agent in this repository: create it in VAIL, upload its source, scan it for behaviors, and generate probes. Then summarize the vulnerability and control behaviors it found.
```

It creates the agent in VAIL, shows you the files it will upload, uploads them with its own shell tools, scans the agent, and generates probes. Scans take several minutes. You approve probes and schedule them against the running agent in the [web app](https://agents.projectvail.com/agents).

## Test and fix the agent locally

The `agent-improvement` skill tests the agent's risks against a copy running on your machine, graded the way VAIL grades them, then fixes what the tests show and runs them again. It works for LangGraph, Hermes, and OpenClaw agents. Ask:

```
Use the agent-improvement skill to test this agent's VAIL behaviors against a local copy, and fix what fails.
```

You choose which risks to address and approve every change. The skill installs VAIL's grading package in a virtual environment of its own, and keeps results in `.vail/` in the agent's repository. Keep that directory out of version control, since it holds the agent's replies.

## Troubleshooting

- `vail` asks you to sign in again: click **Connect** next to it in **Cursor Settings → MCP**.
- With a personal token, `vail` cannot authenticate: quit Cursor fully and start it from a terminal where `VAIL_TOKEN` is set, so it inherits the variable.
- A tool returns `organization_not_approved`: your organization is still pending. Uploads work; scans and probe generation start once VAIL approves it. Questions: contact@projectvail.com.
