OperationsRunning plugins

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_PLUGINS empty 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 default or as a named plugin export, with id, name and version strings.
  • An entry that fails to load (an unknown built-in, a missing package, a bad export) is logged as plugin.load_failed and 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_SENSITIVITY sets the plugin’s sensitivity ceiling (see below).
  • WORKSPACE_ID is the workspace the plugin’s sync and verify run 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_PLUGINS to the server, but only the variables it names, so add each MNEMO_PLUGIN_* variable to the server’s environment in docker-compose.yml as well.

Built-in plugins

Ten plugins ship in packages/plugins/src/builtins:

EntryConfig keysWhat it does
builtin:webhook-notifyurlPosts new facts, completed tasks and worth changes to a URL.
builtin:feedback-loopnoneKeeps the last 20 worth values of each memory in its state.
builtin:git-verifierrepoPathChecks a fact’s metadata.commitSha against a repository.
builtin:calendar-syncicsUrlRecords each event of an ICS feed as an event.
builtin:slack-eventswebhookUrlTurns Slack messages into events.
builtin:github-eventsnoneTurns pull requests and issues into events and facts.
builtin:outline-syncoutlineApiUrl, apiTokenMirrors Outline documents into facts.
builtin:obsidian-exportvaultDirWrites the facts as a Markdown vault.
builtin:claude-importnoneImports a Claude memory export as facts.
builtin:event-reactionsnoneFires 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: around POST /remember for facts. Returning null from onBeforeWrite rejects the write, and the request answers 400.
  • onBeforeRecall, onAfterRecall: around POST /recall.
  • Event hooks, fired without waiting: onFactCreated, onTaskCompleted, onSessionCollapsed, onConflictDetected, onWorthChanged, onEventRecorded.
  • sync(ctx): each plugin has its own job, mnemo.plugin.sync:<id>, every syncInterval the plugin declares (at least 60 seconds), or every MNEMO_PLUGIN_SYNC_INTERVAL_MS (one hour) without one. It runs in the plugin’s WORKSPACE_ID, and with several replicas only one runs each tick. MNEMO_CRON_DISABLE=mnemo.plugin.sync turns 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 as plugin_verification_failed; it is flagged, never closed.
  • onHealthCheck(): reported in the plugins block of GET /health/deep, as its id, healthy and 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.

See also