While built-in dashboard widgets provide fast metric summaries, real-world operational tools often require custom user interfaces, multi-screen navigation, interactive data entry, and direct integration with external services.
The Toolbelt Dashboard SDK lets you build fully customized web applications that run directly inside Toolbelt dashboard pages. Using standard web technologies (HTML, CSS, JavaScript) and the embedded SDK, your apps can execute SQL queries against organization DuckDB databases, invoke MCP tools, stream assistant conversations, generate speech with Gemini TTS, and conduct real-time live voice calls—all within a secure, sandboxed environment.
Deploy full web apps with split HTML, CSS, JavaScript, and static assets from organization storage with automatic client-side SPA routing.
No API keys or external scripts required. The SDK communicates directly with the Toolbelt parent window over a secure, authenticated bridge.
Generate single- and multi-speaker audio with Gemini TTS or start live conversational voice calls right from your dashboards.
Choosing a Page Type#
When creating or configuring a dashboard page in Toolbelt, choose the page type that matches your application's scope:
| Page Type | Configuration | Best Used For |
|---|---|---|
pageType='app' (Preferred) |
sourceDir: "apps/<slug>/", entryFile: "index.html" |
Multi-file applications spanning separate CSS/JS files, multiple screens, calendars, or custom image assets. |
pageType='html' |
sourceFile: "filename.html" |
Lightweight, single-file interactive tools kept entirely in one file. |
pageType='file' |
sourceFile: "document.md" |
Read-only markdown documentation or text files. |
Whenever you need to expand a dashboard page with additional features, styles, or screens, use pageType='app'. Moving to a structured folder (apps/<slug>/) keeps code modular and maintainable.
Persistent Storage: DuckDB, Never localStorage#
All persistent data—such as user settings, form submissions, calendar events, or status flags—must be stored in a workspace DuckDB database (custom.duckdb or a database created via duckdb_create_database) using sdk.executeSql().
Never store application state in localStorage, sessionStorage, or IndexedDB. Browser storage is local to the viewer's browser, unshared across team members, and wiped when browsing data is cleared. Always persist state in DuckDB.
Multi-file application architecture#
For pageType='app', multi-file dashboard apps are stored under a dedicated folder in workspace storage (for example, apps/incident-manager/):
apps/incident-manager/
├── index.html # Application entry point with embedded SDK
├── styles.css # App styling
├── app.js # Core client logic
└── assets/
└── logo.png # Static images and icons
Layout and Routing Rules#
- Relative URLs only: Reference assets using relative paths (
./styles.css,assets/logo.png). Do not hardcode absolute paths or/public/dashboard/...URLs. - No custom
<base>tags: Toolbelt automatically injects the appropriate<base>tag and bridge shim when serving the app. - SPA fallback: Extensionless client-side navigation paths automatically fall back to
index.html, allowing client-side routers (such as page.js, Navigo, or history-based routing) to function seamlessly. - File size limit: Each individual asset file is capped at 25MB.
The Embedded SDK Class#
Toolbelt pages do not require external CDN dependencies or API keys. Include the following standalone SDK class directly in your entry HTML:
class ToolbeltSDK {
constructor() {
this.requests = new Map();
this.requestId = 0;
this.listeners = new Set();
window.addEventListener("message", (event) => {
const { type, payload, requestId } = event.data;
if (requestId && this.requests.has(requestId)) {
const { resolve, reject } = this.requests.get(requestId);
if (type === "TOOLBELT_RESPONSE_ERROR") {
const err = new Error(
typeof payload === "string" ? payload : payload?.message || "Bridge error"
);
if (event.data.error) {
err.code = event.data.error.code;
err.status = event.data.error.status;
}
reject(err);
} else resolve(payload);
this.requests.delete(requestId);
} else if (type && !requestId) {
this.listeners.forEach((cb) => cb(type, payload));
}
});
this.readyPromise = this.sendRequest("TOOLBELT_INIT").then((context) => {
this.workspaceId = context.workspaceId;
return context;
});
}
async ready() {
return this.readyPromise;
}
async sendRequest(type, payload = {}) {
return new Promise((resolve, reject) => {
const id = ++this.requestId;
this.requests.set(id, { resolve, reject });
window.parent.postMessage({ type, payload, requestId: id }, "*");
});
}
async listTools() {
const payload = await this.sendRequest("TOOLBELT_LIST_TOOLS");
if (Array.isArray(payload)) return payload;
const tools = Array.isArray(payload?.tools) ? payload.tools : [];
tools.tools = tools;
tools.count = typeof payload?.count === "number" ? payload.count : tools.length;
tools.workspaceId = payload?.workspaceId || this.workspaceId || "";
return tools;
}
async runTool(toolName, args = {}) {
return this.sendRequest("TOOLBELT_RUN_TOOL", { tool: toolName, arguments: args });
}
parseToolResult(result) {
const content = Array.isArray(result?.content) ? result.content : null;
if (!content || content.length === 0) return result;
const firstText = content.find((part) => part?.type === "text");
if (firstText && typeof firstText.text === "string") {
try {
return JSON.parse(firstText.text);
} catch {
return firstText.text;
}
}
return result;
}
parseToolImages(result) {
const content = Array.isArray(result?.content) ? result.content : [];
return content
.filter((part) => part?.type === "image" && typeof part.data === "string")
.map((part) => ({
mimeType: part.mimeType || "image/png",
data: part.data,
dataUrl: `data:${part.mimeType || "image/png"};base64,${part.data}`,
}));
}
async runToolParsed(toolName, args = {}) {
const result = await this.runTool(toolName, args);
return this.parseToolResult(result);
}
async executeSql(query, params = [], database = null) {
const payload = { query, parameters: params };
if (database) payload.database = database;
return this.sendRequest("TOOLBELT_EXECUTE_SQL", payload);
}
async chat(message) {
return this.sendRequest("TOOLBELT_CHAT", { message });
}
async chatStream(message, onChunk) {
const res = await this.sendRequest("TOOLBELT_CHAT", { message });
onChunk(res.content || JSON.stringify(res), res.content || JSON.stringify(res));
return res;
}
get tts() {
const sdk = this;
return {
async generate(options = {}) {
return sdk.sendRequest("TOOLBELT_TTS", options);
},
async play(options = {}) {
const res = await this.generate(options);
const audio = new Audio(res.dataUrl);
await audio.play();
return { ...res, audio };
},
};
}
get liveAudio() {
const sdk = this;
return {
start(options = {}) {
return sdk.sendRequest("TOOLBELT_LIVE_AUDIO_START", options);
},
stop() {
return sdk.sendRequest("TOOLBELT_LIVE_AUDIO_STOP");
},
setMuted(muted) {
return sdk.sendRequest("TOOLBELT_LIVE_AUDIO_MUTE", { muted: !!muted });
},
on(eventName, callback) {
if (typeof callback !== "function") {
return () => {};
}
const handler = (type, payload) => {
if (
type === "TOOLBELT_LIVE_AUDIO_EVENT" &&
payload?.event === eventName
) {
callback(payload);
}
};
sdk.listeners.add(handler);
return () => sdk.listeners.delete(handler);
},
};
}
get auth() {
const sdk = this;
return {
async getViewer() {
const ctx = await sdk.ready();
return ctx.user || null;
},
async logout() {
await sdk.sendRequest("TOOLBELT_AUTH_LOGOUT");
window.location.reload();
},
};
}
get connections() {
const sdk = this;
return {
async list() {
return sdk.sendRequest("TOOLBELT_CONNECTIONS_LIST");
},
async connect(serverId, options = {}) {
const result = await sdk.sendRequest("TOOLBELT_CONNECTIONS_CONNECT", {
serverId,
...options,
});
const popupUrl = result?.connectPopupUrl || result?.authorizeUrl || result?.connect_link_url;
if (popupUrl) {
window.open(popupUrl, "ToolbeltExternalConnect", "width=520,height=720,scrollbars=yes,resizable=yes");
}
return result;
},
async complete(serverId, payload = {}) {
return sdk.sendRequest("TOOLBELT_CONNECTIONS_COMPLETE", { serverId, ...payload });
},
async disconnect(serverId) {
return sdk.sendRequest("TOOLBELT_CONNECTIONS_DISCONNECT", { serverId });
},
};
}
}
SDK Reference & Usage#
1. Initialization#
Always instantiate the SDK and wait for the handshake before invoking other methods:
const sdk = new ToolbeltSDK();
document.addEventListener("DOMContentLoaded", async () => {
const context = await sdk.ready();
console.log("Connected to workspace:", context.workspaceId);
});
2. DuckDB SQL execution#
The sdk.executeSql method runs queries against attached DuckDB databases.
Warning: Response Shape Difference
SELECTqueries resolve to a plain array of rows[{ ... }, ...]. There is no top-level.rowsproperty. Accessingresult.rows[0]will fail.- Write queries (
INSERT,UPDATE,DELETE,CREATE) resolve to an object containing{ changes: number }.
// Safe helper to normalize SQL responses
function rowsFromSqlResult(raw) {
if (Array.isArray(raw)) return raw;
const nested = raw?.rows ?? raw?.data?.rows;
return Array.isArray(nested) ? nested : [];
}
// Example: Select items
const raw = await sdk.executeSql("SELECT id, title, status FROM tasks ORDER BY createdAt DESC", [], "custom.duckdb");
const tasks = rowsFromSqlResult(raw);
// Example: Insert item
await sdk.executeSql(
"INSERT INTO tasks (id, title, status) VALUES (?, ?, ?)",
[crypto.randomUUID(), "Review pull request", "pending"],
"custom.duckdb"
);
3. Executing MCP tools#
Use sdk.runToolParsed() to execute any connected MCP tool and automatically parse the JSON response:
// Fetch open GitHub issues
const issues = await sdk.runToolParsed("github_list_issues", {
owner: "my-org",
repo: "my-repo",
state: "open"
});
4. Working with Images in Organization Storage#
To display an image stored in workspace storage, call read_storage_file and parse the binary block using sdk.parseToolImages():
const raw = await sdk.runTool("read_storage_file", { fileName: "diagram.png" });
const [image] = sdk.parseToolImages(raw);
if (image) {
document.getElementById("preview").src = image.dataUrl;
}
For large files, request a signed URL with get_storage_file_url:
const res = await sdk.runToolParsed("get_storage_file_url", { fileName: "report.pdf", expiresIn: 3600 });
window.open(res.url, "_blank");
5. Managing connections and OAuth#
Your application can inspect connected services and trigger OAuth connect flows with sdk.connections:
// Check if GitHub is connected
const connections = await sdk.connections.list();
const isGitHubConnected = connections.some(c => c.serverId === "github" && c.connected);
// Trigger connection popup if disconnected
if (!isGitHubConnected) {
connectBtn.addEventListener("click", async () => {
await sdk.connections.connect("github");
});
}
6. User identity#
Retrieve the signed-in user's profile with sdk.auth:
const viewer = await sdk.auth.getViewer();
if (viewer) {
document.getElementById("user-name").textContent = viewer.displayName || viewer.email;
}
7. Speech synthesis with Gemini TTS (sdk.tts)#
Generate natural spoken audio from text using Gemini Flash TTS models. Single-speaker narration and multi-speaker dialogue are both supported.
sdk.tts.generate(options): Synthesizes speech and resolves to{ mimeType, data, dataUrl, model, file? }.sdk.tts.play(options): Generates and plays the resulting audio buffer directly in the browser via HTML5 Audio.
Single-Speaker Narration#
// Generate and play read-aloud speech
await sdk.tts.play({
text: "Welcome to the Operations Overview. All services are healthy. <short pause> No active incidents.",
voice: "Kore", // Prebuilt voices: Kore, Puck, Charon, Zephyr, Fenrir, etc.
style: "calm, professional newscaster",
model: "gemini-3.8-flash-lite-tts", // default; pass "gemini-3.8-flash-tts" for higher fidelity
save: true // optionally persist generated WAV in assistant media storage
});
Use angle-bracket inline tags like <sigh> or <short pause> in the text string for momentary vocal inflections, and describe sustained tone (e.g., "excited and upbeat") in the style parameter.
Multi-Speaker Dialogue (Up to 2 Speakers)#
const result = await sdk.tts.generate({
speakers: [
{ speaker: "Host", voice: "Zephyr" },
{ speaker: "Expert", voice: "Charon" }
],
turns: [
{ speaker: "Host", text: "Welcome back! What are the latest metrics looking like?" },
{ speaker: "Expert", text: "Latency dropped 18% following the database indexing patch.", style: "confident and clear" }
]
});
// Play back the generated dialogue
const audio = new Audio(result.dataUrl);
audio.play();
8. Live Voice Chat in Dashboards (sdk.liveAudio)#
Integrate real-time conversational voice directly into custom dashboard apps. The parent Toolbelt window manages microphone capture, WebSocket streaming, and gapless audio output, while your app handles custom UI controls.
// Start a live voice session with the workspace assistant
await sdk.liveAudio.start({
instructions: "You are guiding the user through quarterly server maintenance.",
voice: "Kore",
greeting: "Hello! I am ready to review your server maintenance checklist.",
pageName: "Server Maintenance"
});
// Listen for live transcription turns
sdk.liveAudio.on("transcript", (payload) => {
console.log(`${payload.role}: ${payload.text}`);
});
// Monitor session state changes
sdk.liveAudio.on("state", ({ state }) => {
// state: "connecting" | "active" | "speaking" | "listening" | "stopped"
statusEl.textContent = `Voice status: ${state}`;
});
// Mute microphone
sdk.liveAudio.setMuted(true);
// End call
stopButton.addEventListener("click", async () => {
await sdk.liveAudio.stop();
});
Only one live audio session can run at a time per browser tab. On public dashboards, live audio requires the Live voice chat publishing capability toggle.
Visual Verification & Testing (Agents)#
When an AI assistant creates or updates a dashboard page, it must visually inspect the rendered result using Toolbelt's built-in preview tools:
- Mint a preview link: Call
get_dashboard_page_preview_urlwith thepageSlug. This creates a short-lived signed preview URL with full in-app bridge capabilities. - Capture visual state: Call
browser_screenshotwithembedPreviewUrlto verify typography, colors, layout, and data tables. - Interact and test: Call
browser_interactwithrawPreviewUrlto click buttons, test tab navigation, and inspect DOM states directly. - Iterate: Patch the code using
read_html_elementandpatch_text_file, then re-verify.
Preview URLs allow full authenticated testing of private dashboards without requiring them to be shared publicly.
Related Topics#
- Live Audio Chat — Real-time conversational voice sessions and architecture.
- Voice & Speech APIs — Programmatic REST endpoints for TTS and audio chat.
- Dashboards — Create and arrange widget-based dashboards.
- Public Dashboards — Share dashboards securely with external users and custom domains.
- Auto-DuckDB — Query structured data sets using SQL.
- Organization Storage — Manage files, images, and application directories.
