Metadata-Version: 2.4
Name: maskflare-mcp
Version: 0.1.1
Summary: Maskflare admin MCP server - ask an assistant about your organization's devices, traffic, masking rules and audit trail.
Keywords: maskflare,mcp,model context protocol,dlp,admin
Author: Maskflare
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Requires-Dist: httpx>=0.27,<1
Requires-Dist: mcp>=2.3,<3
Requires-Dist: pyjwt[crypto]>=2.8,<3
Requires-Python: >=3.12
Project-URL: Homepage, https://maskflare.com
Project-URL: Repository, https://github.com/maskflare/maskflare-mcp-server
Project-URL: Changelog, https://github.com/maskflare/maskflare-mcp-server/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/maskflare/maskflare-mcp-server/issues
Description-Content-Type: text/markdown

# Maskflare admin MCP server

Ask an assistant (Claude Code, Claude Desktop, Cursor, any MCP client) about your Maskflare organization: which devices are unprotected, how much traffic was blocked this week, which masking rules are on, what changed in the audit trail.

It talks to the [Maskflare platform API](https://api.maskflare.com/api/platform/v1/openapi.json) as an **API client**, so it sees exactly one organization with that client's role.

- **Read-only by default.** Write tools are offered only when you list them (`MASKFLARE_MCP_WRITE_TOOLS`). A tool you don't list is never shown to the model.
- **Rule changes are proposals.** Changes to masking rules, packs and modes become pending changes that a *person* approves in the console. An API client can't approve them, and neither can whoever holds its credentials.
- **Deletes need confirmation.** A delete runs only on a second call with the one-time code the first call returned. The code is valid for 5 minutes, works once, and only for the same target.
- **Audited.** Every call is logged as one JSON line: time, tool, read/write/delete, target ids and outcome. Argument values are not logged, so preview text never reaches the log. The platform keeps its own audit trail of every change too.

## Tools

| Read (always) | Write (opt-in, `MASKFLARE_MCP_WRITE_TOOLS`) |
| --- | --- |
| `whoami`, `get_organization` | `propose_rule_pack`: turn a detector pack on or off (proposal) |
| `get_traffic_usage`: requests, success rate, blocked, p95 latency, tokens | `propose_rule_update`: enable or disable a rule, change its action or mode (proposal) |
| `list_devices`: endpoint agents and their protection state | `set_browser_dlp_apps`: which AI web apps browser DLP inspects |
| `list_masking_rules`, `list_rule_packs`, `get_masking_scope`, `get_volume_thresholds` | `revoke_device` (confirmed) |
| `list_rule_changes`, `list_change_sets`: the approvals inbox | `revoke_api_key` (confirmed) |
| `get_masking_settings`, `get_browser_dlp`, `list_mcp_servers` | `revoke_enrollment_token` (confirmed) |
| `list_api_keys`, `list_enrollment_tokens`: metadata only, never secrets | `delete_mcp_server` (confirmed) |
| `list_audit_events` | |
| `preview_masking`: mask sample text with an environment's rules and explain each match | |

What a tool may do is also limited by the API client's role. An `auditor` client reads, a `security` client can propose rule changes, and only `admin` can revoke API keys.

## Set up

1. In the Maskflare console, open **Settings > API clients** and create a client. Choose the role it should have, for example `auditor` for a read-only assistant, and how it authenticates: a client secret (shown once), or a private key - generate one (`openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out maskflare-mcp.pem`, then `openssl pkey -in maskflare-mcp.pem -pubout`) and paste only the public key. Note the client id and token URL.
2. Run the server:

```bash
uvx maskflare-mcp            # stdio
uvx maskflare-mcp --transport http --host 127.0.0.1 --port 8765   # streamable HTTP at /mcp
```

Configuration, from the environment:

| Variable | |
| --- | --- |
| `MASKFLARE_CLIENT_ID` | The API client's id. |
| `MASKFLARE_CLIENT_SECRET` or `MASKFLARE_CLIENT_PRIVATE_KEY_FILE` | How it authenticates: its secret, or (better) the PEM private key whose public key the client was created with. With a key (`private_key_jwt`), each token request carries a 60-second assertion signed with it (RS256, or ES256/384/512 by curve) and no shared secret exists anywhere. |
| `MASKFLARE_TOKEN_URL` | The token URL shown when the client was created. |
| `MASKFLARE_API_URL` | Default `https://api.maskflare.com/api/platform/v1` (self-hosted: your gateway's `/api/platform/v1`). |
| `MASKFLARE_MCP_WRITE_TOOLS` | Comma-separated write tools to offer, or `all`. Empty (default): read-only. An unknown name stops the server. |
| `MASKFLARE_MCP_AUDIT_LOG` | File to append the audit log to. Default: stderr. |

### Claude Code

```text
/plugin marketplace add maskflare/maskflare-mcp-server
/plugin install maskflare-admin@maskflare-mcp
```

The plugin asks for the client id, secret, token URL and API URL, plus any write tools to enable. The secret is stored in your OS keychain.

### Other clients

```json
{
  "mcpServers": {
    "maskflare": {
      "command": "uvx",
      "args": ["maskflare-mcp"],
      "env": {
        "MASKFLARE_CLIENT_ID": "maskflare-client-...",
        "MASKFLARE_CLIENT_SECRET": "...",
        "MASKFLARE_TOKEN_URL": "https://id.maskflare.com/realms/maskflare/protocol/openid-connect/token"
      }
    }
  }
}
```

## Notes

- **HTTP transport:** it binds to `127.0.0.1` by default and has no authentication of its own. Anyone who can reach it acts with the API client's role, so don't expose it beyond the machine without a proxy that authenticates.
- **Rate limits:** the API allows each client 600 requests a minute by default. A refused call returns the `Retry-After` the API sent.
- **Credentials:** the client's token is cached in memory and renewed shortly before it expires. When a client is rotated or revoked, the next call gets a new token or fails with `api_client_inactive`.

## Development

```bash
uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check . && uv run pyright
```

## Versioning and releases

The package follows [Semantic Versioning](https://semver.org). Until 1.0, a minor version may
change the tools or their arguments; every change is listed in [CHANGELOG.md](CHANGELOG.md).
Releases are published to PyPI from a `vX.Y.Z` tag.

Other Maskflare packages: the Python SDK [`maskflare`](https://github.com/maskflare/maskflare-sdk-python)
and the TypeScript SDK [`@maskflare/sdk`](https://github.com/maskflare/maskflare-sdk-js).

## License

MIT
