Metadata-Version: 2.5
Name: zscaler-dp-mcp
Version: 0.11.0
Summary: Unofficial MCP server for Zscaler Data Protection (ZIA DLP + Workflow Automation). Not affiliated with or supported by Zscaler.
Project-URL: Source, https://github.com/sarthakvit24-ux/zscaler-dp-mcp
Project-URL: Issues, https://github.com/sarthakvit24-ux/zscaler-dp-mcp/issues
Author: Sarthak Jain
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: data-protection,dlp,mcp,zia,zscaler,zwa
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security
Requires-Python: >=3.11
Requires-Dist: mcp<3,>=2.3
Requires-Dist: python-docx<2,>=1.1
Requires-Dist: python-dotenv>=1.0
Requires-Dist: truststore<1,>=0.10.4
Requires-Dist: zscaler-sdk-python<2,>=1.11.2
Description-Content-Type: text/markdown

# zscaler-dp-mcp: Data Protection MCP server for Zscaler (unofficial)

> **Unofficial community project.** Not affiliated with, endorsed by, or supported by Zscaler, Inc. "Zscaler" is a
> trademark of its owner and is used here only to describe compatibility. Use at your own risk, and try it on a
> non-production tenant first.

An [MCP](https://modelcontextprotocol.io) server that lets AI assistants (Claude Desktop, VS Code Copilot, Cursor,
Devin, ...) work with **Zscaler Data Protection**: ZIA DLP policy and Workflow Automation (ZWA) DLP incidents.

It covers all of Data Protection through one server, so you don't need to piece it together from other tools:

| Area | Read | Write (opt-in) |
|---|---|---|
| Web, CASB (SaaS API), Outbound Email and Endpoint DLP rules | ✓ | create / update / delete |
| DLP dictionaries, engines, notification templates, rule labels | ✓ | create / update / delete |
| Web DLP global options | ✓ | update |
| ICAP servers, incident receivers, C2C receivers, IDM, EDM, endpoint custom apps | ✓ | read-only by API |
| Endpoint application groups and resource groups, email recipient profiles | ✓ | read-only in v0.1 |
| ZIA activation | status | activate |
| ZWA incidents: search, details, triggers (masked), history, audit log | ✓ | notes, labels, close |
| Workflows: export / diff / audit / import (cross-tenant) / clone, incident digest | ✓ | import, clone |
| **Expert DLP review** by the bundled zscaler-dlp-practitioner skill: evidence-graded findings across Web, CASB, Email and Endpoint DLP, EDM/IDM, Cloud App Control, File Type Control and OCR, plus recorded ZWA incidents per rule (counts only; last 7 days by default), run locally; Word report; API access check | ✓ | – |
| Prompts: DLP review and adoption guidance, incident triage, tenant-context builder | ✓ | – |

## Simplest start: the Zscaler DLP hub

- Windows (PowerShell): `irm https://raw.githubusercontent.com/sarthakvit24-ux/zscaler-dp-mcp/main/install.ps1 | iex`
- macOS / Linux: `curl -LsSf https://raw.githubusercontent.com/sarthakvit24-ux/zscaler-dp-mcp/main/install.sh | sh`

