# Packages

Install shared Ferrite source into an application with ferrite add: resolution, signature and digest checks, MCP usage without a shell, and the published package catalog.

A deployable Ferrite application declares one Cargo dependency, `ferrite-app`,
and the platform source gate rejects any other entry in `[dependencies]`,
including local path dependencies. Shared functionality therefore ships as Rust
source instead of Cargo crates: `ferrite add` copies a package's source tree
into your app's `src/` directory, where it compiles inside your crate, runs
with your app's handles and no others, and passes the same source gate as code
you wrote. See [the one-dependency rule](/kb/guide/one-dependency-rule-explained/)
for why this boundary exists.

## Add a package

Run `ferrite add` from your app directory (or pass `--dir`), then declare the
printed modules at your crate root:

```bash
ferrite add mcp
```

```rust filename="src/lib.rs"
pub mod crypto;
pub mod mcp;
```

The CLI runs six steps in order and writes nothing to disk unless every step
succeeds:

1. It loads the package index from `https://packages.<base>/registry.json`,
   where `<base>` comes from your active MCP login (`https://mcp.<base>/mcp`),
   so each app installs from its active installation's registry. Before signing
   in, `ferrite add` exits with
   `Select a Ferrite instance first or pass --registry`; pass
   `--registry https://packages.ferrite.cloud/registry.json` to target Ferrite
   Cloud directly. Use `--registry <url>` for another remote index, or
   `--path <dir>` for a local checkout containing `packages/registry.json`. The
   CLI caches the index in its config directory so an offline run still
   resolves from the last seen index and reports its age (fetching package
   files still requires network access). Any index whose serial is lower than
   one already seen is rejected as a downgrade.

   For URL indexes, the CLI verifies the detached Ed25519 signature at
   `registry.json.sig`. `packages.ferrite.cloud` and other Ferrite installation
   package hosts are checked against the public key compiled into the CLI. For
   any other registry, pass its trusted public keys in
   `FERRITE_REGISTRY_KEYS=ed25519:<base64>[,...]`. Unsigned indexes and
   untrusted signers are rejected. When no key is trusted for a third-party
   registry, `--allow-unsigned-registry` installs on file digests alone and
   prints a notice; once a key is trusted for that registry, the flag has no
   effect. A failed signature check is always rejected. Local `--path`
   checkouts skip signature verification.
2. It resolves the requested package and its transitive dependencies. Running
   `ferrite add mcp` also installs `sha256-hmac`, which is why the crate root
   above declares both `crypto` and `mcp`.
3. It downloads each listed file and checks it against the SHA-256 digest in
   the index. One mismatched byte aborts the entire install.
4. It maps each file under `src/<mount>/`, using the package's declared root
   unless `ferrite-packages.json` already specifies another (for example,
   `sha256-hmac` mounts under `src/crypto/`). Each `.rs` file receives a
   `@generated by ferrite-pkg` header with its package name and version, and
   inline `#[cfg(test)] mod name { ... }` blocks are stripped because they test
   package internals. Separate test files shipped by a package (`auth`,
   `ferrite-sso`, `preview-gate`, and `agent-sdk`) stay installed and run under
   `ferrite test`.
5. It refuses to overwrite any existing file whose contents differ and lists
   the conflicting paths, unless you pass `--force`.
6. It writes all files, records the requested package's mount in
   `ferrite-packages.json`, and prints the crate-root lines you need: the
   `pub mod` declarations, plus `extern crate alloc;` for packages written
   against `alloc::` paths (`wasm-runtime`, `qjs-engine`, and `serde-codec`).
   Any package that declares Cargo features also outputs a `[features]` block
   (none in the current registry does). After `ferrite add auth`, the CLI also
   prints the sign-in setup, including the secrets `auth` reads along with your
   app's public origin and OAuth callback URLs so you can configure them before
   your first deploy.

`ferrite add` runs on Linux and macOS; on other operating systems it stops
before reading or writing anything.

Treat vendored files as generated source. Do not edit files carrying the
`@generated by ferrite-pkg` header: the next `ferrite add` flags edits as
conflicts, and `ferrite add --force <name>` replaces them. To upgrade to a
newer version, run `ferrite add --force <name>`.

