# Agents over MCP

> Connect Claude Code, Codex, Cursor's agent or GitHub Copilot to an Occlude session over MCP, with the configuration for each and what the agent can reach.

Source: https://occlude.dev/docs/agents-mcp/ · Reviewed 28 November 2026

An agent outside Occlude connects to a session as an MCP server. Its reads, listings, searches, writes and commands go through the same workspace as a person's, so a file the grant does not show does not exist for it.


## What the agent gets

Occlude's MCP server offers five tools:

| Tool | Does |
|---|---|
| `list_files` | Lists a folder on the person's side. *Occluded* files are not listed |
| `read_file` | Reads a *Visible* or *Read-only* file. An *Occluded* or *Absent* path answers that the file does not exist, and the attempt is recorded |
| `search` | Searches the files the agent may read, and returns matching lines |
| `write_file` | Writes a *Visible* file. A *Read-only* path is refused and recorded |
| `run_command` | Runs a script the profile lists, such as `build`, `test` or `dev`, on the build's side, or one of `submit`, `status` and `diff`. It takes a script's name, never a shell command |

`run_command` takes a name because a shell would let the agent run anything on the build's side, which can read the whole repository. A name runs exactly what your package manifest says. See [How a build runs](https://occlude.dev/docs/builds/).

The walk-through shows an agent's session on a sample repository: [`read_file` on an *Occluded* path](https://occlude.dev/demo/#agent-4), [`run_command test`](https://occlude.dev/demo/#agent-5) and [`run_command submit`](https://occlude.dev/demo/#agent-6).

## Before you start

An admin starts an agent session under a grant, naming the agent. Occlude shows two things, once:

- the session's **MCP address**;
- the session's **token**. Keep it in an environment variable, here `OCCLUDE_TOKEN`. It works for this session only and stops working when the session ends.

Use your own variable name for the token. Claude Code, for one, reads some well-known credential variables as empty in a remote server's headers.

## Claude Code

From the folder you work in:

```sh
claude mcp add --transport http occlude "$OCCLUDE_MCP_URL" \
  --header "Authorization: Bearer $OCCLUDE_TOKEN"
```

Or in a `.mcp.json` file, which Claude Code asks you to approve before first use:

```json
{
  "mcpServers": {
    "occlude": {
      "type": "http",
      "url": "${OCCLUDE_MCP_URL}",
      "headers": { "Authorization": "Bearer ${OCCLUDE_TOKEN}" }
    }
  }
}
```

Claude Code requires `"type": "http"` for a remote server: an entry with a `url` and no `type` is read as a local one.

## Cursor

In `~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project folder:

```json
{
  "mcpServers": {
    "occlude": {
      "url": "<mcp-address>",
      "headers": { "Authorization": "Bearer ${env:OCCLUDE_TOKEN}" }
    }
  }
}
```

Cursor writes environment variables as `${env:NAME}`. It asks for approval before using MCP tools by default.

## Codex

In `~/.codex/config.toml`:

```toml
[mcp_servers.occlude]
url = "<mcp-address>"
bearer_token_env_var = "OCCLUDE_TOKEN"
```

The Codex CLI, the IDE extension and the ChatGPT desktop app share this file.

## GitHub Copilot in VS Code

In `.mcp.json` at the root of the folder you have open:

```json
{
  "mcpServers": {
    "occlude": {
      "type": "http",
      "url": "<mcp-address>",
      "headers": { "Authorization": "Bearer ${OCCLUDE_TOKEN}" }
    }
  }
}
```

VS Code's documentation asks for this file, not `.vscode/mcp.json`, for new configurations.

## CI

Any MCP client that speaks Streamable HTTP connects the same way: the address, and the token as a bearer header from a secret.

## What the agent can still reach

The agent keeps its own tools for the machine it runs on. Claude Code, Codex, Cursor and Copilot all have built-in file and shell tools, and adding an MCP server does not remove them; [What AI coding agents' ignore settings actually block](https://occlude.dev/blog/ai-coding-agent-ignore-settings-compared/) compares what each tool's own settings cover. There is no clone of the repository on that machine, so those tools find nothing of it. The repository is reachable only through Occlude.

What the agent reads through Occlude goes into its context, and its context goes to its model vendor. See [Where your code goes](https://occlude.dev/docs/data-flow/).

## What the record shows

Every tool call is recorded with the agent's name and the door, `mcp`: the files read, the attempts refused, the commands run, and the diff it submitted. The same task through the browser, an editor or MCP produces the same record apart from the door's name.

## An agent that runs inside Occlude

For an agent that should not run on anyone's machine, Occlude runs its own: it proposes a plan, a person approves it before any write, and the work is checked with your type-check, tests and build. See [AI agents](https://occlude.dev/use-cases/agents/).

## Sources

Vendor pages, last read on 28 November 2026. Each vendor's behaviour can change; their page is the authority.

- [Claude Code: MCP](https://code.claude.com/docs/en/mcp)
- [Cursor: MCP](https://cursor.com/docs/mcp)
- [Codex: MCP](https://developers.openai.com/codex/mcp)
- [VS Code: MCP configuration](https://code.visualstudio.com/docs/copilot/reference/mcp-configuration)