This installs everything, creates a "Zscaler DLP hub" desktop shortcut and opens the hub in your browser: connect to
Zscaler (with an access check), add the tools to your AI apps with one click, or download the files for any chatbot.
Every change an AI app proposes is first returned as a preview (DLP rule, engine and dictionary changes include the
DLP practitioner's check) and applied only when the app repeats the call with the preview's token. Asking you in
between is up to the AI app: keep its approval prompt on for the write tools; auto-approving them removes that step.

## Use it with any AI chatbot (ChatGPT, Claude, Copilot, ...)

No plugins, MCP or AI keys needed:

1. Install once (see step 2 of the quick start below), then run `zscaler-dp-mcp hub`. A local **DLP Review page** opens
   in your browser: enter your Zscaler tenant and API client, check access (it tells you exactly which permission is
   missing), and click **Run review**.
2. Download the **practitioner instructions** and the **review file** from the page.
3. In your chatbot, upload the practitioner instructions (once, e.g. as project or GPT knowledge), then the review
   file, and ask: *"Review my DLP configuration and tell me what to look at first."*

The page only reads from your tenant and binds to 127.0.0.1; your API secret never goes into the chat. The chatbot
cannot change configuration: for changes it writes a change plan you apply in the admin portal or through the MCP
server below.

## Easiest with Claude Desktop: the extension (no command line)

1. Create the API client in ZIdentity (step 1 below).
2. Download `zscaler-dp-mcp-<version>.mcpb` from the latest GitHub release and double-click it. Claude Desktop shows
   an install dialog with a form: enter your tenant, client ID and secret (stored securely by Claude). Optional: ZWA
   key for incident tools.
3. Ask: *"Review my DLP configuration"*, then *"Give me the report"* for a Word document.

The extension is read-only: it pins configuration changes and incident actions off, even if setup or the hub allowed
them for your other AI apps. If something can't be read, ask *"Check my API access"*: it names the exact permission
to add in ZIdentity.

## Quick start for other apps (3 steps)

**1. Create an API client in ZIdentity** (about 5 minutes, in the browser)

In `https://<your-tenant>.zslogin.net`, go to **Integration → API Clients → Add**. Give it **ZIA** access with a DLP
role (read-only is fine to start), then copy the **Client ID** and **Secret**.
*Optional:* for incident tools, also create a key in the **Workflow Automation (ZWA) portal → API keys**.

**2. Install and run setup** — answer the questions it asks

**Windows**: open **PowerShell** and run these three lines, one at a time:
```powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```
```powershell
& "$env:USERPROFILE\.local\bin\uv.exe" tool install zscaler-dp-mcp
```
```powershell
& "$env:USERPROFILE\.local\bin\zscaler-dp-mcp.exe" setup
```

**macOS / Linux**: open **Terminal** and run:
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh && ~/.local/bin/uv tool install zscaler-dp-mcp && ~/.local/bin/zscaler-dp-mcp setup
```
(The macOS/Linux line does not work in PowerShell, and the Windows lines do not work in Terminal.)

Setup:
- asks for your tenant, Client ID and Secret (the secret is hidden as you type);
- **tests them against your tenant** before saving anything;
- saves them to a file in your user profile (on macOS and Linux readable only by you; on Windows the folder's
  normal permissions apply);
- asks how much the assistant may do (read-only by default; saved in the same file);
- adds the server to every AI app it finds: **Claude Desktop, Claude Code, Cursor, VS Code (Copilot), Devin**.

**3. Restart your AI app** and ask: *"List my Web DLP rules"*.

Something not working? Run `zscaler-dp-mcp doctor` (Windows: `& "$env:USERPROFILE\.local\bin\zscaler-dp-mcp.exe" doctor`). It checks the credentials, the connection to your tenant
and each AI app's configuration, and tells you how to fix anything that's wrong.

> **Install fails with a certificate error, "UnknownIssuer", or "401 Unauthorized" from a package proxy?**
> Your network inspects TLS or routes Python packages through a company proxy. Add `--system-certs` to the
> `uv tool install` command so uv trusts your company's root certificate. If a package proxy still refuses, either
> ask IT for its credentials or, **if your organisation allows it**, install straight from PyPI:
> `uv tool install --system-certs --default-index https://pypi.org/simple zscaler-dp-mcp`.
> After installation the AI app starts the installed program directly, so the proxy is not needed again.

**Updating:** `uv tool upgrade zscaler-dp-mcp` (add `--system-certs` if you needed it at install). On Windows, quit your
AI apps first so the program file isn't locked.

**SSL inspection:** the server verifies TLS with your operating system's certificate store, so it works behind
Zscaler SSL inspection without bypass rules or certificate files.

**More than one tenant?** Run setup once per tenant with a name: `zscaler-dp-mcp setup --profile lab`. Each
tenant appears as its own server (`zscaler-dp-lab`).

**Changing permissions later?** Rerun `zscaler-dp-mcp setup`, keep the saved credentials, and pick a different
option at the permissions step (pressing Enter keeps the current one), or use the **Changes** card in
`zscaler-dp-mcp hub`. Both write the same three settings (`ZDP_ENABLE_WRITES`, `ZDP_WRITE_TOOLS`,
`ZDP_ENABLE_ZWA_WRITES`) to the credentials file, which the server reads at every start: restart your AI apps
afterwards. An AI-app entry that still carries write flags or `ZDP_*` variables of its own (from setup before 0.11.0
or edited by hand) overrides the file; the hub warns about such entries, and re-adding the app in setup removes the
flags.

## Safety model

- **Read-only by default.** Write tools are not even registered unless you start the server with `--enable-writes`
  **and** an allowlist (`--write-tools`). ZWA incident changes need their own flag, `--enable-zwa-writes`.
- **Two-phase writes.** Every write first returns a **preview**: the exact payload and a field-by-field diff, plus a
  one-time `confirm_token`. Nothing changes until the same call is repeated with that token, and the token is rejected
  if the object changed in between. The token goes back to the same AI app, so the server can't tell whether you
  approved: that depends on the app's tool-approval prompt. Keep it on for the write tools; auto-approving them
  removes your approval step.
- **Practitioner check.** Changes to Web, CASB, Email and Endpoint DLP rules, engines and dictionaries (and policy
  imports) are simulated against the skill's checks; a change that introduces a potential flaw or detection gap needs
  an explicit `apply_anyway`. If the check can't run, the preview says so and the change is not blocked.
- **Partial updates are safe.** The ZIA API replaces whole objects on update; the server fetches the live object, merges
  your change and sends the full object, then reads it back and reports any field the API didn't apply.
- **Snapshots and audit log.** A JSON snapshot is saved before every update or delete of a DLP object (activation and
  incident notes, labels and closes have none), and every write is appended to `audit.jsonl` (see
  [State directory](#state-directory)).
- **No silent activation.** ZIA changes stay staged until you call `zia_activate`, which warns that activation pushes
  *every* pending change in the tenant.
- **Sensitive data masked.** ZWA trigger values (the matched strings) are masked unless you pass `--no-redact-triggers`.

## Manual configuration (advanced)

You don't need this if you used `setup`. Credentials can come from the file `setup` writes
(`~/.config/zscaler-dp-mcp/credentials.env`, or `%APPDATA%\zscaler-dp-mcp\credentials.env` on Windows), from
`--env-file <path>`, or from environment variables:

| Variable | Required | Where to get it |
|---|---|---|
| `ZSCALER_CLIENT_ID`, `ZSCALER_CLIENT_SECRET` | yes | ZIdentity → Integration → API Clients (ZIA access + DLP role) |
| `ZSCALER_VANITY_DOMAIN` | yes | The `<name>` in `https://<name>.zslogin.net` |
| `ZSCALER_CLOUD` | beta tenants only | e.g. `beta` |
| `ZWA_CLIENT_ID`, `ZWA_CLIENT_SECRET` | for incident tools | ZWA portal → API keys (separate from the ZIdentity client) |
| `ZWA_CLOUD` / `ZWA_URL` | if needed | Only if your ZWA API host isn't `https://api.us1.zsworkflow.net` |

MCP client entry (Claude Desktop, Cursor, Claude Code and Devin use `mcpServers`; VS Code uses `servers` and needs
`"type": "stdio"`). Use the full path to `uvx`, because desktop apps often don't inherit your shell's PATH:

```json
{
  "mcpServers": {
    "zscaler-dp": {
      "command": "/full/path/to/uvx",
      "args": ["zscaler-dp-mcp"]
    }
  }
}
```

To allow changes, prefer the credentials file (setup's permissions step or the hub's Changes card). Flags in `args`
also work and take priority over the file, for example
`"--enable-writes", "--write-tools", "update:web_dlp_rule,*:dictionary,activate"`. `--write-tools` takes
comma-separated globs over `action:kind` (`create`, `update`, `delete`, `import`, `activate`); `*` allows everything.

Docker: `docker run --rm -i --env-file ./zscaler.env ghcr.io/sarthakvit24-ux/zscaler-dp-mcp` (stdio).

### Shared HTTP deployment

```bash
ZDP_HTTP_TOKEN=$(openssl rand -hex 32) zscaler-dp-mcp --transport streamable-http --host 0.0.0.0 --port 8000 --env-file ...
```

Clients connect to `http://<host>:8000/mcp` with `Authorization: Bearer <token>`. Put it behind TLS.

## All options

| Flag | Env | Default |
|---|---|---|
| `--env-file` | `ZDP_ENV_FILE` | the file written by `setup` |
| `--profile` | `ZDP_PROFILE` | – (one saved tenant per profile) |
| `--toolsets` | `ZDP_TOOLSETS` | all: `web_dlp,casb_dlp,email_dlp,endpoint_dlp,resources,activation,zwa,workflows,review` |
| `--enable-writes` | `ZDP_ENABLE_WRITES` | off |
| `--write-tools` | `ZDP_WRITE_TOOLS` | – (required with writes) |
| `--enable-zwa-writes` | `ZDP_ENABLE_ZWA_WRITES` | off |
| `--no-redact-triggers` | `ZDP_REDACT_TRIGGERS=false` | redaction on |
| `--state-dir` | `ZDP_STATE_DIR` | `~/.zscaler-dp-mcp` |
| `--min-interval` | `ZDP_MIN_INTERVAL` | `1.0` s between API calls |
| `--transport` / `--host` / `--port` | `ZDP_TRANSPORT` / `ZDP_HOST` / `ZDP_PORT` | `stdio` / `127.0.0.1` / `8000` |
| – | `ZDP_HTTP_TOKEN` | required for HTTP |

## State directory

```
~/.zscaler-dp-mcp/
  exports/                 policy bundles (shared by every tenant on this machine, so you can import across tenants)
  reports/                 incident digests (HTML + CSV)
  <tenant>/snapshots/      object JSON saved before every update/delete
  <tenant>/audit.jsonl     one line per applied write: action, kind, target, outcome (ok / error / incomplete),
                           result status and ID, per-step results for imports; never credentials
```

## Example requests

- "List my Web DLP rules and tell me which ones block uploads to generative AI."
- "Disable the rule 'Block PCI to personal email'." *(shows a preview; you approve; then "activate")*
- "Review my DLP configuration and tell me what to look at first."
- "Copy all DLP rules from this tenant to the `lab` tenant, but leave them disabled."
- "Summarise yesterday's DLP incidents and triage the three newest high-severity ones."

## Documentation

- [docs/capabilities.md](docs/capabilities.md): what the server can do, tool by tool, with example requests
- [docs/tools.md](docs/tools.md): every tool, its arguments and what it returns
- [docs/safety.md](docs/safety.md): the write model in detail
- [API limits](src/zdp_mcp/prompts/api_limits.md): API behaviours and what is read-only

## Development

```bash
uv sync --group dev
uv run pytest                        # unit tests (no tenant needed)
uv run ruff check src tests && uv run mypy src
ZDP_ENV_FILE=~/lab.env uv run pytest tests/integration -m integration -s          # live reads
ZDP_ENV_FILE=~/lab.env ZDP_LIVE_WRITES=1 uv run pytest tests/integration -m integration -s   # + self-cleaning writes
```

## License

Apache-2.0
