# MCP server for AI assistants

> Connect Claude Code, Claude Desktop, Cursor or VS Code to Cloak Proxy over MCP to read traffic, set up mocks and breakpoints, and run API tests.

Source: https://docs.subcloak.com/cloak-proxy/automation/mcp-server/

Cloak Proxy is a Model Context Protocol (MCP) server. Connect it to an AI assistant such as Claude Code, Claude Desktop, Cursor or VS Code, and the assistant can do what you do in the app: read, search, trace, replay and repeat captured requests, turn them into replayable flows, map where an app sends its users' data, turn on capture and SSL proxying, mute noisy apps, create Map Local mocks, Rewrite rules and breakpoints, answer paused requests, read Insights, test authorization by replaying requests as other users, check traffic against an OpenAPI spec, compare two builds' traffic, turn traffic into tests, read streamed responses event by event, see the tokens and cost of model calls, follow distributed traces, set up capture step by step, and use the whole [API client](https://docs.subcloak.com/cloak-proxy/api-client/overview/). It offers 154 tools, 7 resources and 6 prompts, and runs entirely on your Mac.

## How it works

The server is [`cloakctl mcp`](https://docs.subcloak.com/cloak-proxy/automation/cloakctl/#start-the-mcp-server). Your assistant starts it as a local process and talks to it over standard input and output. It does nothing until the assistant calls a tool.

| Kind of tool | Where it runs | Needs the app open |
|---|---|---|
| Captured traffic: `list_requests`, `get_request`, `get_request_curl`, `replay_request` | The proxy's [control API](https://docs.subcloak.com/cloak-proxy/automation/control-api/) | The app, or [`cloakctl run`](https://docs.subcloak.com/cloak-proxy/automation/headless-and-ci/) |
| Everything else in the proxy: capture, SSL proxying, settings, debugging tools, breakpoints, Insights, windows | The running app, through `POST /api/rpc` | Yes |
| API client: collections, requests, environments, runs, mocks, specs, flows, Git and more | The workspace folder, read and written directly | No |

Changes an assistant makes show up in the app's windows right away, and changes to the workspace are picked up by the app if it's open.

The Cloak Proxy app for iPhone and iPad serves the same tools over the network instead, over HTTPS with a token. See [Let AI assistants control your iPhone or iPad](https://docs.subcloak.com/cloak-proxy/ipad/ai-assistants/).

## Connect your assistant

You need Cloak Proxy installed in `/Applications`. Copy the commands from the app so the path is right for your Mac: open **Settings › Advanced** and look under **AI assistants (MCP)**, or open the [API client](https://docs.subcloak.com/cloak-proxy/api-client/overview/) with <kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>M</kbd> (**File › MCP…**) and use the **Use Cloak Proxy from AI assistants** card.

(added in Cloak Proxy 0.5.1) **Settings › AI Assistants** has the same commands, and the [assistant scope](https://docs.subcloak.com/cloak-proxy/automation/assistant-scope/): limit what assistants see to one app, some hosts, a view or the requests you highlight.

*[Screenshot: The MCP page of the API client: a Connect to an MCP server card, and a Use Cloak Proxy from AI assistants card with Copy buttons for Claude Code and for Claude Desktop, Cursor and VS Code JSON, followed by the tool list grouped by area. The MCP page in the API client has copyable setup for each assistant and lists every tool.]*

**Claude Code**

Run this in Terminal:

```bash title="Terminal"
claude mcp add cloak-proxy -- "/Applications/Cloak Proxy.app/Contents/Resources/cloakctl" mcp
```

Then start `claude` and ask about your traffic. Run `claude mcp list` to check that `cloak-proxy` is connected.

**Claude Desktop**

Add the server to `~/Library/Application Support/Claude/claude_desktop_config.json`, then quit and reopen Claude Desktop:

```json title="claude_desktop_config.json"
{
  "mcpServers": {
    "cloak-proxy": {
      "command": "/Applications/Cloak Proxy.app/Contents/Resources/cloakctl",
      "args": ["mcp"]
    }
  }
}
```

If the file already has an `mcpServers` object, add the `cloak-proxy` entry inside it.

**Cursor**

Add the server to `.cursor/mcp.json` in your project, or to `~/.cursor/mcp.json` for every project:

```json title=".cursor/mcp.json"
{
  "mcpServers": {
    "cloak-proxy": {
      "command": "/Applications/Cloak Proxy.app/Contents/Resources/cloakctl",
      "args": ["mcp"]
    }
  }
}
```

**VS Code**

Add the server to `.vscode/mcp.json` in your project. VS Code uses a `servers` key and a `type`:

```json title=".vscode/mcp.json"
{
  "servers": {
    "cloak-proxy": {
      "type": "stdio",
      "command": "/Applications/Cloak Proxy.app/Contents/Resources/cloakctl",
      "args": ["mcp"]
    }
  }
}
```

**Other clients**

Any MCP client that can launch a local stdio server works. Give it:

| Setting | Value |
|---|---|
| Command | `/Applications/Cloak Proxy.app/Contents/Resources/cloakctl` |
| Arguments | `mcp` |
| Transport | stdio |

### Options

Add these after `mcp` in the command or `args`:

| Option | Use it when |
|---|---|
| `--port N` | The proxy listens on a port other than the one in the app's settings, for example a `cloakctl run --port 9091`. |
| `--workspace DIR` | The assistant should use a different API-client workspace folder than the app's, for example the one in your project's repository. |
| `--no-redact` (added in Cloak Proxy 0.4.0) | Tool results should include credentials as captured, whatever the app's setting. For CI jobs reading their own test traffic; see [Redact sensitive data before sending to AI](https://docs.subcloak.com/cloak-proxy/automation/agent-skills/#redact-sensitive-data-before-sending-to-ai). |
| `--app NAME` (added in Cloak Proxy 0.5.1) | This connection should only see one app's requests (repeat it for several). It narrows the [assistant scope](https://docs.subcloak.com/cloak-proxy/automation/assistant-scope/) set in the app; it can't widen it. |
| `--host HOST` (added in Cloak Proxy 0.5.1) | Only one host's, or `*.example.com`'s. |
| `--scope QUERY` (added in Cloak Proxy 0.5.1) | Only requests matching a [typed query](https://docs.subcloak.com/cloak-proxy/inspect/query-language/). |
| `--metadata-only` (added in Cloak Proxy 0.5.1) | Only metadata (method, URL, status, timing, sizes, headers), never bodies. |

```bash title="Terminal"
claude mcp add cloak-proxy -- "/Applications/Cloak Proxy.app/Contents/Resources/cloakctl" mcp --workspace ~/code/shop-api/api-workspace
```

### Teach your assistant with skills

(added in Cloak Proxy 0.4.0)

Install Cloak Proxy's [agent skills](https://docs.subcloak.com/cloak-proxy/automation/agent-skills/) so Claude Code, Codex and other agents know when to use these tools and in which order: **Agent skills** on the MCP page, or `cloakctl skills install claude`.

## Find the setup from anywhere

Press <kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>A</kbd> and type `mcp`. **MCP** opens the API client's MCP page, and **AI Assistants (MCP)** opens **Settings › Advanced**. (added in Cloak Proxy 0.5.1) **AI Assistants** opens the settings page with the assistant scope.

*[Screenshot: Search Everything with the query mcp: MCP in the API Client as the top hit, AI Assistants (MCP) under Settings › Advanced, and New MCP Request entries. Search Everything finds both places to set up the MCP server.]*

## What your assistant can do

The tools cover the whole app. Every one is listed with its arguments in the [MCP tools reference](https://docs.subcloak.com/cloak-proxy/automation/mcp-tools-reference/).

| Area | Examples of what you can ask |
|---|---|
| Captured traffic | "Why did the last checkout request fail?" "Compare request 41 with 52." "Replay request 12 with a different `Authorization` header." "Send request 12 twenty times, five at once, and summarize the statuses." "Generate TypeScript types from the response of request 30." "Which requests contain `fc68188e`?" "Where did this order ID come from, and which calls use it?" "Make a replayable flow from requests 40 to 44." "Which third parties receive ShopApp's users' data?" |
| Capture control | "Start capturing macOS traffic and decrypt `*.example.com`." "Pause recording." "Stop recording Mail's traffic." |
| Debugging tools | "Mock `GET /v1/users` to return an empty list." "Add a 2-second delay to `api.example.com`." "Block analytics hosts." "Turn on the Payment declined rule set." "Add an `X-Debug: 1` header to every request to `staging.example.com`, only from Safari." |
| Queries and highlights (added in Cloak Proxy 0.4.1) | "Show me ShopApp's server errors slower than a second." "Add an Order column with each response's `$.order.id`." "Color every request to the payments host red." |
| Sharing and the browser (added in Cloak Proxy 0.4.1) | "Share ShopApp's traffic with a colleague for an hour, without bodies." "Which tab and script sent request 52?" "Any console errors around the failing checkout?" |
| Breakpoints | "Pause the next login request and change the password field." "Break on the next request like 41." |
| Insights | "Are any secrets leaking in this traffic?" "Which endpoints are slowest?" |
| Authorization | "Replay ShopApp's requests as a user with this token and as no credentials, and list any endpoints that leak the original user's data." |
| Security testing (added in Cloak Proxy 0.5.1) | "Is `api.example.com/v2/admin` in scope?" "Which tokens never expire, and where were they sent?" "Run the passive API scan and add the IDOR candidates to the findings." "Did any tool result try to inject instructions into the agent?" "Plan a fuzz of the order id, without sending anything." See [Scope](https://docs.subcloak.com/cloak-proxy/security/scope/), [Findings and reports](https://docs.subcloak.com/cloak-proxy/security/findings/) and [AI security](https://docs.subcloak.com/cloak-proxy/security/ai-security/). |
| Releases and tests (added in Cloak Proxy 0.4.0) | "Compare ShopApp 2.3's traffic with 2.4's and list what changed." "Make a test suite from ShopApp's checkout requests and run it." |
| Streams, model calls and traces (added in Cloak Proxy 0.4.0) | "Show the events of the last chat stream and where it stalled." "What did the agent's model calls cost, and why did the prompt cache miss?" "Did the checkout request keep its trace ID through the API?" |
| Apps that ignore the proxy | "Why isn't my app's traffic showing up?" The assistant can suggest domains to capture and open the capture sheet for you to confirm. From 0.5.0: "Capture everything `deploy-tool` sends." It asks for [App Capture](https://docs.subcloak.com/cloak-proxy/capture/capture-apps-that-ignore-the-proxy/), and you click **Allow** in Cloak Proxy. (added in Cloak Proxy 0.5.0) |
| Setup (added in Cloak Proxy 0.4.0) | "Set up capture for ShopApp in the iOS Simulator." "Install the certificate on the Android emulator." "Where do the docs explain Map Remote?" |
| API client | "Write tests for the Login request and run them." "Run the Shop API collection against Staging." "Create an OpenAPI spec from this collection." "Commit the workspace." |

### Resources

Resources are read-only context an assistant can attach to a conversation.

| URI | What it contains |
|---|---|
| `cloak://status` | Port, recording, macOS capture and active tools. |
| `cloak://assistant-scope` (added in Cloak Proxy 0.5.1) | What the assistant scope lets the assistant see. |
| `cloak://requests/recent` | The last 100 captured requests. |
| `cloak://requests/{id}` | Headers and bodies of one request (a template: replace `{id}`). |
| `cloak://insights/report` | The Insights Markdown report. |
| `cloak://rules` | Every debugging tool and its rules. |
| `cloak://collections` | API client collections, requests and environments. |

### Prompts

Prompts are ready-made tasks. In clients that support them, they appear as slash commands or in a prompt menu.

| Prompt | Arguments | What it asks the assistant to do |
|---|---|---|
| `debug_request` | `id` (required) | Find out why a captured request failed, compare it with a successful one, and suggest or try a fix. |
| `mock_endpoint` | `id` (required), `change` | Make a Map Local rule from a request, change the response as described, and confirm by replaying. |
| `write_tests` | `collection`, `request` (both required) | Add `pm.test` assertions to a saved request, run it, and report. |
| `security_review` | None | Review leaked secrets, weak headers and risky cookies, with fixes. |
| `app_traffic_summary` | `app` (required) | Summarize one app's API calls, and check whether it bypasses the proxy. |
| `setup_capture` (added in Cloak Proxy 0.4.0) | `target` (required), `app` | Get an app's or device's traffic into Cloak Proxy step by step with `capture_setup`, then check it arrives. |

## Security

The MCP server gives an assistant the same power over Cloak Proxy that you have. Set it up knowing what that means.

- **It stays on your Mac.** The server is a local process. It talks to the app only on `127.0.0.1`, and the app's API refuses other machines.
- **It uses the API token.** The server reads the token from `~/Library/Application Support/CloakProxy/api-token`. Any program you let run `cloakctl mcp` can read your captured traffic. See [Control API](https://docs.subcloak.com/cloak-proxy/automation/control-api/#authenticate-with-the-token).
- **Captured data goes to your assistant's model.** When a tool returns a request, its headers and body become part of the conversation, which your assistant sends to its model provider. **Redact sensitive data before sending to AI**, on by default, replaces tokens, cookies, API keys, passwords and card numbers with `REDACTED` first; personal data such as names and emails still comes through. See [Redact sensitive data before sending to AI](https://docs.subcloak.com/cloak-proxy/automation/agent-skills/#redact-sensitive-data-before-sending-to-ai), and don't point an assistant at traffic you aren't allowed to share.
- **Team vault values aren't filled in.** (added in Cloak Proxy 0.7.0) MCP tools never get [team vault](https://docs.subcloak.com/cloak-proxy/team/vault/) values: a request an assistant sends that uses one isn't sent, with "Team vault values aren't filled in for MCP tools and AI assistants". Shared team MCP servers get their secrets through `cloakctl mcp-exec` when they start, never in an agent's config file. See [Shared agent setups](https://docs.subcloak.com/cloak-proxy/team/agent-setups/).
- **Keep it to the traffic you're working on.** (added in Cloak Proxy 0.5.1) The [assistant scope](https://docs.subcloak.com/cloak-proxy/automation/assistant-scope/) limits what every tool returns to the apps, hosts or requests you choose, with bodies or as metadata only. Other apps' requests stay out of the conversation, and the assistant can't change the scope.
- **Assistants are told to ask first.** The server's instructions tell the assistant to ask before deleting things or turning macOS capture off. Each tool is also marked read-only or destructive, so clients that support those hints can ask for confirmation. Tools are marked destructive when they delete something, change the Mac's or the app's settings, or share traffic: `clear_session`, `delete_rule`, `delete_extract_rule`, `delete_request`, `delete_collection`, `delete_variable`, `restore_deleted`, `import_session`, `set_macos_proxy`, `ssl_proxying`, `update_settings`, `set_tool_enabled`, `toxiproxy_api`, `install_certificate`, `git_commit`, `start_live_share`, `stop_live_share`, from 0.5.0, `set_app_capture` and, from 0.5.1, `update_scope`, `configure_ai_guard` and `add_finding`. Widening the scope, approving an MCP server's changed tools, loosening the AI Guard and saving a finding always wait for you to click in Cloak Proxy.
- **Some actions always need you.** Trusting or removing the certificate and capturing an app that ignores the proxy need your Mac password, so the assistant can only open the right screen for you to confirm. `capture_setup` marks these steps `needs_user`.
- **Lock assistants out when you need to.** (added in Cloak Proxy 0.4.0) With `cloakctl mcp off`, every tool call answers *MCP access to Cloak Proxy is turned off* until you run `cloakctl mcp on`. See [cloakctl](https://docs.subcloak.com/cloak-proxy/automation/cloakctl/#certificate-upstream-proxy-and-assistants).
- **Review tool calls.** Keep your client's approval prompts on for tools that change things, such as `update_settings`, `set_macos_proxy`, `upsert_rule` and `git_commit`.

> **Turn things back off:**
> Rules, SSL proxying hosts and settings an assistant creates stay until they're removed. When you're done, check **Tools** and **Settings**, or ask the assistant to list and undo its changes.

## Troubleshooting

| Problem | What to do |
|---|---|
| Traffic tools say "Couldn't reach Cloak Proxy on port 9090" | Open Cloak Proxy, or start `cloakctl run`. If the proxy uses another port, add `--port N` to the server command. |
| A tool says it "needs the Cloak Proxy app" | The proxy is `cloakctl run`, which only serves traffic tools. Open the app for the rest. |
| Collection tools don't see your collections | The server uses the app's workspace folder. If yours is elsewhere, add `--workspace DIR`. |
| The client doesn't list the server | Check the path to `cloakctl` (it contains a space, so it must be quoted in shell commands), then restart the client. |

## Related

  - [MCP tools reference](https://docs.subcloak.com/cloak-proxy/automation/mcp-tools-reference/): All 154 tools with arguments, plus resources and prompts.
  - [Limit what AI assistants can see](https://docs.subcloak.com/cloak-proxy/automation/assistant-scope/): Keep an assistant to one app, some hosts or the requests you highlight.
  - [Agent skills and setup tools](https://docs.subcloak.com/cloak-proxy/automation/agent-skills/): Skills for Claude Code and Codex, guided capture setup, docs search and redaction.
  - [Debug with Claude](https://docs.subcloak.com/cloak-proxy/guides/debug-with-claude/): A walkthrough of debugging an app with an AI assistant.
  - [MCP client](https://docs.subcloak.com/cloak-proxy/api-client/protocols/mcp/): Test other MCP servers from the API client.
  - [Security and privacy](https://docs.subcloak.com/cloak-proxy/reference/security-and-privacy/): What stays on your Mac and who can reach it.
