Skip to main content

Server half of the Synapse cross-host UI framework: register one self-contained ui:// component from a FastMCP server and render it in ChatGPT (OpenAI Apps SDK), Claude (MCP Apps), and the NimbleBrain runtime.

Project description

nimblebrain-synapse (Python)

The server half of the Synapse cross-host UI framework. Pairs with the @nimblebrain/synapse client (connectUI / window.SynapseUI).

pip install nimblebrain-synapse   # or: uv add nimblebrain-synapse

One SynapseUI declaration wires a self-contained HTML component into every host bridge a Synapse app renders in — ChatGPT (OpenAI Apps SDK), Claude (MCP Apps), and the NimbleBrain runtime — from a FastMCP server, replacing the per-app hand-rolled shim.

from mcp.server.fastmcp import FastMCP
from nimblebrain_synapse import SynapseUI

mcp = FastMCP("bassethound")

report_ui = SynapseUI(
    uri="ui://bassethound/report",
    template=load_template(),            # data-free HTML (carries the SDK + data markers)
    preferred_size=("100%", "auto"),
)
report_ui.register(mcp)                   # skybridge ui:// resource, SDK inlined

@mcp.tool(meta=report_ui.tool_meta(invoking="Picking up the scent…", invoked="Dossier ready"))
async def analyze_domain(domain: str) -> Dossier:
    ...

report_ui.bind(mcp, tool="analyze_domain", should_render=lambda d: "domain" in d)

register serves the ChatGPT-facing skybridge resource (data-free). bind post-processes the CallToolResult for one tool: appends the mcp-ui embedded ui:// resource (dossier baked into a <script>) and mirrors the ChatGPT _meta. Plain MCP clients ignore both and still read structuredContent.

Template contract

The template is data-free HTML that carries two markers:

  • <!--__SYNAPSE_SDK__--> — replaced with the inlined client SDK <script>.
  • <script type="application/json" id="synapse-ui-data">/*__SYNAPSE_DATA__*/</script> — the data slot; render_html(data) substitutes the escaped payload here (the served copy leaves the marker, so the client reads null and falls back to the host's push).

SynapseUI._safe_json escapes the payload for <script> embedding (the XSS defense) — framework-owned and on by default.

Interface debt

bind wraps FastMCP's CallToolRequest handler — a leak into FastMCP internals, quarantined in this one place. See the # TODO: upstream a real FastMCP result-transform hook note in server.py.

Client SDK asset

nimblebrain_synapse/_assets/synapse-ui.iife.js is the vendored client IIFE (window.SynapseUI), regenerated from the JS build (dist/synapse-ui.iife.global.js) and inlined at register time so a component is fully self-contained (CSP-safe, no CDN). CI fails on drift from the build. nimblebrain_synapse.__client_version__ records which @nimblebrain/synapse release the bundled IIFE was built from.

Versioning & compatibility

nimblebrain-synapse (PyPI) versions independently of @nimblebrain/synapse (npm). They change for different reasons at different cadences — the server descriptor is thin and stable; the JS client evolves with host adapters and theming — so they do not share a version number. The exact client build a given release bundles is recorded in nimblebrain_synapse.__client_version__ (and, per release, in the CHANGELOG); CI keeps it equal to the sibling package.json at HEAD.

What both halves share is the wire protocol — the ui:// resource MIMEs, the _meta dialects, and the data-element contract:

  • ext-apps 2026-01-26
  • MCP Apps (SEP-1865)
  • OpenAI Apps SDK

Releases publish on a nimblebrain-synapse-v* tag (distinct from the npm v* tags).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nimblebrain_synapse-0.2.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nimblebrain_synapse-0.2.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file nimblebrain_synapse-0.2.0.tar.gz.

File metadata

  • Download URL: nimblebrain_synapse-0.2.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for nimblebrain_synapse-0.2.0.tar.gz
Algorithm Hash digest
SHA256 183e3bbd550dbeef93342bf61e7fd1efed985c8fd9f3231e768b896beb47c8e3
MD5 fbd5b8073f28e5443828113f91760c45
BLAKE2b-256 635af8d39f544b661b6899076f87c8e072251ff8cfa0b13fd1f75edf9ebdf7d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for nimblebrain_synapse-0.2.0.tar.gz:

Publisher: publish-python.yml on NimbleBrainInc/synapse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nimblebrain_synapse-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nimblebrain_synapse-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f62ea8197076f598a3ab8a0159ac80de0c8d20200bfda599d2b56b35d11cfbe
MD5 f0eb16b7654cfa0eae83301297ab5fa5
BLAKE2b-256 19976816b3321e6df93d75d4359c8b39bf9c495eff0f1476fbd78d584e2e0d9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for nimblebrain_synapse-0.2.0-py3-none-any.whl:

Publisher: publish-python.yml on NimbleBrainInc/synapse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page