Running plugins
A plugin is a package the server loads at boot and calls on writes, recalls and events. The plugin architecture page explains the model. This page covers running them.
A plugin runs inside the server process with full access to memory, the filesystem, the network, the database connections and the environment, secrets included. There is no sandbox. Loading a plugin grants that package everything the server can do, so load only code you have audited.
Loading plugins
The server reads MNEMO_PLUGINS, a comma-separated list, and loads each
entry at boot. An entry is an npm package name or builtin:<id> for one of
the ten built-ins:
export MNEMO_PLUGINS="builtin:webhook-notify,@acme/mnemosyne-erp-plugin"- With
MNEMO_PLUGINSempty or unset, no plugin code runs. That is the default. - Each package must be resolvable from the server’s
node_modules. In the Docker stack that means building it into the server image. - Each package must export an object as
defaultor as a namedpluginexport, withid,nameandversionstrings. - An entry that fails to load (an unknown built-in, a missing package, a bad
export) is logged as
plugin.load_failedand skipped; for an unknown built-in the log lists the known ids. The other plugins and the server still start.
The plugin contract (MnemoPlugin, PluginContext) is defined in the
internal @mnemo-ai/plugins package, which is not on npm. To write a plugin,
work from the repository.
Configuring a plugin
Each plugin gets its own config from environment variables named
MNEMO_PLUGIN_<ID>__<KEY>, for built-ins and packages alike. <ID> is the
plugin id in upper case with every other character as _ (webhook-notify
becomes WEBHOOK_NOTIFY), the double underscore ends it, and <KEY> in
upper snake case becomes the camelCase key the plugin reads
(OUTLINE_API_URL becomes outlineApiUrl):
export MNEMO_PLUGINS="builtin:webhook-notify,builtin:outline-sync"
export MNEMO_PLUGIN_WEBHOOK_NOTIFY__URL="https://hooks.acme.example/mnemo"
export MNEMO_PLUGIN_OUTLINE_SYNC__OUTLINE_API_URL="https://wiki.acme.example/api"
export MNEMO_PLUGIN_OUTLINE_SYNC__API_TOKEN="..."
export MNEMO_PLUGIN_OUTLINE_SYNC__MAX_SENSITIVITY="confidential"
export MNEMO_PLUGIN_OUTLINE_SYNC__WORKSPACE_ID="<workspace uuid>"- A plugin only ever sees its own config, never another plugin’s.
MAX_SENSITIVITYsets the plugin’s sensitivity ceiling (see below).WORKSPACE_IDis the workspace the plugin’ssyncandverifyrun in. Without it the server skips them and logs a warning.- Values can be secrets: the loader logs only the keys.
- Docker Compose passes
MNEMO_PLUGINSto the server, but only the variables it names, so add eachMNEMO_PLUGIN_*variable to the server’senvironmentindocker-compose.ymlas well.
Built-in plugins
Ten plugins ship in packages/plugins/src/builtins:
| Entry | Config keys | What it does |
|---|---|---|
builtin:webhook-notify | url | Posts new facts, completed tasks and worth changes to a URL. |
builtin:feedback-loop | none | Keeps the last 20 worth values of each memory in its state. |
builtin:git-verifier | repoPath | Checks a fact’s metadata.commitSha against a repository. |
builtin:calendar-sync | icsUrl | Records each event of an ICS feed as an event. |
builtin:slack-events | webhookUrl | Turns Slack messages into events. |
builtin:github-events | none | Turns pull requests and issues into events and facts. |
builtin:outline-sync | outlineApiUrl, apiToken | Mirrors Outline documents into facts. |
builtin:obsidian-export | vaultDir | Writes the facts as a Markdown vault. |
builtin:claude-import | none | Imports a Claude memory export as facts. |
builtin:event-reactions | none | Fires rules when recorded events match a trigger. |
The server calls every hook, sync, verify and onHealthCheck
included (see Hooks). obsidian-export writes the facts its verify is
given to its vault. slack-events, github-events and claude-import
only expose functions (handleSlackEvent, handleGithubWebhook,
importClaudeMemory) for code that calls them; the server has no route for
them.
What a plugin receives
Every hook gets a PluginContext:
interface PluginContext {
readonly workspaceId: string;
readonly config: Record<string, string | undefined>;
readonly maxSensitivity: Sensitivity; // ceiling for what the plugin writes
recall(query: string): Promise<PluginRecallHit[]>;
getFact(id: string): Promise<PluginFact | null>;
createFact(input: PluginCreateFactInput): Promise<PluginFact>;
createEvent(input: PluginCreateEventInput): Promise<PluginEvent>;
createTask(input: PluginCreateTaskInput): Promise<PluginTask>;
createEpisode(input: PluginCreateEpisodeInput): Promise<PluginEpisode>;
readonly state: PluginStateStore; // persisted in mnemo_plugin_state
readonly log: PluginLogger;
readonly logger: PluginLogger;
}Writes through the context are scoped to the workspace, rate-limited and
attributed to plugin:<id>. The sensitivity of what a plugin writes is
capped at maxSensitivity, which MNEMO_PLUGIN_<ID>__MAX_SENSITIVITY sets
and which is internal without a valid tier. Each plugin has its own context:
its own config, its own ceiling, and its own state, stored under its id.
The context is a convenience, not a security boundary: the plugin is still ordinary code in the server process.
Hooks
All hooks are optional.
onInit(ctx): once at boot. An error is logged and the other plugins still start.onBeforeWrite,onAfterWrite: aroundPOST /rememberfor facts. ReturningnullfromonBeforeWriterejects the write, and the request answers400.onBeforeRecall,onAfterRecall: aroundPOST /recall.- Event hooks, fired without waiting:
onFactCreated,onTaskCompleted,onSessionCollapsed,onConflictDetected,onWorthChanged,onEventRecorded. sync(ctx): each plugin has its own job,mnemo.plugin.sync:<id>, everysyncIntervalthe plugin declares (at least 60 seconds), or everyMNEMO_PLUGIN_SYNC_INTERVAL_MS(one hour) without one. It runs in the plugin’sWORKSPACE_ID, and with several replicas only one runs each tick.MNEMO_CRON_DISABLE=mnemo.plugin.syncturns them all off.verify(facts, ctx): once a day, the plugin gets the code, config and infrastructure facts of its workspace, up to its ceiling, in batches of 50 as{ id, content, metadata }. A fact it returns as invalid goes to the review queue asplugin_verification_failed; it is flagged, never closed.onHealthCheck(): reported in thepluginsblock ofGET /health/deep, as its id,healthyand a detail of at most 200 characters with personal data redacted. It never changes the overall status.onShutdown(ctx): on shutdown, with a 5-second timeout.
Plugins that implement the same hook run in the order they were loaded.
When a plugin misbehaves
The loader contains faults; it does not contain a hostile plugin.
- Each hook call has a 2-second timeout.
- After a timeout, or after 3 failures in a row, the plugin is disabled and
the log shows
MNEMO_010. A disabled plugin is skipped from then on.