## Use a package without a shell

An agent connected only to the Ferrite MCP server, with no shell to run
`ferrite add`, can inspect and include packages through MCP where the platform
serves those tools. Ferrite Cloud serves all three capabilities; on another
installation, check `tools/list` for `list_packages` and `read_package`, and
check the `deploy_source` schema for a `packages` property.

- `list_packages` lists published packages; passing `query` filters to packages
  whose name, summary, or guide contains every word.
- `read_package {"name": "<name>"}` returns the package guide, its files as
  installed in your app, its dependencies in install order, and the required
  crate-root lines. Guides longer than 24,000 bytes are truncated with
  instructions for reading the rest. Passing `file` returns one file in chunks
  of up to 60,000 bytes; send the returned `next_offset` back as `offset` to
  continue. For `auth`, the setup guide points to `app_host` so you have your
  app's origin and OAuth callbacks before the first deploy.
- Pass package names in the `packages` argument of `code_gate`, `deploy_source`,
  or `rcs_commit`:

```json
{
  "spec": "<the InfraSpec JSON>",
  "files": {
    "Cargo.toml": "...",
    "src/main.rs": "pub mod crypto;\n..."
  },
  "packages": ["sha256-hmac"]
}
```

Before the gate or build reads `files`, the server injects each named package
and its dependencies under `src/<root>/`, byte-for-byte identical to
`ferrite add`, so your request sends only your own files. If you also send a
package file in `files`, the server accepts an exact match and rejects any
difference. Pin a specific release with `"name@version"`; versions the server
does not carry are rejected. If your files plus the requested packages exceed
the MCP request body budget, the call fails and you need to name fewer
packages. The reply lists the injected packages beside the verdict on
`code_gate` and inside `BuildStarted` on `deploy_source`.

On an installation without these MCP tools, you can bundle a package yourself:
read `https://packages.<base>/registry.json` for each package's `root`,
dependencies, and file SHA-256 digests, download each file from
`https://packages.<base>/<package>/src/<path>`, verify every digest, place the
package and its dependencies under `src/<root>/`, and include them in `files`.
Whenever a shell is available, `ferrite add` is simpler because it checks
signatures, adds provenance headers, and prints the crate-root lines.

Running `ferrite add ferrite-auth` fails with a message pointing to `auth`.
Ferrite Core has no platform-managed sign-in service; application sign-in comes
from the `auth` package.

## Sign-in and sessions

| Package | Mounts at | Also installs | Use it for |
| --- | --- | --- | --- |
| `auth` | `src/auth/` | none | Sign-in for your app: OAuth authorization-code flow with PKCE over your declared egress handle (each call made and recorded by the platform), opaque store-backed sessions, one `__Host-` cookie, and a CSRF gate. See [Authentication](/developers/authentication/) |
| `alloy-auth` | `src/alloy_auth/` | `alloy`, `http-change-password`, `http-cookies`, `sha256-hmac` | Password sessions for an [Alloy](/developers/alloy/) app: PBKDF2 records, store-backed sessions, host-only session cookies, and session-bound CSRF so audited mutations record a server-verified actor |
| `ferrite-sso` | `src/ferrite_sso/` | `http-change-password`, `http-cookies`, `sha256-hmac` | Single sign-on across properties run by one operator: a broker app built on `auth` issues short-lived, audience-bound, single-use assertions, and each client verifies them to mint its own session. Because clients share an assertion key with the broker, use it only across properties run by one operator; use `auth` for an independent app |
| `http-cookies` | `src/http_cookies/` | none | `__Host-` session cookie constructor and reader that composes the prefix, root path, `Secure` flag, and absent `Domain` in one constructor |
| `http-change-password` | `src/http_change_password/` | none | `/.well-known/change-password` handler that redirects to a password page your app serves, or answers `404` when none is served |
| `preview-gate` | `src/preview_gate/` | `http-cookies`, `sha256-hmac` | Not for application authors. Ferrite's own sign-in broker mounts it beside `auth` to restrict operator-run hosts to an identity allowlist; `ferrite.cloud` hosts are configured for public access |

## Application frameworks

