Skip to content

Cross-host client

connectUI(options) is the push-first, cross-host path. It renders one Synapse component in any host that speaks the MCP Apps standard (ChatGPT, Claude, NimbleBrain) and standalone, behind a single façade. It is decoupled from @modelcontextprotocol/* so the window.SynapseUI IIFE stays small.

import { connectUI } from "@nimblebrain/synapse/host";
const synapse = connectUI({ name: "my-app", version: "1.0.0" });
function connectUI(options: ConnectUIOptions): SynapseUIClient;
Option Type Description
name string Component name
version string Semver version
host HostKind? Force a host adapter. Auto-detected if omitted.
dataElementId string? DOM element id carrying the host-injected tool-result payload
autoResize boolean? Observe content and auto-send height. Default true
window Window? Target window. Defaults to the current global.

HostKind names the bridge, not the product. A framed component gets "mcp-apps" in every host, because every host speaks that bridge; a top-level document gets "generic":

type HostKind = "mcp-apps" | "generic";
Method Description
data() Return the current tool-result data
onData(cb) Subscribe to data changes. Returns an unsubscribe function.
theme() Return the current theme
onTheme(cb) Subscribe to theme changes. Returns an unsubscribe function.
callTool(name, args) Call a host tool (pull) and get the result. Rejects with ToolCallError when the result reports isError: true
sendPrompt(text) Send a prompt to the agent
openLink(url) Open a URL via the host
resize(height) Send a new height to the host
capabilities() Return the detected host capabilities
host() Return the detected HostKind
destroy() Tear down listeners and bridges