Skip to content

About

A simple web development server using iridium notebooks

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

Repository files navigation

Iridium Dev Server

Local dev server for working with Observable notebooks: edit them in Iridium, save them as files, and compile them to ES modules you can embed in any app.

Published on npm as @a10k/iridium-dev-server (previously @wishyoulization/iridium-dev-server).

Cells are compiled by Observable's own engine, Notebook Kit: classic Observable JavaScript (viewof, mutable, import {x} from "@user/notebook", require(…)) and plain JavaScript cells (several statements, const declarations, npm: imports, display(…)), as in Observable Notebooks 2.0. Plain JavaScript cells may use TypeScript syntax (type annotations, interfaces): the types are removed and the cell runs as plain JavaScript, without type checking.

It also includes an MCP server and a skill, so AI assistants such as Claude can build notebooks with you, live, in the tab you're watching.

Requires Node.js 22 or later.

Quick start

Start a server in any folder (notebooks are saved there as <name>.html):

mkdir my-notebooks && cd my-notebooks
npx @a10k/iridium-dev-server

Open http://localhost:8080/ to edit the index notebook, or http://localhost:8080/my-notebook for any other (it's created on first save). Write a cell, run it with Shift+Enter, save with ⌘S / Ctrl+S. Running or saving writes the notebook file and its compiled module (<name>.js).

Try these cells, one per cell:

viewof n = Inputs.range([1, 100], { value: 20, step: 1, label: "Points" })
points = d3.range(n).map((i) => ({ x: i, y: Math.sin(i / 3) }))
Plot.lineY(points, { x: "x", y: "y" }).plot({ width })

Drag the slider and the chart follows: cells re-run when the values they use change.

To build notebooks with Claude instead, see Live collaboration and AI assistants.

Install

Run it with npx as above, or add it to a project:

npm i -D @a10k/iridium-dev-server

or install it globally to get the iridium-dev-server command everywhere:

npm i -g @a10k/iridium-dev-server

Importing other notebooks

Every saved notebook is also compiled to <name>.js next to it, so one notebook can import cells from another with a path starting ./, ../ or /:

import { points } from "./my-data.js"

Paths resolve against the page (the server root), so ./my-data.js is the compiled my-data notebook. Save the imported notebook first so its module is up to date. Names without a path (@d3/color-legend, or a notebook id) still load from observablehq.com, and full URLs are imported as written.

Other relative URLs in cells and in the head option (fetch("./data.json"), <img src="./libs/logo.svg">, <link href="./libs/index.css">) also resolve against the server root, so files in the static or compiled folders work with ./ paths. FileAttachment("x") reads from the notebook's own files folder (<notebooks>/<name>/).

Notebook list API

GET /api/notebooks?q=&page=1&per_page=25&sort=name|modified returns the notebooks whose name or title contains q (any case), one page at a time. For example, with my-notebook and my-data saved, GET /api/notebooks?q=my returns:

{
  "q": "my", "sort": "name", "page": 1, "per_page": 25, "pages": 1, "total": 2,
  "items": [
    { "name": "my-data", "title": "my-data", "url": "/my-data", "modified": "2026-11-21T10:00:00.000Z", "cells": 3, "size": 812 },
    { "name": "my-notebook", "title": "my-notebook", "url": "/my-notebook", "modified": "2026-11-21T10:05:00.000Z", "cells": 5, "size": 1240 }
  ]
}