| Package | Mounts at | Also installs | Use it for |
| --- | --- | --- | --- |
| `alloy` | `src/alloy/` | `sha256-hmac` | The [Alloy](/developers/alloy/) runtime: route matching, tag-epoch cache, replay-safe actions, document assembly, and packed asset archives. `ferrite new alloy` scaffolds an app with it mounted |
| `rsx` | `src/rsx/` | none | Runtime layer for [Rsx](/developers/rsx/): escape-safe HTML, file-convention router, and ingress server. `ferrite rsx new` writes it from the CLI bundle |
| `nitro` | `src/nitro/` | `sha256-hmac` | Nitro server toolkit in constrained Rust: routing, route rules, storage over Ferrite primitives, cached handlers, and the ingress adapter behind [TanStack Start](/developers/tanstack-start/) apps |

## Agents and protocols

| Package | Mounts at | Also installs | Use it for |
| --- | --- | --- | --- |
| `agent-sdk` | `src/agent_sdk/` | `acp`, `http-query`, `mcp`, `regex-lite`, `sha256-hmac` | The [Agent SDK](/developers/agent-sdk/). Keeps your product's agent inside your application so it deploys and rolls back with the app, stores conversations in the app's own bindings, and obeys the same `ferrite.json` manifest. Compose hooks, tools, skills, and subagents in one function with session recovery and compaction, served over the thread API, MCP, ACP, and A2A |
| `agent-ready` | `src/agent_ready/` | `http-change-password`, `http-query`, `sha256-hmac` | Exposes your app to customers' assistants from one declared surface: `robots.txt`, `sitemap.xml`, `llms.txt`, Markdown page twins, an OpenAPI catalog, an A2A agent card, a stateless MCP server, RFC 9457 errors, and opt-in [Personal Agent Protocol (Poppy 1.0)](/developers/personal-agent-protocol/) discovery, exposure controls, exact-terms approvals, Browser Join, and conversations |
| `poppy-oauth` | `src/poppy_oauth/` | `agent-ready`, `http-query`, `sha256-hmac` | Standalone per-app OAuth 2.1 issuer for [Personal Agent Protocol (Poppy 1.0)](/developers/poppy-oauth/): RFC 8414 metadata, PAR, PKCE `S256`, `private_key_jwt`, multi-resource RFC 8707 refresh tokens, optional DPoP, immediate RFC 7009 revocation, and a Connected Personal Agents settings page |
| `mcp` | `src/mcp/` | `sha256-hmac` | Model Context Protocol revision `2026-07-28`: wire protocol, stateless client, resource-server shell, and OAuth 2.1 authorization |
| `acp` | `src/acp/` | none | Agent Client Protocol v1: JSON-RPC wire model, agent and client roles, session lifecycle, and HTTP, SSE, and WebSocket bindings |
| `ferrite-ai` | `src/ai/` | none | Responses API request, response, item, and stream-event types spoken by the [AI Gateway](/developers/ai-gateway/) |
| `ai-budgets` | `src/ai_budgets/` | none | AI attribution per user, team, or workspace, reserve-and-settle allowance counters, and policy that routes autonomous runs to cheaper models |
| `gpt-plugins` | `src/gpt_plugins/` | `sha256-hmac` | OpenAI plugin kit on Ferrite: an MCP server for ChatGPT and Codex with optional UI (MCP Apps), OpenAI MCP extensions, skills, MCP Events, checkout, and submission packaging. Its stylesheet derives from Apache-2.0 code, so it also installs `LICENSES/Apache-2.0.txt` and `NOTICE` with your app |

## Connectors and grants

| Package | Mounts at | Also installs | Use it for |
| --- | --- | --- | --- |
| `gatekeeper` | `src/gatekeeper/` | none | Connector contract: scoped grants, observation audit, approvals with simulated outcomes, bounded catalogs, and schedules that stay inactive on registration and re-verify admission on every delivery |
| `connector-github` | `src/connector_github/` | `gatekeeper` | GitHub connector on the `gatekeeper` contract; your app implements the live backend trait over its own egress |
| `connector-google` | `src/connector_google/` | `gatekeeper` | Google Docs, Sheets, and Drive folders on the `gatekeeper` contract, with connector-owned OAuth |
| `context-library` | `src/context_library/` | `gatekeeper` | Public or private collections of documents and `SKILL.md` skills, searchable and expandable as slash commands |
| `blueprints` | `src/blueprints/` | `gatekeeper` | Sharing a surface's code and binding requirements without its state or credentials, with hashed share keys and revocable permissions |

