Skip to main content
Glama

Create a Napkin interface

napkin_interfaces_create

Create an interface — a small screen of its own the user can open and send to people. Use when someone asks for a custom chat UI, a little tool, or a prototype of how something would feel in their product. It starts with a working index.html you then edit. It can reach NOTHING in the workspace until a flow is granted with napkin_interfaces_grant. Cite it in your reply as [[interface:ID]] alone on its own line — it renders as a card the user can click. Do NOT paste an image URL or try to embed the picture yourself; that renders as a broken image. An interface is plain HTML, CSS and JavaScript in one or more files, served from its own origin. Put styles in a block. LIBRARIES: there is no build step and no CDN, and a to any other site is blocked. A fixed shelf of libraries is served from the interface's own origin instead; load them with exactly these tags (the versions are pinned, and any other /lib/ path is not found): PREACT + HTM, for a page with several screens or a lot of state — components and hooks with no build: then var html = htm.bind(preact.h); var useState = preactHooks.useState; function App(){ var s = useState(0); return html<button onClick=${function(){ s[1](s[0] + 1) }}>${s[0]}</button> } preact.render(html<${App}/>, document.getElementById("app")). Templates are tagged strings (html…), not JSX. CHART.JS, for a chart: then new Chart(canvasElement, { type: "bar" | "line" | "doughnut" | …, data: { labels: [...], datasets: [{ label, data: [...] }] }, options: {} }). Color the datasets from the brand variables, read with getComputedStyle(document.documentElement).getPropertyValue("--brand-accent"). LUCIDE, for icons: . In plain markup, write and call lucide.createIcons() once it's on the page (again after adding more). In a Preact page DON'T — createIcons swaps elements Preact owns; draw the icon from its shapes instead: lucide.icons.Calendar is a list of [tag, attributes], so render with preact.h(tag, attributes) for each (the app starter has an Icon component that does this). Names are lucide.dev's: kebab-case in markup, PascalCase in lucide.icons. A one-screen page needs none of these: plain HTML, CSS and JavaScript is still the default. React, Tailwind and every other library are not available. index.html is the entry point and must exist. THE BRAND: every interface carries the workspace brand as files — link it with and style with its variables: var(--brand-ink), var(--brand-muted), var(--brand-background), var(--brand-surface), var(--brand-accent), var(--brand-accent-2), var(--brand-color-) (napkin_interfaces_view lists the exact names this brand defines), var(--brand-font-heading), var(--brand-font-body), var(--brand-radius). Never hard-code the brand's colours or font names. brand.css already loads the brand's own font files; web fonts (Google Fonts or any other) are BLOCKED, so linking one leaves the page in a system font. The brand's logos are files under brand/ (brand.css lists them at the top): . Use the logo rather than typing the name, and real icons (inline SVG) rather than emoji. Read the brand with napkin_brand_get first, and say only what the brand kit or the user tells you. PICTURES: a picture from anywhere on the web is BLOCKED and draws as a broken image, so never use an external image URL. Show a picture from the workspace's files with (in CSS, url(file:)) — PNG, JPEG, GIF or WebP, up to 5 MB. Write the reference literally; a file id assembled in JavaScript is not found. When the user gives you a picture in chat, save it with workspace_files_save_from_chat and use the file id it returns. A picture that's only on a website has to be attached in chat first, or uploaded in the interface's Files panel. LOOK before you hand it over: napkin_interfaces_view draws the page as it is now. Fix anything that doesn't look like the brand and look again. Load the client with . Then zw.ready() resolves with the context { viewer, grants, flows, tables, metrics, tasks }; ctx.flows lists the flow grants, each with its id, name and variables. zw.flows.run(flow.id, input) runs one. Call it inside zw.ready().then(...), and handle the rejection — it rejects only when the page isn't open in ZeroWidth, so show "Open this from ZeroWidth" there instead of a dead button. A run can take up to two minutes; show it working (stream it, below), and show the error's message when one fails — err.message is a sentence written for the person using the page. Input is {kind:"chat", messages:[{role:"user", content:"…"}]} or {kind:"form", values:{…}} — the same shapes the public API takes. zw.replyText(result) pulls the assistant text out of a chat result. SOURCES: when the flow searches a knowledge base, zw.sources(result) lists the documents the run actually read, as [{ name, documentId }], once each. Show those under the answer for "where did this come from" — never ask the model to write a sources line and parse it out of the text. The flow needs the knowledge base attached BEFORE it is published (workbench_flows_attach_knowledge_base, then workbench_flows_publish, then re-grant the new version here); the interface runs the published version it was granted. FEEDBACK: to let someone rate an answer or flag a wrong one, call zw.feedback.send(result, { rating: "up" | "down", correction, comment }) with the result zw.flows.run returned. It goes to Caliper, into the flow's feedback dataset, with the question and the answer taken from the run itself; correction is what the answer should have been. Needs no extra grant and no table — never make a table to log flagged answers. It returns a promise: say it was sent only once it resolves, and show the error's message if it rejects. Tell the user flagged answers are in Caliper, in the dataset named after the flow, under Datasets. VARIABLES: a flow grant lists variables — the values the flow reads besides the conversation, usually the {{key}} tokens in its prompt (who the user is, their plan, the page they are on). Send them on the same chat run: {kind:"chat", messages:[…], values:{: value}}, using each variable's exact name and its type (string, number, boolean, array, object). A variable left out reaches the prompt empty. Read them from napkin_interfaces_get while you write the page, or at run time from ctx.flows[i].variables. A SHIM is not a flow and takes a different call: zw.shims.run(shimId, text), which decides on the viewer's own device with no network and no cost. It resolves with the same envelope a flow does, so read the decision with zw.decision(result) — NOT result.decision, which is undefined and makes an interface show one answer for every input. The decision is { answer, confidence, familiarity, action, probs, gates }; branch on action, the shim's own call about whether it was sure enough. Calling zw.flows.run with a shim id is refused. ctx.grants tells you which you have: each entry carries a kind of "flow" or "shim" alongside its id and name. DATA: an interface can be granted a sheet TABLE or a Ledger METRIC with napkin_interfaces_grant_data. ctx.tables lists each table with its fields (name, type, options) and access ("read", "add" or "edit"); ctx.metrics lists each metric with its unit and access ("read" or "record"). Records travel keyed by field NAME, choices by option NAME. zw.tables.query(table, { where: [{ field, op, value }], sort: [{ field, dir }], limit }) resolves { records: [{ id, fields }], total }; zw.tables.add(table, { Field: value }) or a list adds records; zw.tables.update(table, id, fields) and zw.tables.remove(table, ids) need "edit". zw.metrics.read(metric, { from, to }) resolves { metric, readings: [{ value, at, note }] }; zw.metrics.record(metric, value, { note }) needs "record". Name a table or metric by its id or its name. Through a share link a guest can read and add, never change or delete — so an intake form works when shared, a triage board needs a signed-in viewer. A granted Workbench TASK (ctx.tasks; each says whether it takesInput) starts with zw.tasks.start(task, input), which resolves { runId, status } at once — the run carries on after the page closes — and zw.tasks.get(task, runId) reads { status, output } for runs this page started. Running a shim on every keystroke is fine — it costs nothing and there is no rate limit. Debounce ~150ms and COALESCE: remember the latest text and run it when the current call finishes, so the answer matches what is on screen. Clear any in-flight guard on failure as well as success, or one call that doesn't come back wedges the interface. d.action is "act" | "suggest" | "refuse" — those three strings, nothing else. Branch on it rather than on a confidence threshold you invent; "refuse" means the shim doesn't recognise the input well enough to answer, so say so rather than showing a low-confidence guess. If you run a requestAnimationFrame loop, remove CSS transitions from any property it writes — the two fight and the property looks frozen. A flow answers in markdown: render it with el.replaceChildren(zw.markdown(text)). It builds DOM nodes, so model output is never treated as markup. STREAM chat answers: zw.flows.run(id, input, { onEvent: fn }) delivers the text token by token, and a flow that takes several seconds reads as broken without it. Use zw.textDelta(event) for each chunk — it returns null for anything that isn't text, so pass it every event — and accumulate. The promise still settles at the end with the whole result; take the final text from there. onEvent also sees node_start / node_complete / node_error if you want to name the step. Don't name a top-level variable history, name, status, length, origin or top: those are already window properties, so var history = [] leaves you with the browser's History object and history.push fails. Prefix it, or keep it inside a function. THE KIT: every new interface also has kit.css, components built only from the brand's variables — link it after brand.css () and build from its classes rather than styling from scratch: layout (.page, .page.wide, .header, .stack, .row, .grid), type (h1, h2, h3, .muted, .small, .label, .num, .stat), buttons (.btn, .btn.secondary, .btn.quiet, .btn.sm, .btn.icon), fields (.field with a .label, then .input / .select / .textarea, then a .hint or .error; .check for a checkbox), .chips and .chip, .badge (.up, .down, .accent), .card, .list, .meter, states (.empty, .skeleton, .spinner, .notice, .notice.error), chat (.thread, .bubble.me, .bubble.them, .typing, .composer), and .icon for a Lucide icon. Its tokens are var(--ink), var(--muted), var(--bg), var(--surface), var(--accent), var(--line), var(--tint), var(--radius) and spacing var(--s1)…var(--s7). The starters show the kit used well; read one before writing a page of your own. Design it the way a good product is designed: a clear hierarchy, real spacing, states for loading, empty and failure, and a layout that works on a phone first. Use the brand kit (napkin_brand_get) for what the brand looks like and how it sounds.

Input Schema

NameRequiredDescriptionDefault
nameNo
starterNoWhich worked example to start from — a whole working page, written well, that you then shape to what was asked. `blank`: a title and the client library. Start here unless one of the others is exactly the shape you want. `chat`: a conversation against one flow, streamed, keeping the history client-side so the flow sees the whole thread. `form`: labelled fields sent as a form run, with the answer underneath. `decision`: text in, a shim's answer out, with its confidence and the action it recommends. `app`: an app with several screens (Preact, htm and Lucide from the shelf): tabs along the bottom on a phone and the top on a wide screen, the screen kept in the address, a home screen and a streamed chat. For a member app or a tool with a few views. `dashboard`: cards over the granted data (Chart.js from the shelf): each Ledger metric's latest reading and a line of its history, each table's count, a bar of how it splits on its first choice column, and its latest records. `intake`: a form built from a granted table's columns that adds a record to it, with a done state and 'add another'. Works through a share link. `board`: a granted table's records in lanes by its first choice column, moved a lane at a time by someone who may edit. Needs a signed-in viewer to move cards. Take `blank` (the default) when none of the others is the shape you want, rather than deleting one you didn't need. The data starters (dashboard, intake, board) read what's granted with napkin_interfaces_grant_data, so grant the table or metric too.
workspaceNoWorkspace slug. Personal tokens with no default workspace MUST pass this; tokens with a default can override per call. Ignored for workspace API keys.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / starter / description
      Previous value: -"Which worked example to start from. `chat` is a conversation against one flow; `form` is labelled fields sent as a form run; `decision` is text in and a shim's answer out. `blank` (the default) is a title and the client library — take it when none of the others is the shape you want, rather than deleting one you didn't need."New value: +"Which worked example to start from — a whole working page, written well, that you then shape to what was asked. `blank`: a title and the client library. Start here unless one of the others is exactly the shape you want. `chat`: a conversation against one flow, streamed, keeping the history client-side so the flow sees the whole thread. `form`: labelled fields sent as a form run, with the answer underneath. `decision`: text in, a shim's answer out, with its confidence and the action it recommends. `app`: an app with several screens (Preact, htm and Lucide from the shelf): tabs along the bottom on a phone and the top on a wide screen, the screen kept in the address, a home screen and a streamed chat. For a member app or a tool with a few views. `dashboard`: cards over the granted data (Chart.js from the shelf): each Ledger metric's latest reading and a line of its history, each table's count, a bar of how it splits on its first choice column, and its latest records. `intake`: a form built from a granted table's columns that adds a record to it, with a done state and 'add another'. Works through a share link. `board`: a granted table's records in lanes by its first choice column, moved a lane at a time by someone who may edit. Needs a signed-in viewer to move cards. Take `blank` (the default) when none of the others is the shape you want, rather than deleting one you didn't need. The data starters (dashboard, intake, board) read what's granted with napkin_interfaces_grant_data, so grant the table or metric too."
    • changedInput schema / properties / starter / enum
      Previous value: -[
      -  "blank",
      -  "chat",
      -  "form",
      -  "decision"
      -]New value: +[
      +  "blank",
      +  "chat",
      +  "form",
      +  "decision",
      +  "app",
      +  "dashboard",
      +  "intake",
      +  "board"
      +]
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only say this writes (readOnlyHint=false) and is not destructive; the description goes far beyond that, disclosing that the interface reaches nothing until napkin_interfaces_grant, that external images/CDNs/web fonts are blocked, that libraries are a pinned same-origin shelf, the 5 MB file limit, the two-minute flow run window, that tasks continue after the page closes, and that feedback lands in Caliper. This is exactly the extra context the dimension rewards.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

It is genuinely long, but the density is warranted for a tool that generates an arbitrary HTML/CSS/JS app, and the purpose plus the critical citation rule (`[[interface:ID]]` on its own line) are front-loaded before the reference material. The all-caps section headers (LIBRARIES, THE BRAND, DATA, STREAM) give it navigable structure, though the volume sits at the upper limit of what a description should carry.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description takes on the full burden and meets it: it explains the grant model, the client library (/zerowidth.js) and its zw.* APIs, table/metric/shim/task access shapes, streaming, markdown rendering, and how results surface in the reply. An agent has everything needed to produce and hand over a working interface.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 67% and the enum description for `starter` is already exhaustive, so the schema carries the parameter burden. The description only gestures at that parameter ('It starts with a working index.html you then edit'; 'The starters show the kit used well') and says nothing new about `name` or `workspace`. Baseline 3 fits: the schema does the heavy lifting and the description adds marginal value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence gives a precise verb and resource: 'Create an interface — a small screen of its own the user can open and send to people.' That distinguishes it cleanly from napkin_boards_create, napkin_docs_create, and napkin_deck_compose without requiring the schema. The follow-on examples (custom chat UI, little tool, prototype) sharpen the intent further.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It states the triggering condition ('Use when someone asks for a custom chat UI, a little tool, or a prototype'), names the companion tools (napkin_interfaces_grant for reaching workspace data, napkin_interfaces_view to look before handing over, napkin_interfaces_get for variables, napkin_brand_get for brand truth), and routes edits elsewhere by saying it 'starts with a working index.html you then edit.' Nothing about when-to-use is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources