AgiCloud

AgiCloud's Plugin system (apps/server/src/plugins.ts) lets you add custom sections to the main sidebar menu, authenticated server API routes, and MCP tools for all your coding agents.

In this tutorial you will learn how AgiCloud plugins work and build a complete external plugin step by step (with a web UI, Hono backend routes, Key Vault access, and an MCP server for agents)—without modifying or rebuilding AgiCloud itself.


How plugins work in AgiCloud

AgiCloud supports two kinds of plugins:

  1. Built-in plugins (source: 'builtin'): live inside the AgiCloud repository under apps/server/src/ (design.ts, pii.ts, browser.ts, verdict.ts, video.ts, notebook.ts). They export a PluginSpec object (id, name, version, description, section, routes, plus optional install, uninstall, and health hooks) and are registered in apps/server/src/index.ts.
  2. External plugins (source: 'external'): are standalone folders outside the AgiCloud repository containing a manifest.json file. AgiCloud discovers them in two ways:
    • Machine catalog (AGICLOUD_PLUGINS_DIR): one or more colon-separated directories (e.g. AGICLOUD_PLUGINS_DIR=/path/to/catalog). Every subfolder containing a manifest.json appears in Settings → Plugins, ready to install.
    • From a link (Settings → Plugins → Install private plugin from link): paste a Git URL (https://…, ssh://…, or git@…), which AgiCloud clones into DATA_DIR/plugins/<slug>, or an absolute folder path on the server (/path/to/my-plugin). Installing again from the same Git URL runs git pull --ff-only and hot-reloads the plugin server module.

Security and plan permissions:

  • Plugin code runs on the server with the same permissions as AgiCloud: only install plugins you trust.
  • When a plugin is turned Off, its menu item disappears, its MCP server is not passed to agents, and all its routes (/api/x/<id> and /plugin-ui/<id>) automatically return 404.
  • If your environment uses AGICLOUD_FEATURES to restrict plan features, the list must include the plugin's id (or all).

Step 1: Create the plugin folder and manifest.json

Let's create an example plugin named project-notes with the following layout:

project-notes/
├── manifest.json
├── server.mjs
├── mcp-server.mjs
└── web/
    └── index.html

Here is a complete manifest.json:

{
  "id": "project-notes",
  "version": "1.0.0",
  "name": {
    "it": "Note di progetto",
    "en": "Project Notes",
    "de": "Projektnotizen",
    "cs": "Poznámky projektu",
    "ru": "Заметки проекта"
  },
  "description": {
    "it": "Bacheca di note condivisa tra te e gli agenti AI.",
    "en": "Shared notes board between you and your AI agents."
  },
  "requires": {
    "it": "Nessun requisito aggiuntivo",
    "en": "No extra requirements"
  },
  "section": {
    "icon": "tool",
    "label": {
      "it": "Note",
      "en": "Notes"
    }
  },
  "secrets": ["OPENROUTER_API_KEY"],
  "mcp": {
    "command": "node",
    "args": ["${PLUGIN_DIR}/mcp-server.mjs"],
    "env": {},
    "autoAllow": true
  },
  "server": "server.mjs",
  "web": "web"
}

manifest.json field reference

  1. id: required; lowercase letters, digits, -, and _ only (2 to 41 characters; cannot collide with a built-in plugin ID). It is also used as the MCP server name, the AGICLOUD_FEATURES key, and the URL prefix for /api/x/<id> and /plugin-ui/<id>/.
  2. Localized strings (name, description, requires, section.label): either a plain string or a per-language object (it, en, de, cs, ru). If the user's active language is missing, AgiCloud falls back to Italian (it), then English (en).
  3. section (optional): when combined with web, adds an entry to AgiCloud's main sidebar menu that opens /plugin-ui/<id>/index.html inside the app.
  4. secrets (optional): array of Key Vault key names (Settings → Keys) that the plugin's server module is allowed to read via ctx.secret('NAME'). No other vault keys are exposed to the plugin.
  5. mcp, server, and web (all optional): a plugin can provide a UI + API, or only an MCP server and/or API without any UI. (For security, server and web must stay inside the plugin directory; paths escaping with .. are ignored).

Step 2: Write the backend module (server.mjs)

When "server": "server.mjs" is declared, AgiCloud dynamically imports the ESM module on first request and calls export async function register(app, ctx):

Here is a complete server.mjs:

import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';

export async function register(app, ctx) {
  const notesFile = join(ctx.dataDir, 'notes.json');

  const readNotes = () => {
    if (!existsSync(notesFile)) return [];
    try {
      return JSON.parse(readFileSync(notesFile, 'utf8'));
    } catch {
      return [];
    }
  };

  // GET /api/x/project-notes/notes
  app.get('/notes', (c) => c.json({ notes: readNotes() }));

  // POST /api/x/project-notes/notes
  app.post('/notes', async (c) => {
    const body = await c.req.json().catch(() => ({}));
    const text = String(body.text ?? '').trim();
    if (!text) throw new ctx.HttpError(400, 'Note text is required');
    const notes = readNotes();
    notes.push({ id: Date.now().toString(36), text, createdAt: Date.now() });
    writeFileSync(notesFile, JSON.stringify(notes, null, 2));
    return c.json({ notes }, 201);
  });
}

Step 3: Build the web UI with /plugin-kit.js (web/index.html)

Files inside web/ are served at /plugin-ui/<id>/ inside an same-origin <iframe>. By loading <script src="/plugin-kit.js"></script>, your page automatically inherits AgiCloud's stylesheets, live light/dark theme (data-theme), language, and authentication token:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Notes</title>
  <script src="/plugin-kit.js"></script>
</head>
<body>
  <section class="settings">
    <header class="chat-header">
      <div class="chat-heading">
        <h1 id="title">Notes</h1>
      </div>
    </header>
    <div class="settings-body">
      <div class="agent-card">
        <label class="field-label" for="note-input">New note</label>
        <div style="display: flex; gap: 8px; margin-top: 6px;">
          <input id="note-input" type="text" style="flex: 1;" />
          <button id="save-btn" class="btn primary" type="button">Save</button>
        </div>
      </div>
      <ul id="list" class="agent-cards" style="margin-top: 16px;"></ul>
    </div>
  </section>

  <script type="module">
    await AgiCloud.ready;

    document.getElementById('title').textContent = AgiCloud.t({
      it: 'Note di progetto',
      en: 'Project Notes',
    });

    const list = document.getElementById('list');
    const input = document.getElementById('note-input');

    async function refresh() {
      // Calls GET /api/x/project-notes/notes with AgiCloud's token
      const { notes } = await AgiCloud.plugin('GET', '/notes');
      list.innerHTML = notes
        .map((n) => `<li class="agent-card"><p>${n.text}</p></li>`)
        .join('');
    }

    document.getElementById('save-btn').addEventListener('click', async () => {
      if (!input.value.trim()) return;
      await AgiCloud.plugin('POST', '/notes', { text: input.value });
      input.value = '';
      await refresh();
    });

    await refresh();
  </script>
</body>
</html>

window.AgiCloud helper reference (/plugin-kit.js)


Step 4: Expose MCP tools to agents (mcp-server.mjs)

When your manifest.json includes an "mcp" block, AgiCloud attaches that stdio MCP server to every agent session while the plugin is enabled:

Here is a minimal dependency-free Node.js stdio MCP server (mcp-server.mjs):

import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { createInterface } from 'node:readline';

const dataDir = process.env.AGICLOUD_PLUGIN_DATA || '.';
const notesFile = join(dataDir, 'notes.json');

const TOOLS = [
  {
    name: 'read_notes',
    description: 'Read all notes saved in the Project Notes plugin',
    inputSchema: { type: 'object', properties: {} },
  },
  {
    name: 'add_note',
    description: 'Add a new note to the Project Notes plugin',
    inputSchema: {
      type: 'object',
      properties: { text: { type: 'string', description: 'Note text' } },
      required: ['text'],
    },
  },
];

const readNotes = () => (existsSync(notesFile) ? JSON.parse(readFileSync(notesFile, 'utf8')) : []);

const rl = createInterface({ input: process.stdin });
rl.on('line', (line) => {
  let msg;
  try { msg = JSON.parse(line); } catch { return; }
  if (msg.id === undefined || !msg.method) return;

  try {
    let result;
    if (msg.method === 'initialize') {
      result = {
        protocolVersion: msg.params?.protocolVersion ?? '2025-06-18',
        capabilities: { tools: {} },
        serverInfo: { name: 'project-notes', version: '1.0.0' },
      };
    } else if (msg.method === 'ping') {
      result = {};
    } else if (msg.method === 'tools/list') {
      result = { tools: TOOLS };
    } else if (msg.method === 'tools/call') {
      const { name, arguments: args = {} } = msg.params ?? {};
      if (name === 'read_notes') {
        result = { content: [{ type: 'text', text: JSON.stringify(readNotes(), null, 2) }] };
      } else if (name === 'add_note') {
        const notes = readNotes();
        notes.push({ id: Date.now().toString(36), text: String(args.text ?? ''), createdAt: Date.now() });
        writeFileSync(notesFile, JSON.stringify(notes, null, 2));
        result = { content: [{ type: 'text', text: 'Note saved.' }] };
      } else {
        throw new Error(`Unknown tool: ${name}`);
      }
    } else {
      throw new Error(`Unsupported method: ${msg.method}`);
    }
    process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id: msg.id, result }) + '\n');
  } catch (err) {
    process.stdout.write(
      JSON.stringify({ jsonrpc: '2.0', id: msg.id, error: { code: -32603, message: err.message } }) + '\n',
    );
  }
});

Step 5: Install, test, and update your plugin

  1. Open AgiCloud and go to Settings → Plugins.
  2. In the Install private plugin from link box at the top, enter:
    • the absolute path to your plugin folder on the server (e.g. /home/user/projects/project-notes);
    • or your Git repository URL (e.g. https://github.com/your-org/project-notes.git).
  3. Press Install from link:
    • the plugin immediately appears in the list as On;
    • the new Notes section appears in AgiCloud's main sidebar menu;
    • under Settings → MCP Servers, the project-notes MCP server is active for all agents.
  4. Whenever you push updates to a Git-hosted plugin, simply paste the same Git URL into Install private plugin from link and press Install from link again: AgiCloud pulls the latest commits (git pull --ff-only) and reloads server.mjs without restarting the server.

[Screenshot: "Settings → Plugins" page showing the "Install private plugin from link" form and the external plugin installed and enabled]


Next step

Using the hosted version on agicloud.dev? In the next tutorial, let's see all available plans, how to manage your subscription and invoices, and how the dedicated server works on the Pro and Team plans:

👉 13 — Plans and subscriptions on agicloud.dev