## Commerce and messaging

| Package | Mounts at | Also installs | Use it for |
| --- | --- | --- | --- |
| `payments` | `src/payments/` | `agent-ready`, `http-change-password`, `http-query`, `sha256-hmac` | Customer billing: Stripe request builders, signed webhook verification, an idempotent event-admission ledger, dunning schedules, and the x402 header path |
| `messaging` | `src/messaging/` | none | Transactional email and chat: request builders for Resend, Postmark (single sends, batches of up to 500 messages, and broadcast stream type, suppression, and delivery-count readers), Telegram Bot API, and Cloudflare Email Sending, plus a Markdown email renderer that cannot emit active content and retry classification |

## HTTP, text, and data

| Package | Mounts at | Also installs | Use it for |
| --- | --- | --- | --- |
| `http-query` | `src/http_query/` | none | Total query-string decoder for `IngressRequest.path`, which arrives verbatim as `path?query` |
| `http-route-budget` | `src/http_route_budget/` | none | Admits each request against its matched route's token bucket kept in a store your app already binds, before the handler runs any effect. See [Rate limits](/developers/rate-limits/) |
| `regex-lite` | `src/regex_lite/` | none | Panic-free, step-bounded regular expressions for apps without access to the `regex` crate |
| `crdt-text` | `src/crdt/` | none | Sequence CRDT for collaborative plain text and Markdown with server-side merge, tombstone deletes, and idempotent re-apply (not Yjs-compatible) |
| `sha256-hmac` | `src/crypto/` | none | SHA-256, HMAC-SHA-256, constant-time comparison, hex encoding, PBKDF2 password records, and OS entropy over `ferrite_app::crypto` |
| `serde-codec` | `src/codec/` | none | Compact binary serde codec for embedding precompiled WebAssembly modules in app source |
| `chronicle-sync` | `src/chronicle_sync/` | none | Wire protocol shared by a workspace authority and a sandbox leaf: bounded binary codecs, frame headers, message bodies, workspace-relative paths, SHA-256 hashing, manifest models, and sequence tracking using safe Rust and `std` only |

## Engines

| Package | Mounts at | Also installs | Use it for |
| --- | --- | --- | --- |
| `wasm-runtime` | `src/wasm/` | none | In-app WebAssembly interpreter: runtime store and stack interpreter over pre-parsed modules (derived from `tinywasm`, MIT OR Apache-2.0) |
| `qjs-engine` | `src/qjs/` | `serde-codec`, `wasm-runtime` | Fuel-bounded QuickJS on `wasm-runtime` to run JavaScript and TypeScript snippets with deterministic-replay host calls |

## Application-specific

The registry also publishes packages scoped to specific reference apps; they
are not general-purpose building blocks:

| Package | Mounts at | Also installs | Use it for |
| --- | --- | --- | --- |
| `bookshelf` | `src/bookshelf/` | none | The Goodreads catalog contract shared by NextBooks and its importer |

## Security shape

A package has no deployment, bindings, credentials, or resources of its own.
Everything it does at runtime runs through the handles your `ferrite.json`
grants the host app, which is why provider packages such as `auth` and
`messaging` require you to declare egress destinations and secrets yourself.
When a subsystem needs its own failure, scaling, or authority boundary, deploy
it as a separate Ferrite app instead of vendoring a package.

Because vendored source compiles into your crate, its code shares every handle
your application holds. It can read any secret injected into the app and call
any destination declared in `ferrite.json`, beyond the ones its guide asks
for. A secret is set once and is never returned by a read; the running
application receives its value and can call out only to declared destinations.
Read a package's files before adding it, the same way you review code you wrote.
See [What this does not stop](/developers/secrets-egress/#what-this-does-not-stop)
for what code holding a secret can still do with it.
