When to use it
- A coding agent in development calls the app's tools through the dev MCP, and reads the running page through the dev MCP's own
isoloop_*tools. - A browser agent calls them through WebMCP, where a browser has it.
Both call the same tool surface, and the isolate that answers doesn't know or care which one asked.
To watch a running page without exposing any tool, read the inspection guide instead: the dev MCP's isoloop_* reads come from that feed.
A topic as a tool
// contracts.ts: a requestable topic (it has a `reply`) with a tool description
import { topic } from '@isoloop/bus';
import * as s from './schemas';
export const quoteTool = topic('markets.quote.v1', {
schema: s.quoteRequest,
reply: s.quoteReply,
retention: { kind: 'last-n', n: 100 },
tool: {
title: 'Quote',
description:
"The latest figures for one symbol: VWAP, cross-market spread and volume over the dashboard's window (null with no trades in it), and each exchange's last, bid and ask.",
readOnly: true,
},
});
// main.ts: the kernel lists which topics agents may call
import { createKernel } from '@isoloop/host';
const kernel = createKernel({ contracts, workers, agents: { expose: ['markets.quote.v1'] } });
The worked example throughout is the markets dashboard (isoloop/web apps/dashboards/markets). It exposes two tools: markets.quote.v1, a read-only quote answered by the aggregator isolate, and markets.alerts.create.v1, which adds an alert rule through the alerts isolate.
A tool is a topic with a reply schema and a tool field. Its name is always the topic's name.
tool field |
Meaning |
|---|---|
description |
Required. What the tool does, for the agent choosing it. |
readOnly |
Required. true if a call changes nothing. WebMCP and MCP readOnlyHint. |
title |
A short human-readable name. |
consequential |
The call has effects the user should confirm. WebMCP consequentialHint, MCP destructiveHint. Default false. |
untrustedContent |
The reply can carry third-party text. WebMCP untrustedContentHint. Default false. |
The tool field stays on the host: it isn't part of the topic config the bus sees, and a tool field alone exposes nothing.
Exposing tools: agents.expose
import { createKernel } from '@isoloop/host';
createKernel({
contracts,
workers,
agents: { expose: ['markets.quote.v1', 'markets.alerts.*'], timeoutMs: 10_000 },
});
exposetakes grant patterns: without*a pattern names one topic;*matches one or more characters, dots included, somarkets.*coversmarkets.alerts.create.v1.- Every topic it matches needs a
reply, atoolwith a non-emptydescriptionand a booleanreadOnly, and schemas that make JSON Schema (Standard JSON Schema, draft 2020-12). OtherwisecreateKernelthrowsKernelError('not_exposable'), naming the topic. A schema built withunchecked()can't make JSON Schema, so its topic can't be a tool. - A pattern that matches nothing isn't an error. It's reported once, through the
agents:unmatchedevent:kernel.on('agents:unmatched', ({ patterns }) => …). timeoutMsis how long transports wait for a tool's reply. Default 10 s.kernel.tools()lists the exposed tools, made once atcreateKernel: name, title, description, the three hints, the input and output JSON Schemas,timeoutMs, andtopic. Everything buttopicis plain data. It's empty withoutagents.
Answering a tool call
An isolate answers a tool call the way it answers any request: it subscribes to the topic and replies to records that carry req. Markets' alerts isolate:
import { defineIsolate } from '@isoloop/runtime';
import { busSource, runAlerts } from './alerts';
import { createAlertTool } from './contracts';
export default defineIsolate({
start(ctx) {
const svc = runAlerts(busSource(ctx.bus));
ctx.bus.subscribe(
createAlertTool,
async (r) => {
if (r.req === undefined) return; // a plain record, not a request
await ctx.bus.reply(r, svc.create(r.req.id, r.value));
},
{ from: 'committed' },
);
},
});
The isolate needs a subscribe grant for the topic, as for any request. The first valid reply wins, checked against the reply schema.
Handlers must be idempotent
Delivery is at least once, as for every handler on the bus. A crash after the handler's side effect but before its reply delivers the request again, so a tool that changes something would do it twice. Its handler has to recognise a request it has already handled by req.id. Markets derives the rule's id from the request's id (agent-${req.id}) and publishes the rule under that key, so a request delivered again adds nothing new:
create(requestId, rule) {
const id = `agent-${requestId}`;
const created = !engine.has(id);
if (created) engine.setRule({ removed: false, id, ...rule });
src.publish('alertRules', { removed: false, id, ...rule }, id);
return { id, created };
}
The bus doesn't de-duplicate request records itself.
Calling from the host: kernel.request
Transports call tools through kernel.request. It works on any requestable topic, exposed to agents or not.
const controller = new AbortController();
const tool = kernel.tools().find((t) => t.name === 'markets.quote.v1')!;
const reply = await kernel.request(tool.topic, { symbol: 'BTC-USD' }, {
timeoutMs: tool.timeoutMs,
signal: controller.signal, // controller.abort() rejects with `aborted`
via: 'webmcp', // set on the record as `req.via`
});
| Option | Meaning |
|---|---|
timeoutMs |
Default 30 s, the bus's. Transports pass the tool's timeoutMs (10 s unless agents.timeoutMs says otherwise). |
signal |
Aborting it rejects the call with BusError('aborted'). |
via |
'mcp', 'webmcp' or 'builder': the transport making the call. Anything else is invalid. |
key |
The request record's key. |
It rejects with a BusError:
no_responderat once when no isolate could answer: none has a subscribe grant for the topic, or every one that has is stopped orfailed. Passing this check doesn't promise a reply.timeoutaftertimeoutMs. An isolate that restarts within the timeout still gets the request and can answer it.abortedwhensignalaborts.droppedat once when the topic's retention removed the request before the bus handed it to any subscriber, as in a burst of more calls than the topic keeps. A request already delivered stays its responder's to answer.forbiddenforisoloop.*topics, andunknown_topic,not_requestable,invalid,reply_invalidandbus_unavailable, asbus.requestdoes.
Size a tool's topic's retention for its largest burst of calls. Requests are records in the topic's log, so its retention caps how many calls can wait at once. On a topic keeping 100 records, a burst of 1,000 calls at once gets 100 answers and 900 dropped (isoloop#288). An isolate's own bus.request gets dropped the same way.
In development: the dev MCP
isoloop mcp (the isoloop package's CLI) is an MCP server over stdio for coding agents. Pages in development dial its WebSocket on 127.0.0.1, and it lists their exposed tools plus its own isoloop_* tools for reading the page.
claude mcp add isoloop -- npx isoloop mcp # Claude Code
claude mcp add isoloop -- npx isoloop mcp --allow-write # also the tools that change something
Or in a project's .mcp.json:
{ "mcpServers": { "isoloop": { "command": "npx", "args": ["isoloop", "mcp"] } } }
In the page, behind import.meta.env.DEV:
if (import.meta.env.DEV) {
const token = import.meta.env.VITE_ISOLOOP_MCP_TOKEN;
if (token) {
const { connectDevMCP } = await import('@isoloop/host/dev-mcp');
connectDevMCP(kernel, { token, title: 'markets' });
}
}
- Pairing: any site open in the browser can dial
127.0.0.1, so the CLI accepts a page only with its token and only from an allowedOrigin(--origin, defaulthttp://localhost:*; comma separated,*for any). The CLI prints a fresh token on stderr at each start. For a fixed one, set the same value twice:ISOLOOP_MCP_TOKENfor the CLI andVITE_ISOLOOP_MCP_TOKENfor the page (Vite only shows the pageVITE_variables). - Port:
--port, default4317; the page'surloption defaults tows://127.0.0.1:4317. The page keeps trying while the CLI isn't running and reconnects after it restarts, backing off to one try every 30 s. A wrong token stops it. --allow-write: without it, the CLI lists only tools withreadOnly: trueand its own reads. With it, it also lists the app's other tools and its writes.- Its own tools:
isoloop_pageslists the connected pages; every other tool takes an optionalpage(default: the page that connected last among those exposing the tool). The reads come from the page's inspection feed (inspection guide):isoloop_isolates,isoloop_topics,isoloop_records(what a topic retains),isoloop_tapandisoloop_events.isoloop_tap { topics, ms?, max? }is a live sample: it taps the topics forms(3 s by default, at most 10 s), stops early atmaxrecords (at most 100), and returns{ records, skipped, ms }. Like the panel's log, it gets at most 50 records a second, counted in fixed one-second windows, so up to 100 can arrive within about a second either side of a window boundary;skippedis how many the bus left out over that, reported once a second, so the last second's count can be missing. The writes need--allow-write:isoloop_restart,isoloop_kill,isoloop_block,isoloop_publishandisoloop_request. Their names are reserved: an app tool with the same name isn't listed. - Calls go through
kernel.request(…, { via: 'mcp' })with the tool'stimeoutMs. - Production builds:
@isoloop/vitefails a production build whose output still containsconnectDevMCP. Imported behindif (import.meta.env.DEV), it's dropped and the build passes.isoloop({ allowDevMcp: true })turns the check off.
Markets runs both of its tools through the official MCP SDK client and the real CLI in its E2E (e2e/dev-mcp.spec.ts, Chromium).
In the browser: @isoloop/webmcp
WebMCP is a Community Group draft for pages to offer tools to an agent built into the browser. @isoloop/webmcp registers the kernel's exposed tools with it:
import { connectWebMCP } from '@isoloop/webmcp';
const disconnect = connectWebMCP(kernel);
// later: disconnect();
- Each tool is registered with its name, title, description, input and output JSON Schemas and hints. A call runs
kernel.request(tool.topic, input, { timeoutMs: tool.timeoutMs, signal, via: 'webmcp' })and resolves with the reply. - Tools stay registered while their isolates restart.
- Disconnecting unregisters every tool and aborts the calls still in flight.
- Without WebMCP it does nothing and returns a function that does nothing. Isoloop has no shim of its own; in development the dev MCP covers other browsers.
- With a polyfill. If the page imports
@w3c/webmcp-polyfill/autobefore callingconnectWebMCP, the tools register on thedocument.modelContextit installs, in a secure context. The polyfill leaves a nativedocument.modelContextalone (Chromium). Firefox 159 has WebMCP only onnavigator, so there the polyfill still installs adocument.modelContext,connectWebMCPregisters on it, and the tools don't reach Firefox's own WebMCP. The polyfill keeps the tools in the page, so they reach an agent only through something that readsdocument.modelContext, such as an extension. Checked by hand with version 0.1.1 in Chrome 153, not in CI or Firefox.
Both browsers that have WebMCP keep it behind a flag. It's tested under Playwright only: Chromium with --enable-features=WebMCP, and Firefox with dom.modelcontext.enabled. The two differ, and connectWebMCP follows the features each one has, not its name:
| Chromium 158 | Firefox 159 | |
|---|---|---|
| Where | document.modelContext |
navigator.modelContext |
| Hints the agent sees | all three | only readOnlyHint; no title |
| Cancelling a call from the agent | yes | no: the call runs until its reply or its timeoutMs, then the agent gets timeout |
| What the agent sees when a call fails | "Tool execution failed"; the BusError is only in the page's console |
the BusError's message |
- Hints are sent only when true, because Firefox lists a tool as read-only whenever
readOnlyHintis present, even asfalse. The draft's defaults are false, so Chromium lists the same thing. - Firefox's agent doesn't see
consequentialHintoruntrustedContentHint, so it can't tell a consequential tool from any other that isn't read-only, or know that a reply can carry third-party text. Descriptions aren't edited to make up for it. If confirmation matters, ask the user in the page. - Cancelling in Chromium names only the tool, so it aborts every call of that tool in flight.
- A tool name registered twice: a
connectWebMCPwhose tools an earlier one on the page registered, and hasn't unregistered, throwsKernelError('invalid_config')naming the tool, and registers nothing. That's the same on both browsers; on their own, Chromium rejects the name and Firefox replaces the tool.
Limits
- All of it is
@experimentalin 0.1. - The hints describe; they don't enforce.
readOnly,consequentialanduntrustedContentare passed to the agent as hints. Nothing in Isoloop stops a call because of them, apart from the dev MCP's--allow-write(above). - Asking the user is the agent's job. A consequential tool runs on agent input. WebMCP also leaves confirmation to the agent. If a tool must not run without the user's say, the app has to ask in its own UI.
viais not a security boundary. Any code on the main thread can callkernel.requestwith anyvia. It's a label for logging and policy between cooperating code on one page. Don't authorize anything by it.- An untrusted reply: with
untrustedContent: true, the reply can carry third-party text (markets' quotes don't; a tool returning user comments would). The agent should treat it as data, not instructions. - The bus doesn't de-duplicate request records, so handlers that change something must be idempotent by
req.id(above). - A tool's topic's retention caps a burst of calls (above).
- WebMCP is behind a flag in both browsers that have it, and tested under Playwright only (above).
See also
- The inspection feed, where the dev MCP's reads come from.
- The devtools panel, the same feed drawn in the page.
- WebMCP, the Community Group draft.