Noyau
Sections

Documentation › Develop

Create a Noyau plugin

Complete example: plugin-examples/hello/ (MCP tool, blocks view, iframe page, widget, setting). Design and security: docs/plugins.md.

1. Folder

mon-plugin/
  noyau-plugin.json   manifest (required)
  server.js           server code (optional), default export definePlugin({...})
  icon.svg            monochrome icon (optional)
  ui/index.html       page for a "frame" view (optional)
  package.json        "type": "module", devDependency @noyau/plugin-sdk

There is no build step at install time: ship JavaScript that is ready to run. Noyau provides @noyau/plugin-sdk to the installed plugin; do not bundle any other node_modules (they are not served to iframes and they make the archive heavier).

2. Manifest

{
  "manifestVersion": 1,
  "id": "mon-plugin",
  "name": "My plugin",
  "version": "1.0.0",
  "description": "What the plugin does, in one sentence.",
  "author": { "name": "Léa Bernard" },
  "license": "MIT",
  "noyau": ">=0.229.0",
  "availability": "members",
  "permissions": ["notes:read", "network:api.example.org"],
  "server": "server.js",
  "contributes": {
    "tools": [{ "name": "resume", "description": "…", "inputSchema": { "type": "object" } }],
    "views": [{ "id": "home", "title": "My plugin", "nav": "sidebar", "kind": "blocks" }],
    "settings": [{ "key": "jeton", "label": "API token", "type": "secret" }]
  }
}
  • id: lowercase letters, digits, hyphens. Must not start with noyau- (reserved for built-in plugins).
  • availability: admins or members, a suggested value; the admin decides.
  • permissions: only request what you need; the admin sees them in plain language before installing. List and risk levels: docs/plugins.md, Permissions section.
  • views[].kind: blocks (rendered by Noyau) or frame (with entry, an isolated HTML page). nav: sidebar or more.

Check: npx noyau-plugin validate.

3. Server code

import { blocks, definePlugin } from "@noyau/plugin-sdk";

export default definePlugin({
  tools: {
    resume: async (args, ctx) => {
      const notes = await ctx.noyau.notes.list();
      return { total: notes.length };
    },
  },
  routes: { "GET /etat": async (request, ctx) => ({ ok: true }) },
  actions: { vider: async (payload, ctx) => ctx.storage.delete("liste") },
  views: {
    home: async (payload, ctx) => blocks.view("My plugin",
      blocks.stat("Items", String(((await ctx.storage.get("liste")) || []).length)),
      blocks.button("Clear", "vider"),
    ),
  },
  hooks: { "agent.turn.after": async (event, ctx) => {} },
});

A hook is also declared in contributes.agents.hooks and requires its permission (agent.turn.after → threads:send). It only receives the agents of the account that enabled the plugin.

ctx passed to every call:

Key Role
ctx.profile { id, admin } of the calling account. All the following data belongs to this account.
ctx.storage get, set, delete, list: the plugin's JSON storage for this account (1 MB).
ctx.settings Non-secret settings chosen by the admin.
ctx.secrets.get(clé) A secret setting, decrypted on demand.
ctx.fetch(url, init) https only, to the hosts of a network: permission. Direct fetch, net and http are blocked.
ctx.noyau notes.list/create, todos.list, projects.list, threads.list, notify: Noyau's API on behalf of the account, according to the permissions.
ctx.log(...) Log visible in Administration > Plugins.

The plugin process has no writable disk, no direct network, no environment variables and no subprocesses. Timeouts: 10 s per route, 60 s per tool, 5 s per hook.

Tools appear in Noyau's MCP server under the name p_<id>__<outil> (hyphens changed to _), for tokens with the "agents" scope.

4. Views

Blocks (shared/plugin-blocks.js): heading, text, notice, stat, list, button, link, divider, row, form. A button or a form calls an action; the view then reloads.

frame page: served in an iframe without same origin (no cookies, no storage, no network). It talks to Noyau through messages:

window.parent.postMessage({ type: "noyau:action", id: 1, action: "vider", payload: {} }, "*");
window.addEventListener("message", (event) => {
  if (event.source === window.parent && event.data?.type === "noyau:result") console.log(event.data.result ?? event.data.error);
});

Scripts and styles: files from the view's folder (<script src="app.js">) or inline.

5. Try it without Noyau

npx noyau-plugin dev                                 # lists tools, routes, actions, views
npx noyau-plugin dev --call=tool:resume --args='{}'  # calls a tool

Unit tests with testPlugin (in-memory storage per account, permissions checked as on the server):

import { testPlugin } from "@noyau/plugin-sdk";
import plugin from "../server.js";

const bench = testPlugin(plugin, { permissions: ["notes:read"], noyau: { notes: { list: [{ id: "n1" }] } } });
console.log(await bench.tool("resume"));               // { total: 1 }
console.log(await bench.tool("resume", {}, { as: "sam" })); // another account, another storage

6. Install

  1. npx noyau-plugin pack → mon-plugin-1.0.0.tgz.
  2. Administration > Plugins > Install a plugin: .tgz archive, https Git repository (with ref), or folder on the server.
  3. Analyze: Noyau shows the author, the version, the permissions ("new" for those added since the installed version) and the "Unverified" warning. Nothing runs at this stage.
  4. Tick "I have read the warning…", click Install, then enable the plugin and choose its availability.

A new version is installed the same way; the old one is removed once the new one is in place. Uninstalling keeps the data, unless "Also delete its data" is ticked (30-day trash).

7. Publish

The community registry does not exist yet. In the meantime, share the Git repository or the .tgz archive.

Edit this page on GitHub