> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usecontextlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resources

> The connections, databases and secrets that a slate's app and agents declare in slate.json, and how owner and viewer mode select who supplies each one.

A slate declares the resources its app and agents need. ContextLayer resolves those declarations into resources when the code runs.

| Resource | What it provides | How you refer to it |
| - | - | - |
| **Connection** | Access to a provider's tools through a connected account. | A slug such as `work-email`. |
| **Database** | Persistent SQLite storage for the slate's data. | A slug such as `notes`. |
| **Secret** | A named value, such as a model provider's API key, for trusted execution. | A name such as `ANTHROPIC_API_KEY`. |

The declaration says what is required. Account assignments, secret values, and stored database contents are separate from the declaration and stay out of Git.

## Declarations

The app and each agent declare their own resource requirements in a file called `slate.json`. MCP tools use the same declaration format, with their resource collections currently required to remain empty:

| Consumer | Declaration |
| - | - |
| The app | `public/slate.json` |
| An agent | `agents/<name>/slate.json` |
| An MCP | `mcp/<name>/slate.json` |

Every declaration uses the same schema. For example, this `digest` agent needs a viewer's Gmail account, a shared notes database, and an API key supplied by the slate's Owner:

```json agents/digest/slate.json theme={null}
{
  "connections": {
    "work-email": {
      "toolkit": "gmail",
      "mode": "viewer"
    }
  },
  "databases": {
    "notes": {
      "mode": "owner"
    }
  },
  "secrets": {
    "ANTHROPIC_API_KEY": {
      "mode": "owner"
    }
  }
}
```

`connections` and `databases` are keyed by slug, and `secrets` by name. Every entry declares a `mode`, and a connection also declares its toolkit. `connections` is required, even when empty; `databases` and `secrets` can be left out. A declaration never contains account IDs, database locations or secret values.

> [!NOTE]
>
> MCP declarations must currently leave all three collections empty. Resource execution is implemented for the app and agents.

## Each consumer declares what it uses

A **consumer** is the app or named agent using a resource. It can use only the resources in its own declaration. An agent does not inherit the app's requirements, and declaring a resource for one agent does not expose it to another. If the app and an agent both need `notes`, both must declare `notes`. A tool call or query for an undeclared slug fails with `not-declared`.

## One namespace per kind

All declarations in one slate share a namespace per resource kind. Reusing a key names the same logical resource. For example, the app and `digest` agent can both declare the owner-mode `notes` database and work with the same rows.

Resource ownership still matters. Two consumers selecting the same slug and Owner use the same database or connection assignment. Two people using a viewer-mode resource select their own databases or account assignments. A matching slug does not merge their resources.

Repeated declarations must agree. Connections must agree on toolkit and mode; databases and secrets must agree on mode. A disagreement is a validation error, and no declaration takes precedence over another.

## Owner mode and viewer mode

Each entry's `mode` is `"owner"` or `"viewer"`. In a hosted slate, the mode selects the Owner who supplies the resource.

* **Owner mode.** The slate's Owner, the user or organization that owns the slate, supplies the resource, and viewers share it. Viewing alone grants no permission to manage the Owner's accounts or secrets.
* **Viewer mode.** Each viewer supplies their own, as their personal Owner.

| Resource | Owner mode | Viewer mode |
| - | - | - |
| Connection | One account of the slate's Owner | Each viewer's own account |
| Database | One database, shared by everyone | One database per slate member |
| Secret | The slate Owner's value | Each viewer's own value |

Assigning an owner-mode connection or saving an owner-mode secret requires authority over the slate's Owner: being the owning user or a member of the owning organization. Each viewer configures their own viewer-mode connections and secrets. Databases need no account assignment or database picker: declare the database and author its migrations, and ContextLayer selects and provisions its storage.

### Viewer setup and scheduled work

Viewer-mode resources require a signed-in person on a private slate. Once setup for the whole slate is complete—every app and agent connection is assigned, and every viewer-mode secret is supplied—ContextLayer establishes that person's [slate membership](https://docs.usecontextlayer.com/core-concepts/owners-and-viewers.md#slate-members) through a setup change or first viewer-mode use. It then provisions their databases and schedules. No separate join step is needed. A public slate has no members and cannot use viewer-mode resources. A job acting for the app also has no person from whom to select a viewer-mode resource.

An agent's own modes also determine who its scheduled runs act for. If the agent requires any viewer-mode resource, its schedules run for slate members. If it requires none, they run once for the app. In the `digest` example above, the viewer-mode Gmail connection makes scheduled jobs member-scoped, even though the notes database and API key use owner mode.

In local development, modes select no Owner. A checkout uses the developer's personal accounts for every connection, environment variables for secrets, and local databases. The declared modes apply when the slate runs hosted.

## Hosted and local configuration

ContextLayer prepares hosted resource configuration from declarations in the latest commit on the slate's `main` branch. The deployed app is not the source of those declarations. Configure account assignments and supply secrets through the [chrome](https://docs.usecontextlayer.com/core-concepts/slate#the-chrome), the CLI, or the slate resource API, such as [List declared resources and their configuration](https://docs.usecontextlayer.com/api-reference/slate-resources/list-declared-resources-and-their-configuration.md). Before the first push to `main`, there are no hosted declarations to configure.

A checkout reads its declarations from disk. Its account assignments and database state live under the ignored `.contextlayer/` directory, and its secret values come from environment variables. Local configuration does not change hosted configuration. Restart `pnpm dev` after changing declarations or local configuration so startup can prepare the new values.

| Input | Local development | Hosted execution |
| - | - | - |
| Declarations | Files in the current checkout. | Committed declarations from `main`. |
| Connection assignments | The checkout's `.contextlayer/connections.json`. | Assignments saved in ContextLayer for the selected Owner. |
| Database data | The checkout's `.contextlayer/databases/` storage. | Platform-selected storage for the slate, Owner, and database slug. |
| Secret values | Environment variables on the developer's machine. | Stored values for the selected Owner and secret name. |

Pushing code and declarations does not upload local database contents, account assignments, or environment values.

## Resource kinds

> **[Connections and assignments](https://docs.usecontextlayer.com/core-concepts/resources/connections-and-assignments.md)**
>
> Declare a provider's toolkit by slug and map it to a connected account.

> **[Databases](https://docs.usecontextlayer.com/core-concepts/resources/databases.md)**
>
> Declared SQLite databases with authored Kysely migrations.

> **[Secrets](https://docs.usecontextlayer.com/core-concepts/resources/secrets.md)**
>
> Named values that belong to an Owner and are supplied separately from source code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.