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:
- Built-in plugins (
source: 'builtin'): live inside the AgiCloud repository underapps/server/src/(design.ts,pii.ts,browser.ts,verdict.ts,video.ts,notebook.ts). They export aPluginSpecobject (id,name,version,description,section,routes, plus optionalinstall,uninstall, andhealthhooks) and are registered inapps/server/src/index.ts. - External plugins (
source: 'external'): are standalone folders outside the AgiCloud repository containing amanifest.jsonfile. 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 amanifest.jsonappears in Settings → Plugins, ready to install. - From a link (Settings → Plugins → Install private plugin from link): paste a Git URL (
https://…,ssh://…, orgit@…), which AgiCloud clones intoDATA_DIR/plugins/<slug>, or an absolute folder path on the server (/path/to/my-plugin). Installing again from the same Git URL runsgit pull --ff-onlyand hot-reloads the plugin server module.
- Machine catalog (
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 return404.- If your environment uses
AGICLOUD_FEATURESto restrict plan features, the list must include the plugin'sid(orall).
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
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, theAGICLOUD_FEATURESkey, and the URL prefix for/api/x/<id>and/plugin-ui/<id>/.- 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). section(optional): when combined withweb, adds an entry to AgiCloud's main sidebar menu that opens/plugin-ui/<id>/index.htmlinside the app.secrets(optional): array of Key Vault key names (Settings → Keys) that the plugin'sservermodule is allowed to read viactx.secret('NAME'). No other vault keys are exposed to the plugin.mcp,server, andweb(all optional): a plugin can provide a UI + API, or only an MCP server and/or API without any UI. (For security,serverandwebmust 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):
app: a Hono router already mounted at/api/x/<id>and protected by AgiCloud's Bearer token authentication (just like the rest of/api/*).ctx: provides{ id, pluginDir, dataDir, appDir, secret, HttpError }:ctx.dataDiris the persistent data directory created for your plugin (DATA_DIR/plugin-data/<id>);ctx.secret(name)returns the value of a Key Vault secret (only ifnameis listed in"secrets"inmanifest.json);new ctx.HttpError(status, message)returns a JSON{ "error": message }response with that HTTP status code (400–599).
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)
await AgiCloud.ready: waits for the host app to pass the access token and active language;AgiCloud.plugin(method, path, body): calls/api/x/<id><path>with the Bearer token and returns parsed JSON (or throws anErrorwith the server's message);AgiCloud.api(method, path, body): calls any AgiCloud API endpoint (/api<path>, e.g.await AgiCloud.api('GET', '/agents')orawait AgiCloud.api('GET', '/projects'));AgiCloud.url(path, params): builds a tokenized URL/api<path>?token=...for file downloads or opening PDFs in a new tab (e.g.AgiCloud.url('/x/project-notes/report.pdf', { download: '1' }));AgiCloud.t({ it: '...', en: '...' }): picks the string matching the app's current language;AgiCloud.navigate('#/t/<thread-id>'): navigates the main AgiCloud app to another section or conversation;AgiCloud.threadsChanged(): tells the main app to refresh the conversation list in the sidebar (useful when your plugin creates a thread via the API).
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:
- In
command,args, andenv, AgiCloud replaces${PLUGIN_DIR}(the plugin folder) and${PLUGIN_DATA}(DATA_DIR/plugin-data/<id>). - The child process also receives
AGICLOUD_PLUGIN_DIRandAGICLOUD_PLUGIN_DATAin its environment. - With
"autoAllow": true, Claude Code is pre-authorized to call your plugin's tools (mcp__<id>) without prompting for permission on every call.
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
- Open AgiCloud and go to Settings → Plugins.
- 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).
- the absolute path to your plugin folder on the server (e.g.
- 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-notesMCP server is active for all agents.
- 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 reloadsserver.mjswithout 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: