Ship to
Put your agent in your own site
Web appA side panel on your website where signed-in people ask your agent for what they need, see each tool it runs, and follow its links around your site.
The web app puts your agent in a panel docked at the side of your own site. A person who is signed in on your site asks for what they need, such as “which of my orders are late?”, and the agent answers with the same tools your MCP server and CLI serve. Each tool call shows as a step, and links in the answer take the site to the right page.
You add one script tag to your site. Flow serves the panel from your MCP server’s origin, signs the person in from your site’s own session, and shows how to use the same tools in Claude, ChatGPT, Cursor, VS Code and the terminal.
How it works
Section titled “How it works”- One script tag.
<script src="<origin>/app/embed.js">draws a launcher on your page. When it opens, it docks a panel at the side of the page. The page moves over to make room instead of being covered; on screens 720 px wide or less, the panel covers the page. People can drag its edge to make it between 340 and 720 px wide. It stays open as they move between pages. - The panel is an iframe on your MCP server’s origin. The person’s token stays in that origin’s storage. Your page’s scripts never see it.
- Its own channel. The panel chats over
POST /app/chat, a channel namedapp(traces show it asweb). The channel draws every tool call, so the agent answers once with the outcome instead of acknowledging first. - Signed in as your site’s user. Your site mints the same one-time code your login page mints for the OAuth bridge. No login page is shown.
- Each tool call is a step, with its title, whether it is running, done or failed, and the CLI
command that does the same when you give
cli. The agent’s housekeeping tools (read_skill,load_skill,search_tools,execute_tool,feedback) are not shown. - Links navigate your site. A link in an answer to one of your site’s pages opens it in the site; other links open in a new tab.
- The conversation follows them. The panel keeps the last 80 messages, steps and views in the browser, across page loads. New chat clears the panel and starts afresh for the agent too: it stops seeing the earlier messages, which are kept, not deleted.
Before you start
Section titled “Before you start”- An MCP server built with
mcpServerthat is given the agent. On Flow’s hosting, themcp(agent, host)factory insrc/mcp.tsreceives it. - Sign-in through Flow’s OAuth bridge, with its issuer on the MCP server’s own origin. The panel
chats only as a signed-in person and has no guest mode. Sign-in from your site uses the bridge’s
appoption; with your own authorization server, the panel stays signed out. - A site whose server can mint the bridge’s one-time login code for the signed-in person. If your login page already does this for Claude and ChatGPT, reuse that code. The OAuth bridge guide describes it.
Add it to your site
Section titled “Add it to your site”Turn on sign-in from your site
Add app: true to the bridge in src/mcp.ts. The bridge then serves /app/session, where the
panel starts, finishes, refreshes and ends its sign-ins:
const bridge = await oauthBridge({ ...bridgeOptions, storage: host.oauthStorage, app: true });Give mcpServer an app
origins lists the sites that may embed the panel. Everything else is optional:
import { mcpServer } from "@flow-engineer/flow/mcp";import { oauthBridge } from "@flow-engineer/flow/oauth";import { cli } from "./cli.ts";// tools, dir and bridgeOptions as in your existing src/mcp.ts
export async function mcp(agent, host) { const bridge = await oauthBridge({ ...bridgeOptions, storage: host.oauthStorage, app: true }); return mcpServer({ name: "acme", version: "1.0.0", tools, dir, auth: bridge.auth, agent, app: { origins: ["https://www.example.com"], site: "https://www.example.com", title: "Acme", subtitle: "Your orders and account", logo: "https://www.example.com/icon.png", greeting: "Hi! I can check your orders, change a delivery or update your account. What do you need?", suggestions: ["Which of my orders are late?", "Show my invoices this month"], launcher: { label: "Ask Acme" }, theme: { accent: "#645bff", radius: 8 }, url: "https://mcp.example.com/mcp", cli: { file: cli, install: "curl -fsSL https://cli.example.com | sh" }, }, });}cli is the configuration your src/cli.ts exports with defineCli. With it, each step
shows its CLI command and the panel offers the terminal.
Sign people in from your site
Before the script tag, tell the panel who is signed in and how to get a code for them:
<script> window.FlowAppConfig = { account: currentUser.id, // a different id signs the panel in afresh signIn: async (request) => { // { nonce, returnTo, clientId, resource } const response = await fetch("/api/flow-app/code", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(request), }); return response.ok ? response.json() : null; // { code, state: request.nonce }, or null }, };</script>/api/flow-app/code is your own route, behind your site’s session. It receives the four values
your login page receives as nonce, return_to, client and resource, mints the same
single-use code for the signed-in account, and returns { code, state } with state set to the
nonce. It never redirects. Return null when no one is signed in: the panel stays signed out, and
a message sent there is answered “Sign in to Acme on this site to chat.”
Add the script tag
Put it on every page that should show the launcher:
<script async src="https://<agent address>/app/embed.js"></script>On Flow’s hosting, the agent address is FLOW_AGENT_URL. If your site sends a Content Security
Policy, allow the agent’s address in script-src, frame-src and connect-src, and the logo’s
host in img-src.
Check it worked: sign in on your site and reload. A launcher labelled “Ask Acme” appears at the bottom right. Open it: the panel slides in, the page moves over, and the header shows your subtitle with a green dot. Ask “Which of my orders are late?”: a step appears for the tool the agent runs, then its answer. Go to another page: the panel is still open with the same conversation.
If the launcher does not appear, the browser console says
FlowApp: this site may not embed the app, or the agent is unreachable.: check that the page’s
origin is exactly one of origins.
Options
Section titled “Options”Every option of mcpServer's app
| Option | What it does |
|---|---|
origins | Required. The sites that may embed the panel, as exact origins: https, or http only for localhost, 127.0.0.1 and [::1] |
title | The panel’s name. Default: the server’s name |
subtitle | A line under the title. Without signIn on your page, it reads “Sign in on this site to use your account” instead |
logo | The brand’s mark, an https or data:image/ URL, on the launcher, the header and the agent’s messages. Default: the title’s first letter |
greeting | What the panel says first, in Markdown. Default: “Hi! I can look things up and get things done in your title account. What do you need?” |
placeholder | The message field’s placeholder. Default “Ask title…” |
suggestions | Questions offered before the first message. Default: the titles of the first four read-only tools |
launcher | label (default the title), position ("right", the default, or "left") and shape ("pill", the default, with the logo and label; "circle", the logo only; "tab", a slim tab on the page’s edge) |
width | The panel’s starting width in px, 340 to 720. Default 420. People can drag it, and the browser remembers their width |
site | Your site’s address, such as https://www.example.com. Links to it open in the site. Default: the origin that embeds the panel |
pages | Your site’s real pages, as paths. See links to your site |
ui | Views the agent can answer with, on Flow’s hosting. See views |
url | The MCP URL people add to their assistant from the panel. Default: auth.resource, else this origin’s MCP path |
cli | { file, install }: your defineCli configuration and the command that installs the CLI. Each step then shows its CLI command, and the panel offers the terminal |
places | Which “Use it in” places the panel offers, in order. See the bottom row |
theme | The panel’s look. See customize the look |
panel | Your own code for the panel’s parts. See parts in code |
onboard | A button for your site’s pages that hands a coding agent your setup prompt. See the onboard button |
The server refuses to start with a clear message when an origin is not exact, logo or
theme.fontUrl is not https or data:image/, places names an unknown place, places has
"terminal" without cli, or the panel file cannot be read.
Sign-in
Section titled “Sign-in”The panel asks your page for a code when it opens and has no valid sign-in. It keeps the person’s
refresh token in its own origin’s storage and refreshes from it on later visits, as long as
account is unchanged.
The page can update the panel through window.FlowApp:
| Call | What it does |
|---|---|
FlowApp.configure({ account, signIn, navigate, pageFailed }) | Changes the settings. A different account signs the panel out, clears its conversation and signs in again |
FlowApp.signOut() | The person signed out on your site: the panel ends its sign-in, revoking the token, and clears its conversation |
FlowApp.open(), FlowApp.close() | Opens or closes the panel |
FlowApp.onboard(element, { label, variant }) | Draws the onboard button in element |
To hide the floating launcher on a page, set FlowAppConfig.launcher: false before the script tag.
The panel still opens from FlowApp.open() or the onboard button.
Call FlowApp.signOut() from your site’s sign-out, and FlowApp.configure after a single-page
app signs someone in without a page load. Without FlowAppConfig.signIn, the panel stays signed out.
Links to your site
Section titled “Links to your site”When the agent links one of your site’s pages, in Markdown such as [Your invoices](/billing/invoices)
or in a view, a click opens it in your site, not in the panel:
- With
FlowAppConfig.navigate(path), your router takes it, as a single-page app needs. - Without it, the page loads
pathas a normal navigation.
window.FlowAppConfig = { ...config, navigate: (path) => router.push(path), pageFailed: () => document.querySelector("[data-error]")?.textContent ?? null,};After the page settles, the panel checks it: an error status, a page whose title says “not found” or
404, a redirect
to another path, or pageFailed() returning a reason (or true) counts as a failed link. On Flow’s
hosting each result is reported to Flow for your insights.
Give pages to keep the agent to pages that exist. Each is a path, with {name} standing for one
segment; a query or hash may follow:
app: { // ... pages: ["/orders", "/orders/{id}", "/billing/invoices", "/settings/team"],}With pages, a link in an answer that is not one of them opens the nearest page above it that is
(/orders/123/items opens /orders/123), and is reported as failed. A view with such a link is
refused before it is shown, and the agent is told which pages exist. Also tell the agent about your
pages in a skill: which results have a page, and which are found from a list page.
Show answers as views
Section titled “Show answers as views”On Flow’s hosting, the agent can show the main part of an answer as a view in your look: a list of
orders, one order’s details, the page to go to. Give the views as ui; each becomes a tool named
ui_<name> that the agent fills in with what answers the question.
import { readFileSync } from "node:fs";import { z } from "@flow-engineer/flow";import type { AppUi } from "@flow-engineer/flow/mcp";
const template = (name: string) => readFileSync(new URL(`./${name}.html`, import.meta.url), "utf8");
export const ui: AppUi[] = [ { name: "list", description: "Several things as rows (a title, a line under it, an optional badge), each opening its page: orders, invoices, team members.", input: z.object({ title: z.string().optional(), items: z.array(z.object({ title: z.string(), subtitle: z.string().optional(), badge: z.string().optional(), href: z.string().describe("The page where this lives, such as /orders/ord_123"), })).min(1), }), template: template("list"), },];Then pass ui (and pages) in app. The template is HTML with placeholders, filled in the browser
with the agent’s input:
<div class="v"><style>.v{font:13.5px/1.45 system-ui,sans-serif}.v .row{display:flex;gap:12px;padding:12px 14px;border-top:1px solid #f4f4f5;color:inherit;text-decoration:none}.v .sub{font-size:12px;color:#6b7280}</style><h3>{{title|default:Results}} ({{items|count}})</h3>{{#items}} <a class="row" href="{{href}}"> <div><b>{{title}}</b>{{#subtitle}}<div class="sub">{{subtitle}}</div>{{/subtitle}}</div> {{#badge}}<span>{{badge}}</span>{{/badge}} </a>{{/items}}</div>Expected result: asked “Which of my orders are late?”, the agent runs your order tool, calls
ui_list with the late orders, and adds a sentence the list does not show. The panel draws the list
under the steps. Clicking a row opens that order’s page in your site.
How views behave:
- One view per answer. A second
ui_call in the same answer is refused, and the agent puts the rest in its words. The agent is told to use a view only when it helps, and not to repeat in its words what the view shows. A single fact or a question back needs none. - Links are checked. With
pages, everyhreforpathvalue in the input must be one of them (links to other sites,#…andmailto:are not checked). Otherwise the view is not shown, and the agent is told the real pages and calls again. - Only on Flow’s hosting. The
ui_tools exist only when the process hasFLOW_APP_SERVICE_URL, which Flow’s hosting sets, and the agent’sFLOW_KEY. Self-hosted, the agent answers in Markdown and everything else works the same. - Only in the web app. The
ui_tools are a tool group namedviews, limited to theappchannel: never offered on MCP, the CLI or other channels.mcpServeradds it to the agent. To pass it yourself (for tests), give createAgentgroups: [uiTools(ui, pages, site)]from@flow-engineer/flow/mcp; mcpServer then keeps yours. - Safe by design. A view is drawn in a sandboxed frame with no scripts, up to 640 px tall. Every
value is escaped, and lists and objects are never written into the page. The frame does not
inherit the panel’s CSS: style the template itself. It gets
theme.fontUrl.
In a template:
{{field}}writes a value, escaped. Dotted paths work, and{{.}}is the current item.{{#field}}…{{/field}}repeats for each item of a list, or shows once for a value that is set;{{^field}}…{{/field}}shows when it is empty or false.- Filters follow a
|:number,compact(1.2M),date,datetime,truncate:N,pct:other,pctmax:list.field,count,default:textandurlencode. href="/a/page"opens that page in your site,href="#ask:<message>"sends the message as the person’s next one, andhref="#copy:<value>"copies the value. Other links open in a new tab.
Keep each view’s input to a few general fields, and describe what it shows and when to use it.
Customize the look
Section titled “Customize the look”theme sets the panel’s look. Every value has a default.
| Option | What it does |
|---|---|
mode | "light", "dark" or "auto" (default, the person’s setting) |
accent | The brand color: the launcher, the person’s messages, buttons and links. Default #2457d6 |
accentText | Text on the accent. Default: white or near-black, whichever reads better |
colors, dark | Any of background, surface, text, muted and border, for light and dark |
font, fontUrl | A CSS font-family, and the https stylesheet that loads it (and monoFont) |
monoFont | The font for commands and code. Default: the system’s monospace font |
radius | Corner radius in px. Default 14 |
style | "soft" (default, rounded bubbles), "sharp" (square corners, ruled lines), "glass" (frosted header, accent glow) or "minimal" (no bubbles) |
pattern | Behind the chat: "none" (default), "dots", "grid" or "glow" |
density | "comfortable" (default) or "compact" |
css | Your own CSS for the panel, applied last |
theme: { accent: "#645bff", font: "Geist, system-ui, sans-serif", monoFont: '"Geist Mono", ui-monospace, monospace', fontUrl: "https://fonts.googleapis.com/css2?family=Geist:wght@400;600&family=Geist+Mono&display=swap", radius: 8, style: "soft", pattern: "dots", density: "compact", colors: { surface: "#f5f7fa", border: "#e5e7eb" }, css: readFileSync(new URL("./ui/panel.css", import.meta.url), "utf8"),},Style parts with CSS
Section titled “Style parts with CSS”Each part’s root has a stable data-part attribute beside its class, whether the panel or your
module drew it:
data-part | Class |
|---|---|
header | .head |
message | .msg.me and .msg.agent, each with a .bubble |
typing | .msg.typing |
background | .backdrop, behind the whole panel |
composer | .composer, with the field .field and the button .send |
Other stable classes: .thread, .welcome, .greeting, .starter, .steps, .line and .copy
(a command and its copy button), .view-box, .sheet, .primary. The root element carries
mode-<mode>, style-<style>, pattern-<pattern> and density-<density>, and the colors are CSS
variables: --accent, --on-accent, --background, --surface, --text, --muted, --border,
--r (the radius), --font, --mono and --gap.
.greeting{font-size:20px;font-weight:600;letter-spacing:-.02em}.steps,.starter{background:var(--surface)}.copy{background:#22221f;color:#fff;border:0}Draw parts in code
Section titled “Draw parts in code”panel names a browser module in your repository that draws any of the panel’s parts. Your agent’s
process serves it at /app/parts.js:
app: { // ... panel: new URL("./ui/panel.ts", import.meta.url), // or a path from the working directory}It exports any of header, message, typing, background and composer (the AppPanel type).
Each gets the element the panel drew and what it shows, and returns the node to show: that element
restyled, wrapped, or a new one.
import type { AppPanel } from "@flow-engineer/flow/mcp";
// The agent's answers on a card with a hairline border.export const message: AppPanel["message"] = (element, { role }) => { if (role === "agent") element.querySelector<HTMLElement>(".bubble")!.style.border = "1px solid var(--border)"; return element;};
// The field and the send button in your own box. They keep their behaviour wherever they go.export const composer: AppPanel["composer"] = (element, { input, send }) => { const box = document.createElement("div"); box.className = "my-composer"; box.append(input, send); return box;};| Export | Receives | Notes |
|---|---|---|
header | { title, subtitle, logo, mark, status, newChat, close } | status changes as the person signs in. newChat and close work wherever you place them |
message | { role: "me" | "agent", text, body } | Called for each message. body is the agent’s Markdown, already drawn safely |
typing | { avatar } | Shown while the agent answers, then removed |
background | { pattern, mode } | A layer behind the panel, drawn once. It takes no clicks |
composer | { input, send, placeholder } | Enter sends, Shift+Enter adds a line, and both are off while the agent answers |
- The module is one file. It may import only types (
import type). A TypeScript file has its types stripped as Node does, so enums and namespaces are not supported; a.jsfile is served as it is. A file that cannot be read, or that imports anything else, stops the server at start. - Fallbacks. A part you do not export stays the panel’s own. If your function throws or returns no node, or the module fails to load, the panel draws its own and logs why in the console. A composer that leaves out the field or the send button is not used.
- Write the person’s and the agent’s text with
textContent, or placebody. Never setinnerHTMLfromtext.
The bottom row
Section titled “The bottom row”Under the message field, every panel shows one row: Use it in, with an icon for each place the same tools work, and Powered by Flow. The row is always shown.
You choose only which places it offers and in what order, and where they point:
app: { // ... places: ["claude", "terminal", "cursor"], // any of terminal, claude, chatgpt, cursor, vscode url: "https://mcp.example.com/mcp", // what Claude, ChatGPT, Cursor and VS Code add cli: { file: cli, install: "curl -fsSL https://cli.example.com | sh" }, // what the terminal offers}By default it offers all five, the terminal first and only when cli is set. places: [] leaves only
“Powered by Flow”.
“Powered by Flow” cannot be removed or hidden. The panel draws the row outside the reach of
theme.css and your panel module, and puts it back if a script moves or covers it. The row’s colors
follow the theme’s background, text and muted colors while they read clearly, else the panel’s
defaults. To go without it, build your own interface against /app/chat.
The “Use it in” sheet
Section titled “The “Use it in” sheet”Clicking a place opens a sheet titled “title in place”: “The same tools as this chat, signed in as
you”, then:
| Place | What it shows |
|---|---|
| Terminal | The cli.install command, then <cli name> login. Every step in the chat shows the command that does the same |
| Claude | Settings → Connectors → Add custom connector, with the MCP url; and the claude mcp add --transport http command for Claude Code |
| ChatGPT | Settings → Apps → Create app (developer mode), with the MCP url |
| Cursor | An Add to Cursor button, or the MCP url to add in Cursor’s settings |
| VS Code | An Add to VS Code button, or MCP: Add Server with the MCP url |
Each command and URL has a copy button.
Add an onboard button
Section titled “Add an onboard button”Available in Framework 0.18.0. For developers who set up your product with a coding agent, put a “Set up with AI” button on your site’s pages, such as your docs or your dashboard’s empty state. It shows your setup prompt, copies it, and opens the panel for questions.
app: { // ...the options above onboard: { prompt: "Set up Acme in this project: install @acme/sdk, add ACME_KEY to .env, then ...", label: "Set up with AI", // default "Onboard with AI" agents: ["claude", "chatgpt", "cursor"], // the assistants' icons on the button; default all askLabel: "Ask Acme", // the button that opens the panel; default "Ask <title>" },},Place it on any page that loads embed.js:
<div data-flow-onboard></div><!-- or with your own label: <div data-flow-onboard data-label="Set up Acme with AI"></div> -->FlowApp.onboard(element, { label, variant }) draws one from code, and
FlowAppConfig.onboard: { label, variant } sets the label for every button on the site.
Expected result: a pill with the assistants’ icons and the label. Clicking it opens a popover
with the prompt, Copy prompt (copies it and says where to paste it) and Ask Acme (opens the
panel). The popover’s “Powered by Flow” line is always shown. The prompt is also in the page, in a
visually hidden [data-flow-onboard-prompt] element, so agents and scrapers reading the page find
it. The server refuses to start when onboard.prompt is empty or agents names an unknown assistant.
Markdown in replies
Section titled “Markdown in replies”The agent’s replies are drawn from a safe subset of Markdown. Everything is escaped first, so raw HTML never reaches the page:
**bold**and__bold__,*italics*and_italics_,~~strikethrough~~`code`and fenced code blocks- lists starting with
-,*,•or1., and line breaks - links to
httpsorhttpaddresses, bare URLs, and links to a path on your site such as[Your invoices](/billing/invoices). A path link opens in your site as described in links to your site. Any other scheme, such asjavascript:, stays plain text.
Headings and tables are not drawn. On this channel the agent is told to bold the one or two things that matter, and to end an answer about something on your site with a link to its page.
Test it
Section titled “Test it”flow test scenarios on the web channel run on your agent’s custom-UI channel. To check the web
app’s behaviour, give that channel the app’s settings in test runs: info: { showsTools: true },
and, if you use views, UI_INSTRUCTIONS and the uiTools(ui, pages, site) group from
@flow-engineer/flow/mcp in createAgent’s groups.
Since 0.18.0, flow test plays group tools such as ui_ views like the agent’s own: the test cloud
records and simulates them, and calls and never work on them. On a channel with showsTools,
the simulated person and the judge see each tool call. Run a scenario on the app’s channel by name
with channels: [app].
Build your own interface
Section titled “Build your own interface”The panel’s routes are listed in the server’s paths, so Flow’s hosting serves them: /app,
/app/embed.js, /app/config, /app/parts.js, /app/chat, /app/view, /app/link and
/app/command, plus the bridge’s /app/session.
For a chat interface of your own, without the panel and its bottom row, call /app/chat with a
token for the person. It works like terminal chat, on the app
channel:
curl -N https://<agent address>/app/chat \ -H "authorization: Bearer $TOKEN" \ -H "accept: application/x-ndjson" \ -H "content-type: application/json" \ -d '{"text":"Which of my orders are late?"}'Expected result: one JSON object per line: {"type":"activity","event":{...}} for each tool as
it starts and ends (type, callId, tool, input, output, ok, ms), {"type":"reply","text":"..."}
for each message, and {"type":"done","result":{"conversationId":"...", ...}} at the end. Send
conversationId back with the next message, or {"reset":true} to start a new chat. Without the
accept header, the answer is one JSON object after the turn.
Thanks, we read every comment.