A `plugin` source mounts any store that has no built-in kind: a third-party memory service, a folder of team notes, an internal API. You write a small program that answers the [plugin protocol](/docs/user-guide/stash/reference/plugin-protocol/index.md), and Stash runs it. The agent sees the store as files, the same as any other source.

## What the agent sees

The source shows at `plugin/NAME/`. The plugin chooses the folder, the file name, and the text of each record:

```text
/tmp/ops-context/plugin/oncall-notes/
  checkout/handoff-2026-11-21.md
  payments/known-issues.md
```

A record with no `name` gets the file name `<date>__<words of the body>.md`. A `.md` file ends with a YAML block that holds `stash-fetched-at`. Any other file, such as a `.json` or `.csv` file, is the body alone, so it stays valid.

## What a plugin can do

A plugin declares its capabilities when it starts. Stash sends only those methods.

| Capability | What it gives the agent |
| --- | --- |
| `list` | Records to browse. |
| `get` | One whole record, for refresh. |
| `search` | `stash search` on the source, best hits first. |
| `plan` | The records the mount loads when it starts. With no `plan`, the mount loads nothing at start. |
| `ingest` | Write-back: the turns of each session, with `write.trajectory = {}`. |

A `plan` has at most 10 steps, and each step has a `limit` of at most 100.

## Configure it

```toml
[sources.oncall-notes]
kind = "plugin"
description = "On-call handoff notes"
plugin = "team-notes"
settings = { folder = "/srv/oncall/notes" }
env = { NOTES_TOKEN = { command = ["op", "read", "op://ops/notes/token"] } }
```

| Key | Default | What it does |
| --- | --- | --- |
| `plugin` | required | The name. Stash runs `stash-source-<plugin>` from the daemon’s `PATH`. |
| `command` | `[]` | The program and its arguments to run instead, such as `["python3", "notes.py"]`. |
| `settings` | `{}` | The plugin’s own keys. Stash passes them as they are. |
| `env` | `{}` | The plugin’s variables: text, `{ from_env }`, `{ file }`, or `{ command }`. |
| `write.trajectory` | none | `{}` sends each turn to the plugin. The plugin must declare `ingest`. |

`plugin` takes only `a-z`, `0-9`, `-`, and `_`, because it’s part of a program name. See [`plugin`](/docs/user-guide/stash/reference/configuration/index.md#plugin) for every rule.

## How a plugin runs

-   Stash starts the plugin when the mount starts, and stops it when the mount stops.
-   Stash talks to it with JSON-RPC 2.0, one object for each line, on stdin and stdout. Logs go to stderr, and Stash writes them to the daemon log.
-   The plugin gets the same short list of variables as a local MCP server, plus `env`.
-   Stash starts a new process after the plugin exits, and after a request gets no answer in 30 seconds. It reads `env` again at each start, so a plugin can exit to get a new token.
-   An answer can have at most 16 MiB.
-   Errors carry a kind. Stash retries `throttled`, `unavailable`, and `timeout`, and no other kind.

## Write one

The Python SDK, `strands-stash-plugin`, speaks the protocol for you. You write one function for each capability. See [Write a plugin](/docs/user-guide/stash/sources/write-a-plugin/index.md), or the [plugin protocol](/docs/user-guide/stash/reference/plugin-protocol/index.md) to write one in another language.

## Related

-   [Connect sources](/docs/user-guide/stash/guides/connect-sources/index.md)
-   [Plugin protocol](/docs/user-guide/stash/reference/plugin-protocol/index.md)