# Connect your agent to varsafe

These are the official instructions from varsafe for connecting a coding agent to the user's varsafe account over MCP. varsafe stores the user's secrets; once connected, the agent can find out which projects, environments and keys exist, compare environments, and run commands with secrets injected, within a grant the user approves in their browser.

Do the steps yourself where your environment lets you. Before each command or file change, tell the user in one line what it changes. Never ask the user to paste a secret, a token or a password into the conversation: sign-in happens in their browser, and nothing in this setup needs a credential from them.

- Add the varsafe MCP server to your client
- Have the user approve the connection
- (Optional) Install the varsafe CLI

---

## Add the varsafe MCP server

The hosted endpoint is `https://api.varsafe.dev/mcp` (Streamable HTTP, OAuth 2.1 with PKCE). There is no token to create: the first connection opens the varsafe consent screen in the user's browser, where they choose the teams, projects, environments and access level the agent gets. Use the section for your client.

### Claude Code

Run this command. `--scope user` makes varsafe available in every project, for this user only.

```bash
claude mcp add --scope user --transport http varsafe https://api.varsafe.dev/mcp
```

Adding the server does not sign in. Tell the user to run `/mcp` inside Claude Code and choose varsafe: their browser opens the varsafe consent screen.

### Codex

Run these commands.

```bash
codex mcp add varsafe --url https://api.varsafe.dev/mcp
codex mcp login varsafe
```

`codex mcp login` opens the varsafe consent screen in the browser straight away. Tell the user to approve it there.

### Cursor

Add this to `~/.cursor/mcp.json` (every project) or `.cursor/mcp.json` (this project). Merge it into an existing `mcpServers` object rather than replacing the file, and update an existing `varsafe` entry instead of adding a second one.

```json
{
  "mcpServers": {
    "varsafe": {
      "url": "https://api.varsafe.dev/mcp"
    }
  }
}
```

The consent screen opens in the browser the first time a varsafe tool is used.

### VS Code (GitHub Copilot)

Run this command. It adds varsafe to the user profile, for Copilot's agent mode.

```bash
code --add-mcp '{"name":"varsafe","type":"http","url":"https://api.varsafe.dev/mcp"}'
```

The consent screen opens in the browser the first time a varsafe tool is used.

### Any other MCP client

Register `https://api.varsafe.dev/mcp` as a remote (HTTP) MCP server named `varsafe` in the client's MCP configuration, then trigger its OAuth sign-in.

The browser and the client must be on the same machine, because sign-in returns to the client on `localhost`. If you are running over SSH, in a container or on a remote host, stop and point the user to [Connect with an API token](https://docs.varsafe.dev/guides/mcp#connect-with-an-api-token): they create the token in the dashboard and add it to the configuration themselves, so it never passes through this conversation.

---

## (Optional) Install the varsafe CLI

The CLI injects secrets into a process without writing a `.env` file (`varsafe run -- npm run dev`), and agents hand work to it. Ask the user whether they want it. If they do not, skip this section.

```bash
curl -fsSL https://varsafe.dev/install.sh | bash
varsafe login
```

The installer verifies the release's signature and checksum and installs to `~/.varsafe/bin`. `varsafe login` opens a browser approval; the user approves it there.

---

## Check the connection

After the client has reloaded its MCP servers, call `varsafe_whoami` (or list the user's varsafe projects). If varsafe shows as needing authentication, repeat the sign-in step for your client.

Once done, tell the user:

```
┌─ varsafe agent setup complete ───────────────────────┐
│  ✓ MCP server  <where it was added>                  │
│  ✓ Signed in   <done, or what the user must still do>│
│  ✓ CLI         <installed, or skipped>               │
│                                                      │
│  Restart or reload your agent to load the server     │
└──────────────────────────────────────────────────────┘
```

---

## Resources

- MCP guide, with every client and the API-token path: https://docs.varsafe.dev/guides/mcp
- What the user approves on the consent screen: https://docs.varsafe.dev/guides/mcp#choose-what-the-agent-may-do
- CLI reference: https://docs.varsafe.dev/cli
- Everything varsafe publishes for agents: https://varsafe.dev/llms.txt

These instructions are published at `https://varsafe.dev/agent-setup/prompt.md` so you can re-verify their authenticity at any time.
