# enterprise/

Source-available modules licensed under the **Functional Source License,
Version 1.1, Apache 2.0 Future License** (`FSL-1.1-Apache-2.0`) — see
[`LICENSE`](./LICENSE). Each file converts to Apache-2.0 two years after it is
made available.

This directory is **not** part of the open-source distribution:

- It lives outside `mcp-server/`, whose npm package only publishes
  `["dist","config"]`, so it is never in the published tarball.
- The container build context is `./mcp-server`, so it is never in the
  Docker image.

The Apache-2.0 core in `mcp-server/` runs fully standalone without anything
here. These modules are optional and load only when explicitly wired in by an
operator.

## Modules

| Module | What it does |
|--------|--------------|
| [`rbac/`](./rbac) | Role-based access control: a pure policy evaluator + an enforcement guard that maps a request's principal/roles to an allow/deny decision over tools, sources, and services. Default-deny. |
| [`catalog/`](./catalog) | Governed product catalog: publish named **products** (curated bundles of sources/services/tools) and **grants** of products to principals; pure evaluator + enforcement guard. Default-deny. Composes with `rbac/` (both must allow). |
| [`audit/`](./audit) | Append-only, tamper-evident audit log: hash-chained access-control decisions and tool invocations; `verifyChain` detects any modification, reorder, insertion or mid-log truncation. Sink-injected (file/SIEM), dependency-free (`node:crypto`). |
| [`entitlement/`](./entitlement) | Ed25519-signed entitlement tokens: an issuer signs `{ sub, tier, features, iat, exp }`; the deployment verifies offline and gates feature activation. Default-deny on any structural/signature/expiry failure. Dependency-free (`node:crypto`). |

## Integration contract

These modules are dependency-free ESM, duck-typed against the core
`RequestContext` shape (`{ principalId, auth, allowedSources?, ... }`) so the
Apache core never imports FSL code. The core wires them at the context seam
(`mcp-server/src/enterprise-gate.ts`) behind a signed entitlement token —
**off by default**. Operators do not call these directly; see the
[**enterprise gate operator guide**](../docs/enterprise-gate.md) for setup
(keypair, token minting, env vars, the three gate modes).

## Tooling & examples

- [`entitlement/mint.mjs`](./entitlement/mint.mjs) — issuer CLI to mint a
  signed token: `node enterprise/entitlement/mint.mjs --key priv.pem
  --sub org --features access-control,audit --ttl 365d`
- [`examples/rbac-policy.json`](./examples/rbac-policy.json) and
  [`examples/catalog.json`](./examples/catalog.json) — working configs,
  exercised by `examples/examples.test.mjs` so they cannot drift from the docs.

## Tests

```
node --test enterprise/*/*.test.mjs
```