DELETE /api/notebooks/<name> moves a notebook and its attachments folder to the Trash (macOS's, restorable with Put Back; elsewhere a .trash folder in the notebooks folder) and removes its compiled module.

per_page is at most 200, out-of-range pages are clamped, and the index notebook (the home page at /) isn't listed. A home page notebook can render it with a search input and pager: fetch the JSON in a cell and draw the cards with htl.html.

Live collaboration and AI assistants (MCP)

Every tab showing a notebook connects to the server (a green dot in its favicon, like the macOS traffic light; grey when offline), so an AI assistant can work on the notebook in that tab while you watch.

The server includes an MCP server, so assistants such as Claude can build and edit notebooks with you: they add and edit cells in the tab you're watching, and read each cell's live output (value, rendered text, errors) to check their work. Tools: create_notebook, open_notebook, list_notebooks, read_notebook, add_cell, add_cells, edit_cell, delete_cell, move_cell, run_cell, evaluate, screenshot_cells, save_notebook.

screenshot_cells returns PNGs of cells as your tab shows them. The tab captures itself with Chrome's tab capture (getDisplayMedia on the current tab), scrolling each cell into view and cropping to it. The first time, the tab asks you to allow it: click Allow tab capture, then share the tab. Capture stays on until you stop sharing in Chrome's bar.

Set up Claude Code

Once, from any folder:

claude mcp add --scope user iridium -- npx -y @a10k/iridium-dev-server mcp

Then install the skill (it teaches Claude the workflow and how to write good cells):

npm i -g @a10k/iridium-dev-server
mkdir -p ~/.claude/skills && cp -r "$(npm root -g)/@a10k/iridium-dev-server/skill" ~/.claude/skills/iridium-notebooks

(If you installed it in a project instead, copy node_modules/@a10k/iridium-dev-server/skill.) Check the connection with claude mcp list, then start a new chat.

Set up Claude Desktop and other MCP clients

Add the server to the client's MCP config (for Claude Desktop: Settings → Developer → Edit Config, claude_desktop_config.json), then restart it:

{
  "mcpServers": {
    "iridium": {
      "command": "npx",
      "args": ["-y", "@a10k/iridium-dev-server", "mcp"]
    }
  }
}

The same command/args work in Cursor, VS Code and other clients that launch stdio MCP servers. In clients that take skills, add the skill folder as a skill; elsewhere, the MCP server's own instructions are enough to get started.

Example prompts

Ask in a new chat:

  • "Make an Iridium notebook exploring a random walk: a slider for the number of steps, a line chart, and summary stats."
  • "Create an Iridium notebook that loads this CSV URL, shows it as a table, and charts the second column over time."
  • "Open my sales notebook and add a monthly revenue chart under the data cell."
  • "Take a screenshot of the chart cell and tighten its margins."
  • "Open it in Google Chrome." / "Save the notebook."

The notebook opens in your browser and fills in as the assistant works; edit cells yourself at any time and it sees your changes.

How it works

  • iridium-dev-server mcp speaks MCP over stdio. It serves the current folder's notebooks if it has an .iridiumrc, otherwise ~/Documents/Iridium (or IRIDIUM_HOME), created on first use with port 8090. If a dev server is already running there, it connects to it, so every chat reaches the same open tabs; otherwise it starts one.
  • A running dev server also serves MCP over HTTP at /mcp (e.g. claude mcp add --transport http iridium http://localhost:8080/mcp).
  • New notebooks open in your default browser, or in another one: assistants can pass browser (e.g. "Google Chrome"), and IRIDIUM_BROWSER sets it for every notebook. Set IRIDIUM_OPEN_BROWSER=0 to disable opening (e.g. when the assistant shows them in its own browser).
  • The assistant works on the notebook in your open tab, as you would: the server only relays its commands (add, edit, run or delete cells, read outputs, save) to the tab, and keeps no notebook state. Its edits are unsaved until you save, or ask it to save, which does what the tab's Save does. Assistants can address cells by the name they define, patch long cells with edit_cell replace: [{old, new}], and list cells compactly with read_notebook brief: true.
  • skill/SKILL.md teaches the assistant the workflow and how to write good cells; the MCP server also sends short instructions of its own.
  • Cells run in your browser, so live outputs need a tab showing the notebook.

Static build

-build (or --build) compiles every notebook to an ES module without starting the server:

npx @a10k/iridium-dev-server -build

Notebook files

Notebooks are saved in Notebook Kit's HTML format (<name>.html), the open format Observable Desktop edits:

<!doctype html>
<notebook theme="air">
  <title>my-notebook</title>
  <script id="1" type="application/vnd.observable.javascript" pinned="">
    a = 21
  </script>
  <script id="2" type="module">
    const doubled = a * 2;
    display(doubled);
  </script>
</notebook>
  • Classic Observable JavaScript cells are stored as application/vnd.observable.javascript, plain JavaScript cells as module, TypeScript cells as text/x-typescript (Observable Desktop's ts mode). Pinned cells (editor visible) have pinned.
  • Markdown, HTML, TeX and Graphviz cells from Observable Desktop open as the equivalent md/html/tex/dot template and are saved back in their own mode. Other modes (SQL, Python, …) can't run in Iridium but are kept unchanged.
  • Legacy .ojs notebooks are still read. The first save writes <name>.html next to it; from then on the .html file is used. The .ojs file is left untouched, so delete it once you're happy with the conversion.

Embedding compiled notebooks

Each notebook compiles to <name>.js exporting the classic define(runtime, observer), with the usual variable names (viewof x, mutable x), so existing embeds keep working:

import { Runtime } from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@6/+esm";
import { Library, FileAttachments } from "https://cdn.jsdelivr.net/npm/@observablehq/stdlib@5/+esm";
import { Inspector } from "https://cdn.jsdelivr.net/npm/@observablehq/inspector@5/+esm";
import define from "./my-notebook.js";

const runtime = new Runtime(new Library());
runtime.fileAttachments = FileAttachments; // runtime 6 no longer includes it; imported notebooks may need it
runtime.module(define, Inspector.into(document.body));
  • Works with @observablehq/runtime 5.9+ (runtime 5 includes the standard library and fileAttachments, so new Runtime() is enough) and 6 as above.
  • Every named cell is passed to observer(name), so you can pick cells to render by name.
  • Plain JavaScript and TypeScript cells: each display(…) call in a run goes to its own observer; top-level declarations are named variables.
  • Built-ins specific to Notebook Kit (such as the sample datasets like penguins) aren't in @observablehq/stdlib; provide them yourself if an embedded notebook uses them.

Configuration

Save an .iridiumrc file (JSON) in the project root, or an "iridiumrc" field in package.json:

{
  "notebooks": "./src",
  "compiled": "./dist",
  "static": "./public",
  "port": 8080,
  "host": "localhost",
  "local_editor": true,
  "head": "<style>body{font-family:'Trebuchet MS';}</style>"
}
Option Default
notebooks . Folder for notebook files (.html, legacy .ojs).
compiled . Folder for compiled modules (.js), served for embedding.
static — Extra folder of static assets to serve.
port 8080
host localhost The server writes files, so it only listens locally. Use 0.0.0.0 to expose it on your network.
local_editor true Serve Iridium from the installed package (works offline). false loads it from jsDelivr at the same version.
head "" Extra markup for the page <head> (fonts, scripts, styles).

Security

/read, /save, /list, /api/notebooks, /mcp and the live WebSocket (/__live__/<name>) only accept requests addressed to this machine (localhost) and, from a browser, from the server's own pages, so other websites can't read or change notebooks (CSRF, DNS rebinding). Notebook names are reduced to letters, digits and -, so files are only ever read or written inside the notebooks and compiled folders. Compiled modules and static files allow cross-origin GET for embedding.

Scripts

Add to your project's package.json for convenience:

"scripts": {
  "start": "iridium-dev-server",
  "build": "iridium-dev-server -build"
}

About

A simple web development server using iridium notebooks

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages