LumaBrowser Extensions Guide
Overview
LumaBrowser's extension system lets you add features to the browser without modifying core code. Extensions are self-contained directories under extensions/ with a manifest, a main process entry point, and optional routes, MCP tools, and UI panels.
Extensions receive a context object with injected services (browser automation, LLM, database, logging), so you never need to know about ports, URLs, or the REST API internals. Declare what you need in your manifest, and the extension manager wires it up for you.
context.expose() to create REST and MCP endpoints in a single call. You can always add manual routes or MCP tools later for advanced use cases.
File Structure
Each extension lives in its own directory. Built-in ones sit under extensions/. In Settings > Extensions, the + menu offers New Extension (scaffolds a folder with manifest.js, main.js and renderer.js) and Install from .zip, which installs into LumaBrowser's user-extensions folder; Code mode installs what it builds there too. Only manifest.js is required; everything else is optional.
extensions/
my-extension/
manifest.js # Required: declares metadata and dependencies
main.js # Main process entry point (activate/deactivate)
routes.js # Optional: Express routes for REST API
mcp-tools.js # Optional: MCP tool definitions
renderer.js # Optional: renderer process UI code
panel.html # Optional: UI panel
settings.html # Optional: settings page
| File | Purpose |
|---|---|
manifest.js | Declares extension ID, name, version, dependencies, and feature registrations. The extension manager reads this first. |
main.js | Exports activate(context) and optionally deactivate(). Called during startup. Return a public API object to share with other extensions. |
routes.js | Exports a factory function that receives (context) and returns an Express router; your public API is on context.extensionApi. Mounted at the prefix declared in the manifest. |
mcp-tools.js | Exports a tools array and a handler(toolName, args, opts) function for manual MCP tool definitions. |
renderer.js | Loaded in the renderer process. Sets window.__ext_<id> = { activate(context) } and calls its IPC handlers through window.ipcBridge.invoke. |
panel.html | HTML panel injected into the browser sidebar or main UI area. |
settings.html | Settings page shown in the extension preferences UI. |
Manifest
The manifest is a CommonJS module that exports a plain object. It declares everything the extension manager needs to load and wire up your extension.
// manifest.js
module.exports = {
id: 'my-extension', // lowercase kebab-case
name: 'My Extension',
version: '1.0.0',
description: 'A helpful extension that does great things.',
// Objects keyed by dependency. The extension receives only what it declares.
dependencies: {
required: {
'core:browser': { reason: 'Open tabs and read pages' },
'core:database': { tables: [{ name: 'my_data' }, { name: 'my_cache' }] },
'core:llm-service': {
slots: [{ id: 'vision', label: 'My Extension Model', required: false }]
}
},
optional: {
'ext:page-summarizer': {}
}
},
// Main process entry point
main: './main.js',
// Renderer process script (loaded in the browser window)
renderer: './renderer.js',
// REST API routes (prefix is optional; this is the default)
routes: {
file: './routes.js',
prefix: '/api/ext/my-extension'
},
// Hand-written MCP tool definitions
mcpTools: {
file: './mcp-tools.js'
},
// A toolbar button that opens a panel
navigationBar: {
label: 'My Panel',
tooltip: 'My Panel',
icon: 'grid',
panel: { location: 'right-panel', htmlFile: './panel.html' }
},
// A page in Settings
settings: {
label: 'My Extension',
tabId: 'my-extension',
htmlFile: './settings.html'
},
// Lower numbers load first (default: 100)
loadPriority: 50
};
Manifest Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Unique identifier in lowercase kebab-case. Namespaces your IPC channels (ext.<id>.*), settings keys, default route prefix and expose() tool names. |
name | string | Yes | Human-readable display name. A manifest without id or name does not load. |
version | string | Recommended | Semantic version string, shown in the Extensions tab. |
description | string | No | Short description shown in the Extensions tab and the Logger settings. |
dependencies | object | No | { required: {...}, optional: {...} }, each an object keyed by core:<name> or ext:<id>. A missing required dependency blocks loading. |
main | string | No | Path to the main process entry point, relative to the extension directory. |
renderer | string | No | Path to the renderer process script. |
routes | object | No | { file, prefix }. Without prefix the router mounts at /api/ext/<id>. |
mcpTools | object | No | { file }: a module exporting tools and handler. |
navigationBar | object | No | A toolbar button: label (required), tooltip, icon, and panel: { location, htmlFile } where location is right-panel, right-sidebar, bottom-bar, right or bottom. |
settings | object | No | A settings page: label (required), tabId, htmlFile, and placement ('extensions' or 'tab' for its own Settings tab). |
ui | object | No | UI slots your renderer fills at runtime, such as 'settings-tab': { label, tabId } (registered from renderer.js through context.slotManager). |
setupTab | object | No | A tab in the LLM tab's Setup area: { id, label, file, group, assets }. Its runtime handler comes from context.setupTab.onInvoke. |
chatModes / chatUi | string or object | No | A file exporting chat mode descriptors (or a (context) => factory), and the chat-side UI bundle for them. |
dashboard | object | No | Dashboard widgets: { widgets: [{ id, title, file, w, h }], assets, api }. |
terminalProfiles | array | No | Entries for the built-in terminal: { id, label, command } or { id, label, file, args, env }. |
loadPriority | number | No | Load order weight. Lower values load first. Default: 100. |
Dependency Formats
Each dependency is a key in required or optional, and its value is an object with that dependency's options ({} when it has none):
| Dependency | Options | Description |
|---|---|---|
core:browser | { reason } | Gives you context.browser: tab management, navigation, page reading and automation. |
core:database | { tables: [{ name }] } | Gives you context.db. List the tables you will create and query (names or { name } objects); {} for key-value settings only. |
core:llm-service | { slots: [{ id, label, required }] } | Gives you context.llm. Slots are named model bindings the user picks a provider and model for; they are registered only from a required declaration. |
ext:<id> | {} | Another extension's public API. Use optional when you can work without it. |
Core Services
The context object is passed to your activate() function. It contains all the services and utilities your extension declared as dependencies, plus framework-level tools that are always available.
| Property | Type | Description |
|---|---|---|
extensionId | string | Your extension's unique ID, as declared in the manifest. |
extensionDir | string | Absolute path to your extension's directory on disk. |
browser | BrowserService | Tab management, navigation, clicks, form fill, page reading, screenshots, JavaScript execution and tab events. Methods answer an envelope: createTab(url, { silent }) resolves { success, tab }, executeJs(tabId, code) resolves { success, data: { result } }, screenshot(tabId) resolves { success, data: { screenshot } } (base64 PNG). Only available if core:browser is declared. |
llm | LLMService | sendCompletion(slotId, messages, options) resolves { success, response } or { success: false, error }; createStream(...) streams. Only available if core:llm-service is declared. |
db | DatabaseService | Namespaced key-value store plus SQL access for declared tables. Only available if core:database is declared. |
sharedServices | object | All core services with unrestricted access. Use sparingly; prefer explicit dependencies. |
ipc | IPCBridge | Register IPC handlers for communication between the main and renderer processes. |
logger | Logger | Writes to the Activity Log under your extension. See More Context Surfaces. |
extensions | object | Public APIs returned by loaded extension dependencies. |
events | EventBus | A small publish/subscribe bus of your own. |
expose | function | Register functions as both REST and MCP endpoints in a single call. |
browser or db) will be null if you forget to list them in your manifest. Always check your dependencies block first if a service is missing.
context.expose()
The simplest way to add REST and MCP endpoints. A single call registers both a REST route and an MCP tool from one function.
Signature
context.expose(name, handler, options)
| Parameter | Type | Description |
|---|---|---|
name | string | Endpoint name. Used in the route path and MCP tool name. |
handler | async function | Receives a params object, returns data. No need to format responses. |
options.targets | string[] | Where to register: 'api', 'mcp', or both. Default: ['api', 'mcp']. |
options.description | string | Human-readable description. Used in MCP tool listing and API docs. |
options.method | string | HTTP method: 'get', 'post', 'put', 'delete'. Default: 'post'. |
options.params | object | Parameter schema. Each key maps to { type, required, description, default }. |
Example
context.expose('searchBooks', async ({ query, limit }) => {
const reply = await context.browser.executeJs(tabId, `...`);
if (!reply.success) throw new Error(reply.error);
const books = reply.data.result.slice(0, limit);
return { books, count: books.length };
}, {
targets: ['api', 'mcp'],
description: 'Search for books by title',
method: 'post',
params: {
query: { type: 'string', required: true, description: 'Search query' },
limit: { type: 'number', description: 'Max results', default: 10 }
}
});
What Gets Created
From the example above, two endpoints are automatically registered:
| Target | Endpoint |
|---|---|
| REST | POST /api/ext/{extensionId}/searchBooks |
| MCP | Tool named {extensionId}_searchBooks |
Your handler function just returns data. Response wrapping is automatic:
- REST response:
{ success: true, data: { books: [...], count: 5 }, timestamp: '...' }. A thrown error answers{ success: false, error }with status 500 (or the error'sstatusCode), and a missing required parameter answers 400. - MCP response:
{ content: [{ type: 'text', text: '{"success":true,"data":{...}}' }] }
expose() must be called synchronously during activate(). The endpoint registry is sealed after activation completes, and any later calls will throw an error.
expose() is the recommended way to add endpoints. Use manual routes.js and mcp-tools.js only when you need Express middleware, streaming responses, or custom MCP response formats.
Extension Dependencies
When your extension depends on another extension (declared as ext:other-id in the manifest), the dependent extension's public API is available on the context object.
You can access it via the full path or a convenient shorthand:
// Full path
const api = context.extensions['page-summarizer'];
// Shorthand (equivalent)
const api = context['page-summarizer'];
// Use the dependency's public API
const result = await api.summarize(text);
context['name'] only works for extension IDs that do not collide with built-in context properties like browser, db, llm, ipc, events, expose, extensionId, extensionDir, sharedServices, logger, extensions, or the surfaces chat, code, voice, setupTab, llmCatalog, imageCatalog and imageTraining. If there is a conflict, use context.extensions['name'] instead.
Database
The database service provides a namespaced key-value store and direct SQL access. Declare core:database with a tables array in your manifest to use SQL.
Key-Value Store
Key-value operations are automatically namespaced to ext.{id}.*, so extensions cannot read or overwrite each other's data.
// Set a value (auto-namespaced to ext.my-extension.lastRun)
context.db.set('lastRun', Date.now());
// Get a value
const last = context.db.get('lastRun');
// Delete a value
context.db.delete('lastRun');
SQL Access
You can only create and query tables that are declared in the tables of your manifest's core:database dependency.
// Create table (must be declared in manifest tables array)
context.db.run(
'CREATE TABLE IF NOT EXISTS my_data (id TEXT PRIMARY KEY, value TEXT)'
);
// Insert data
context.db.run(
'INSERT OR REPLACE INTO my_data (id, value) VALUES (?, ?)',
['key1', JSON.stringify({ hello: 'world' })]
);
// Query data
const rows = context.db.query('SELECT * FROM my_data');
const single = context.db.query('SELECT * FROM my_data WHERE id = ?', ['key1']);
IPC Handlers
IPC handlers bridge the main process and the renderer. Handlers are automatically namespaced with your extension ID.
Main Process (main.js)
context.ipc.handle('getData', async (event, args) => {
const items = context.db.query('SELECT * FROM my_data');
return { items };
});
context.ipc.handle('saveItem', async (event, { id, value }) => {
context.db.run('INSERT OR REPLACE INTO my_data (id, value) VALUES (?, ?)', [id, value]);
return { success: true };
});
Renderer Process (renderer.js or panel.html)
// Call your extension's IPC handler
const result = await window.ipcBridge.invoke('ext.my-extension.getData');
console.log(result.items);
// With arguments
await window.ipcBridge.invoke('ext.my-extension.saveItem', {
id: 'item-1',
value: 'Hello'
});
Events
context.events is a small publish/subscribe bus. Each extension gets its own, so use it to decouple parts of one extension; to talk to another extension, declare it as an ext:<id> dependency and call its public API. A listener that throws is logged and never stops the others.
// Subscribe to an event
context.events.on('taskCompleted', (data) => {
console.log(`Task ${data.taskId} finished with status: ${data.status}`);
});
// Emit an event (listeners on this bus run in order)
context.events.emit('taskCompleted', {
taskId: '123',
status: 'success'
});
// Unsubscribe
const handler = (data) => { ... };
context.events.on('myEvent', handler);
context.events.off('myEvent', handler);
More Context Surfaces
Besides the services above, every extension gets a set of surfaces bound to its id. Anything an extension registers through them is removed automatically when it deactivates.
| Property | What it is for |
|---|---|
context.logger | info, warn, error, debug(message, details), plus log and span, written to the Activity Log under ext.<id>. The extension shows in the Logger settings even before it logs. |
context.chat | registerMode(descriptor) for chat modes, complete(opts) for a one-shot completion (resolves { text } or { error }), generateImage(opts), visionAvailable() and uiUrl(path). |
context.setupTab | register(descriptor) a tab in the LLM tab's Setup area at runtime, and onInvoke(fn) for the calls its UI makes. |
context.llmCatalog | registerRuntime(entry, hooks) for an inference runtime with detect, install and launch hooks, and registerModel(entry) for downloadable add-on models. |
context.imageCatalog | register(entry) downloadable image-model rows in the shared image catalog. |
context.imageTraining | Declare which image models a trainer extension can train a LoRA for. |
context.voice | registerTtsEngine(engine) to add a text-to-speech engine to the voice picker, and transcribe(wav) to use the app's speech recognizer. |
context.code | The privileged seam the coding agent uses to write an extension into the user-extensions folder and hot-install it. |
REST Routes (Manual)
For advanced use cases that require Express middleware, streaming, or custom response handling, define routes in a separate routes.js file.
// routes.js
const { Router } = require('express');
module.exports = function createRoutes(context) {
const router = Router();
const api = context.extensionApi; // what your activate() returned
router.get('/status', (req, res) => {
res.json({ success: true, data: { running: true, version: '1.0.0' } });
});
router.post('/process', async (req, res) => {
try {
const { url } = req.body;
const created = await context.browser.createTab(url, { silent: true });
if (!created.success) throw new Error(created.error);
const tabId = created.tab.id;
await context.browser.waitForLoad(tabId, 15000);
const shot = await context.browser.screenshot(tabId);
res.json({ success: true, data: { tabId, screenshot: shot.data.screenshot } });
} catch (err) {
res.status(500).json({ success: false, error: err.message });
}
});
// Streaming response example
router.get('/stream', (req, res) => {
res.setHeader('Content-Type', 'text/event-stream');
res.setHeader('Cache-Control', 'no-cache');
// ... stream data
});
return router;
};
The router is mounted at the prefix declared in your manifest (default /api/ext/my-extension). The factory runs after activate() and receives the same context, plus context.extensionApi (your public API) and context.gateway (port, baseUrl, and registerUpgrade(suffix, handler) for WebSocket upgrades on your prefix).
MCP Tools (Manual)
For custom MCP response formats or complex tool definitions, use a mcp-tools.js file instead of context.expose().
// mcp-tools.js
let context = null; // set from activate(): the handler is not given the context
module.exports = {
bind: (ctx) => { context = ctx; },
// Names are used as written: no automatic prefix.
tools: [
{
name: 'my-extension_analyzeImage',
description: 'Analyze a screenshot of a browser tab',
inputSchema: {
type: 'object',
properties: {
tabId: { type: 'number', description: 'ID of the tab to capture' },
prompt: { type: 'string', description: 'Analysis prompt' }
},
required: ['tabId']
}
}
],
handler: async (toolName, args, opts) => {
if (toolName !== 'my-extension_analyzeImage') return null; // not ours
const shot = await context.browser.screenshot(args.tabId);
if (!shot.success) return { content: [{ type: 'text', text: shot.error }], isError: true };
const image = shot.data.screenshot; // base64 PNG
const reply = await context.llm.sendCompletion('vision', [{
role: 'user',
content: [
{ type: 'text', text: args.prompt || 'Describe this image' },
{ type: 'image_url', image_url: { url: `data:image/png;base64,${image}` } }
]
}], { needsVision: true });
return {
content: [
{ type: 'text', text: JSON.stringify(reply) },
{ type: 'image', data: image, mimeType: 'image/png' }
]
};
}
};
// main.js, inside activate(context):
// require('./mcp-tools').bind(context);
The file is loaded once, so the module activate() requires is the same instance the MCP aggregator calls. Tools from mcpTools and from expose() are merged into one set per extension; an expose() tool wins a name clash.
{ content: [{ type: 'text', text: '...' }] }. Prefer context.expose() which handles this automatically.
Activation
When LumaBrowser starts, the extension manager loads extensions in loadPriority order and calls each one's activate() function. The full lifecycle is:
- Load manifest - validate it and check that required dependencies are available.
- Build context - inject requested services based on declared dependencies, and register your LLM slots.
- Call
activate(context)- your entry point. Register IPC handlers, callexpose(), set up event listeners. - Capture return value - whatever you return becomes your extension's public API, available to dependents via
context.extensions. - Seal
expose()- no more endpoints can be registered after this point. - Wire surfaces - manifest chat modes and Setup tab, then the
routes.jsrouter and theexpose()routes, then the merged MCP tool set.
// main.js
async function activate(context) {
// Set up IPC, events, expose()
context.ipc.handle('ping', async () => ({ pong: true }));
context.expose('hello', async ({ name }) => {
return { message: `Hello, ${name}!` };
}, {
description: 'Say hello',
params: { name: { type: 'string', required: true } }
});
// Return public API for other extensions
return {
greet: (name) => `Hello, ${name}!`
};
}
async function deactivate() {
// Clean up timers, connections, etc.
}
module.exports = { activate, deactivate };
Deactivation
When an extension is deactivated (app shutdown, user disables it, or an error occurs), the following happens in order:
deactivate()called - clean up timers, intervals, open connections, or external resources.- IPC handlers removed - all handlers registered via
context.ipc.handle()are automatically unregistered. - MCP tools unregistered - both manual and
expose()-based tools are removed from the aggregator. - REST routes blocked - requests to the extension's route prefix answer
503with{ error: 'Extension disabled' }, for manual andexpose()routes alike.
deactivate() if you have resources the framework does not manage, such as setInterval timers, WebSocket connections, or file watchers.
Enable / Disable
Users can enable and disable extensions at runtime in Settings > Extensions (turned-off ones are listed under Inactive). Disabling an extension triggers the full deactivation sequence. Re-enabling it triggers a fresh activation; your activate() function is called again with a new context.
Persisted data (database keys and tables) survives disable/enable cycles. Anything stored only in memory will be lost.
Minimal Extension
The simplest possible extension: a manifest and a main entry point that exposes one function.
manifest.js
module.exports = {
id: 'hello-world',
name: 'Hello World',
version: '1.0.0',
description: 'A minimal extension example.',
main: 'main.js'
};
main.js
async function activate(context) {
context.expose('greet', async ({ name }) => {
return { message: `Hello, ${name || 'World'}!` };
}, {
description: 'Return a greeting message',
params: {
name: { type: 'string', description: 'Name to greet', default: 'World' }
}
});
}
module.exports = { activate };
This creates:
POST /api/ext/hello-world/greet- REST endpointhello-world_greet- MCP tool
Full Extension
A more complete extension that uses database, browser automation, an optional extension dependency, and exposes multiple endpoints.
manifest.js
module.exports = {
id: 'page-analyzer',
name: 'Page Analyzer',
version: '2.1.0',
description: 'Analyze web pages and store results.',
dependencies: {
required: {
'core:browser': { reason: 'Open and read the pages it analyzes' },
'core:database': { tables: [{ name: 'analysis_results' }] }
},
optional: {
'ext:page-summarizer': {}
}
},
main: './main.js',
loadPriority: 80
};
main.js
async function activate(context) {
// executeJs answers { success, data: { result } }
const js = async (tabId, code) => {
const reply = await context.browser.executeJs(tabId, code);
if (!reply.success) throw new Error(reply.error);
return reply.data.result;
};
// Initialize database table
context.db.run(`
CREATE TABLE IF NOT EXISTS analysis_results (
id TEXT PRIMARY KEY,
url TEXT NOT NULL,
title TEXT,
result TEXT,
created_at INTEGER DEFAULT (strftime('%s', 'now'))
)
`);
// Expose: analyze a page
context.expose('analyzePage', async ({ tabId, url }) => {
// Create a silent tab if only a URL was provided
if (!tabId && url) {
const created = await context.browser.createTab(url, { silent: true });
if (!created.success) throw new Error(created.error);
tabId = created.tab.id;
await context.browser.waitForLoad(tabId, 15000);
}
const title = await js(tabId, 'document.title');
const text = await js(tabId, 'document.body.innerText.slice(0, 5000)');
// Use page-summarizer if it is installed (optional dep)
let summary = null;
const summarizer = context['page-summarizer'];
if (summarizer) {
summary = await summarizer.summarize(text);
}
const id = `analysis-${Date.now()}`;
const result = { title, textLength: text.length, summary };
context.db.run(
'INSERT INTO analysis_results (id, url, title, result) VALUES (?, ?, ?, ?)',
[id, url, title, JSON.stringify(result)]
);
return { id, ...result };
}, {
description: 'Analyze a web page and store the results',
method: 'post',
params: {
tabId: { type: 'number', description: 'Existing tab ID to analyze' },
url: { type: 'string', description: 'URL to open and analyze' }
}
});
// Expose: get past results
context.expose('getResults', async ({ limit }) => {
const rows = context.db.query(
'SELECT * FROM analysis_results ORDER BY created_at DESC LIMIT ?',
[limit || 20]
);
return { results: rows, count: rows.length };
}, {
description: 'Retrieve stored analysis results',
method: 'get',
params: {
limit: { type: 'number', description: 'Max results to return', default: 20 }
}
});
// IPC for renderer UI
context.ipc.handle('getRecentAnalyses', async () => {
return context.db.query(
'SELECT id, url, title, created_at FROM analysis_results ORDER BY created_at DESC LIMIT 10'
);
});
// Return public API for dependent extensions
return {
analyze: (tabId) => js(tabId, 'document.title'),
getResultCount: () => {
const row = context.db.query('SELECT COUNT(*) as cnt FROM analysis_results');
return row[0]?.cnt || 0;
}
};
}
async function deactivate() {
// No manual cleanup needed; IPC and routes are handled automatically
}
module.exports = { activate, deactivate };
Chrome Extensions
Everything above is about LumaBrowser's own extension system. LumaBrowser also runs many ordinary Chrome extensions in its tabs. Manage them under Settings > Extensions > Chrome Extensions.
Three ways to install
- Extension store. A curated list of Chrome Web Store extensions known to do their job inside LumaBrowser. They download from Google and keep their data across updates; the page checks the Web Store for newer versions.
- Install from a link. Paste a Chrome Web Store link or the 32-letter extension id. Extensions outside the curated list may load but not work.
- Install unpacked folder. Load an extension folder from disk, for your own or a downloaded build.
The curated store
| Category | Extensions |
|---|---|
| Passwords & security | Bitwarden Password Manager, Proton Pass (partial: passkey prompts are not available), Authenticator |
| Appearance | Dark Reader, Stylus |
| Video & media | Return YouTube Dislike, SponsorBlock for YouTube, Video Speed Controller, Unhook |
| Productivity | Vimium (partial: tab commands do not work), JSON Formatter |
| Developer tools | React Developer Tools, Vue.js devtools (partial), Redux DevTools, Wappalyzer (partial) |
Every enabled extension with a popup gets a toolbar button next to the address bar, as in Chrome, and shows the badge it sets (a password manager's count of logins for the page). Options opens its settings page in its own window.
The shim that lets Bitwarden run
Electron implements only part of the chrome.* API, and many extensions crash on the first call it lacks (Bitwarden's background dies on chrome.webNavigation.onCommitted). LumaBrowser copies a shim into every installed extension and loads it before the extension's own code:
- Provided for real in an extension's background worker and popup:
webNavigation,contextMenus(items appear in the page's right-click menu),tabs(the active tab, queries and tab events), the action badge, andstorage.sync(kept locally). - Inert stubs for
windows,declarativeNetRequest,cookies,notifications,privacy,permissions,commands,sidePanel,userScriptsand native messaging, so the extension starts instead of crashing; features built only on them silently do nothing.
chrome.webRequest; use the built-in Block ads and trackers switch instead. Password managers that need a desktop app (1Password, KeePassXC) cannot reach it, because native messaging is not available. Script managers (Tampermonkey, Violentmonkey) need the userScripts API and do not run scripts. Installing or updating from the Chrome Web Store contacts Google.