From a Headless Linux Server to a Browser Room: A Terminal CLI and MCP Server Bundled from My Web App's Code A developer built clipshare, a terminal CLI and MCP server that lets a headless Linux server join the same browser-based Clipboard Share rooms used for file transfer. The CLI imports crypto and folder-diff modules directly from the web app's frontend/src to prevent protocol drift, with esbuild bundling the entry point into a single clipshare.mjs and a two-line vue-shim re-exporting ref from @vue/reactivity to avoid bundling all of Vue. Room keys travel only through SPAKE2, and a systemd user unit keeps folder sync running after the terminal closes. The goal was narrow: send and receive files from a headless Linux server, the kind you only reach over SSH. Clipboard Share already has rooms on the web. A phone and a PC join the same room and swap files. So the question was simple: can a terminal join that same room? That became clipshare . A file uploaded from the server shows up in the browser room right away. I built it with Claude Code. I made the design calls and checked the results. The work started with PR 164 feat/cli , with stages 1 to 3 landing on 2026-11-30 and npm plus MCP on 2026-12-01. This was the part I cared about most. If I write separate crypto for the CLI, it will drift from the web version, and then the two sides can't open each other's files. So the CLI imports modules straight from frontend/src . This is the top of share.js : js import { diffFolder } from '../../frontend/src/utils/folderDiff.js' import { isCopyOfOther } from '../../frontend/src/utils/folderDedupe.js' import { makeFolderEp, makeFolderEr } from '../../frontend/src/utils/privateFolder.js' import { ctPartCount } from '../../frontend/src/utils/lockCrypto.js' import { scanDir, FOLDER MAX FILES } from './files.js' import { uploadLockedFile, contentHash } from './transfer.js' The catch is browser globals. Anything touching document or window won't run in Node. So I split out the parts that don't need a browser: lockedUploadCore.js , lockedStream.js , identityName.js , receivePath.js and folderDedupe.js . The web app and the CLI use the same files. esbuild turns the entry point into one file, clipshare.mjs : await build { entryPoints: path.join cli, 'src', 'cli.js' , outfile: path.join outDir, 'clipshare.mjs' , bundle: true, platform: 'node', target: 'node18', format: 'esm', // codeJoin.js only uses vue's ref: alias vue to the reactivity module alias: { vue: path.join cli, 'src', 'vue-shim.js' }, nodePaths: path.join frontend, 'node modules' , } The web codeJoin.js uses ref from Vue. I didn't want all of Vue in a CLI bundle, so vue-shim.js re-exports ref from @vue/reactivity . The file is two lines. Node 18 has no globalThis.crypto , so the entry file fills it from node:crypto 's webcrypto before anything else loads. The web code calls Web Crypto directly, so this keeps it unchanged. On the web, you join a room by entering four pictures. A terminal has no pictures, so the same code is written as numbers, 00 to 23 per picture: curl -fsSL clipboardapp.org/c | sh -s 1704-2311 One line installs the CLI and joins. You still have to press "admit" on the web side. The code is single-use and lasts 5 minutes. codejoin.js is thin. It reuses the web state machine through a small adapter: js import { createCodeJoiner } from '../../frontend/src/services/codeJoin.js' export function codeAdapter session { return { emit: event, payload = session.emitAck event, payload , on: event, fn = session.socket.on event, fn , off: event, fn = session.socket.off event, fn } } The room key travels only through SPAKE2, so the server never sees it. I kept the folder rules the same as the web: share ~/docs uploads a folder and checks for changes every 2 seconds. Dotfiles are skipped, with a cap of 1000 files and depth 8. receive ~/inbox saves room files into the same folder structure. Name collisions become name 1 .ext . Downloads go to a .xxxx.clipshare.part temp file and get renamed when done. sync ~/docs runs both in one process. Closing the terminal kills a folder share, so clipshare service install writes a user unit: clipshare service install --room myroom --sync ~/docs clipshare service list | status | logs | uninstall The unit goes to ~/.config/systemd/user/clipshare-