From 2054bfdfd07fd09192648d8bb685487c097ac4ed Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 14:53:41 +0000 Subject: [PATCH 1/2] Add the Toolbox command line and MCP page /toolbox/cli/ documents the `bitanon` command and `bitanon mcp`: install, usage, MCP client setup and a reference of every tool. The reference is read from the command's own MCP tool list during the Toolbox build, so it follows the engine repo. The Toolbox index links to it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KmuCbtjZ699DghxV5a1A9S --- scripts/toolbox.mjs | 29 +++++- src/lib/toolbox.ts | 19 +++- src/pages/toolbox/cli.astro | 188 ++++++++++++++++++++++++++++++++++ src/pages/toolbox/index.astro | 8 ++ 4 files changed, 241 insertions(+), 3 deletions(-) create mode 100644 src/pages/toolbox/cli.astro diff --git a/scripts/toolbox.mjs b/scripts/toolbox.mjs index 24eff23..3dfe8d3 100644 --- a/scripts/toolbox.mjs +++ b/scripts/toolbox.mjs @@ -11,6 +11,10 @@ // public/toolbox/engine..js, and src/data/generated/toolbox.json tells // the pages its file name and the library versions inside it. // +// When the engine repo has the `bitanon` command (bin/bitanon.dart), its tool +// list is read from `bitanon mcp` (the MCP tools/list answer) into +// toolbox.json too, for the reference on /toolbox/cli/. +// // The output is cached in .cache/toolbox/ by source, versions and SDK, so a // rebuild without changes skips the work. Without a Dart SDK this is a // warning locally (the Toolbox pages say the engine is missing) but a hard @@ -90,7 +94,7 @@ const versions = Object.fromEntries( // Cache key: engine sources + resolved versions + SDK. const hash = createHash('sha256'); -for (const dir of ['lib', 'web', 'test']) { +for (const dir of ['lib', 'web', 'test', 'bin'].filter((d) => fs.existsSync(path.join(pkg, d)))) { for (const f of fs.readdirSync(path.join(pkg, dir), { recursive: true }).sort()) { const p = path.join(pkg, dir, String(f)); if (fs.statSync(p).isFile()) hash.update(`${dir}/${f}\n`).update(fs.readFileSync(p)); @@ -99,6 +103,7 @@ for (const dir of ['lib', 'web', 'test']) { hash.update(fs.readFileSync(path.join(pkg, 'pubspec.yaml'))).update(JSON.stringify(versions)).update(sdk); const key = hash.digest('hex').slice(0, 12); const cached = path.join(cacheDir, `engine.${key}.js`); +const cachedCli = path.join(cacheDir, `cli.${key}.json`); if (fs.existsSync(cached)) { log(`engine up to date (${key})`); @@ -127,6 +132,26 @@ if (fs.existsSync(cached)) { } } +// The `bitanon` command's tools, as its MCP server lists them. +let cli = null; +if (fs.existsSync(path.join(pkg, 'bin', 'bitanon.dart'))) { + if (!fs.existsSync(cachedCli)) { + log('reading the bitanon command\'s tool list'); + const input = [ + { jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'bitanon.dev', version: '1' } } }, + { jsonrpc: '2.0', id: 2, method: 'tools/list' }, + ].map((m) => JSON.stringify(m)).join('\n') + '\n'; + try { + const out = dart(['run', 'bin/bitanon.dart', 'mcp'], { input, stdio: ['pipe', 'pipe', 'pipe'] }); + const [init, list] = out.trim().split('\n').map((l) => JSON.parse(l)); + fs.writeFileSync(cachedCli, JSON.stringify({ version: init.result.serverInfo.version, tools: list.result.tools })); + } catch (e) { + fail(`bitanon mcp failed:\n${e.stdout || ''}${e.stderr || e.message}`); + } + } + cli = JSON.parse(fs.readFileSync(cachedCli, 'utf8')); +} + // Publish under a content-addressed name, so browsers never mix an old engine // with new pages. fs.mkdirSync(publicDir, { recursive: true }); @@ -135,5 +160,5 @@ for (const f of fs.readdirSync(publicDir)) { } const engine = `engine.${key}.js`; fs.copyFileSync(cached, path.join(publicDir, engine)); -writeData({ engine, versions, sdk: sdk.replace(/^Dart SDK version: /, '').split(' ')[0] }); +writeData({ engine, versions, sdk: sdk.replace(/^Dart SDK version: /, '').split(' ')[0], cli }); log(`wrote public/toolbox/${engine} (${Math.round(fs.statSync(cached).size / 1024)} KB)`); diff --git a/src/lib/toolbox.ts b/src/lib/toolbox.ts index 14c2fa8..83ff67a 100644 --- a/src/lib/toolbox.ts +++ b/src/lib/toolbox.ts @@ -351,5 +351,22 @@ export const toolUrl = (t: Tool) => url(`toolbox/${t.id}/`); /** The library's project entry (for its accent colour and page link). */ export const libraryProject = (l: Library) => projects.find((p) => p.slug === l); -export const engine = generated as { engine: string | null; versions: Partial>; sdk?: string; error?: string }; +/** A tool of the `bitanon` command, as its MCP server lists it. */ +export interface CliTool { + name: string; + title?: string; + description: string; + inputSchema: { + properties: Record; + required?: string[]; + }; +} + +export const engine = generated as { + engine: string | null; + versions: Partial>; + sdk?: string; + error?: string; + cli?: { version: string; tools: CliTool[] } | null; +}; export const workerUrl = engine.engine ? url(`toolbox/worker.js?engine=${engine.engine}`) : null; diff --git a/src/pages/toolbox/cli.astro b/src/pages/toolbox/cli.astro new file mode 100644 index 0000000..a4ab6f9 --- /dev/null +++ b/src/pages/toolbox/cli.astro @@ -0,0 +1,188 @@ +--- +// /toolbox/cli/: the `bitanon` command and its MCP server. The tool reference +// comes from the command itself (scripts/toolbox.mjs reads its MCP tool list +// into toolbox.json), so it follows the engine repo without edits here. +import { Code } from 'astro:components'; +import Site from '../../layouts/Site.astro'; +import '../../styles/toolbox.css'; +import { engine, type CliTool } from '../../lib/toolbox'; +import { url } from '../../lib/data'; +import RfcText from '../../components/RfcText.astro'; + +const cli = engine.cli ?? null; +const repo = 'https://github.com/bitanon/toolbox'; +const releases = `${repo}/releases/latest`; +const description = + 'The Bitanon Toolbox on your machine: the bitanon command hashes, encodes, encrypts and generates from a terminal, and bitanon mcp offers the same tools to AI agents over MCP. Free, open source, and offline.'; +const themes = { light: 'github-light-default', dark: 'github-dark-default' } as const; + +const usage = `bitanon hash abc +# ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad + +bitanon hash --file archive.zip --algorithm sha256,blake2b256 +echo -n "hello" | bitanon convert --to base64 +bitanon argon2-hash "correct horse battery staple" +bitanon aead-encrypt "secret" --key $(bitanon random --length 32) +bitanon uuid --version 7 --count 3 +bitanon totp --secret JBSWY3DPEHPK3PXP + +bitanon help # every tool +bitanon help aes # one tool's options`; + +const install = `# Linux and macOS: unpack, then put it on your PATH +tar -xzf bitanon-*-linux-x64.tar.gz +sudo mv bitanon-*/bitanon /usr/local/bin/ + +# Or, with the Dart SDK installed +dart pub global activate --source git ${repo}`; + +const desktop = `{ + "mcpServers": { + "bitanon": { "command": "/usr/local/bin/bitanon", "args": ["mcp"] } + } +}`; +const claudeCode = `claude mcp add bitanon -- /usr/local/bin/bitanon mcp`; + +const platforms = [ + ['Linux', 'x64 and arm64'], + ['macOS', 'Apple silicon and Intel'], + ['Windows', 'x64'], +]; + +/** `inputFormat` -> `--input-format`. */ +const flag = (name: string) => `--${name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`; +// The byte formats: the choice list of every *Format parameter. +const formats = cli?.tools.flatMap((t) => Object.entries(t.inputSchema.properties)).find(([n]) => n.endsWith('Format'))?.[1].enum; +const isFormats = (c: string[]) => !!formats && c.length === formats.length && c.every((x, i) => x === formats[i]); +const options = (t: CliTool) => + Object.entries(t.inputSchema.properties).map(([name, p]) => { + const choices = p.enum ?? p.items?.enum; + const def = p.default === undefined ? null : Array.isArray(p.default) ? p.default.join(',') : String(p.default); + return { + flag: p.type === 'boolean' ? `${flag(name)}, --no-${flag(name).slice(2)}` : flag(name), + required: t.inputSchema.required?.includes(name) ?? false, + description: p.description, + def, + choices: choices && !isFormats(choices) ? choices : null, + anyFormat: !!choices && isFormats(choices), + }; + }); +--- + + +
+ +

The Toolbox in your terminal and your AI agent

+

+ bitanon runs every Toolbox tool from the command line, and{' '} + bitanon mcp offers them to AI agents as an MCP server. It is the same engine as the web pages, on the same{' '} + convertlib,{' '} + hashlib and{' '} + cipherlib libraries, compiled to a single native binary. It works offline and makes no network requests. +

+ +
+

Install

+

+ Download the binary for your system from the latest release. Each release lists SHA-256 checksums in SHA256SUMS. +

+ +
+ +
+
+ +
+

Use it

+
+ +
+
    +
  • Data comes from the argument, --file <path> or standard input. Files and standard input are read byte for byte, so bitanon hash < file gives the same answer as sha256sum. Set the format flag (for example --from base64) to read them as text instead.
  • +
  • --json prints the full result as JSON, for scripts.
  • +
  • Exit codes: 0 on success, 1 when a tool fails or a password does not match, 2 for a usage mistake.
  • +
+
+ +
+

MCP server for AI agents

+

+ Language models are bad at computing hashes, encodings and keys in their heads. bitanon mcp speaks the{' '} + Model Context Protocol over standard input and output, so an agent can call the same tested code instead. Every tool is read-only: the server reads no files and makes no network requests. +

+

Claude Desktop, Cursor and other clients

+

Add it to the client's MCP configuration (claude_desktop_config.json for Claude Desktop), with the path where you put the binary:

+
+ +
+

Claude Code

+
+ +
+
+ +
+

Tools{cli && bitanon {cli.version}}

+ { + cli ? ( + <> +

The same names work as commands and as MCP tools. Options are flags on the command line and arguments over MCP.

+
+ {cli.tools.map((t) => ( +
+ + {t.name} + + + +
+ {options(t).map((o) => ( +
+
{o.flag}
+
+ + {o.required && Required.} + {o.def !== null && Default: {o.def}.} + {o.choices && {o.choices.join(' · ')}} + {o.anyFormat && Any of the formats below.} +
+
+ ))} +
+
+ ))} +
+ {formats && ( +

+ Formats: {formats.join(' · ')} +

+ )} + + ) : ( +

+ Run bitanon help for the list of tools, or see the README. +

+ ) + } +
+ +

+ Source: github.com/bitanon/toolbox, BSD-3-Clause. +

+
+
diff --git a/src/pages/toolbox/index.astro b/src/pages/toolbox/index.astro index 96a9244..ca2888a 100644 --- a/src/pages/toolbox/index.astro +++ b/src/pages/toolbox/index.astro @@ -68,6 +68,14 @@ const versions = Object.entries(engine.versions).filter(([, v]) => v); + + + On the command line and for AI agents + The same tools as a native bitanon command, and as an MCP server with bitanon mcp. + + + +

Verified, not just tested

From 2ed13de9291f05fbde8546837e9525b68789561c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 14:55:56 +0000 Subject: [PATCH 2/2] Lead the Toolbox CLI page with the one-line installers Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KmuCbtjZ699DghxV5a1A9S --- src/pages/toolbox/cli.astro | 48 +++++++++++++++---------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/src/pages/toolbox/cli.astro b/src/pages/toolbox/cli.astro index a4ab6f9..77b0022 100644 --- a/src/pages/toolbox/cli.astro +++ b/src/pages/toolbox/cli.astro @@ -29,25 +29,18 @@ bitanon totp --secret JBSWY3DPEHPK3PXP bitanon help # every tool bitanon help aes # one tool's options`; -const install = `# Linux and macOS: unpack, then put it on your PATH -tar -xzf bitanon-*-linux-x64.tar.gz -sudo mv bitanon-*/bitanon /usr/local/bin/ - -# Or, with the Dart SDK installed -dart pub global activate --source git ${repo}`; +const raw = 'https://raw.githubusercontent.com/bitanon/toolbox/main'; +const installSh = `curl -fsSL ${raw}/install.sh | sh`; +const installPs = `irm ${raw}/install.ps1 | iex`; +const installDart = `dart pub global activate --source git ${repo}`; const desktop = `{ "mcpServers": { - "bitanon": { "command": "/usr/local/bin/bitanon", "args": ["mcp"] } + "bitanon": { "command": "/home/you/.local/bin/bitanon", "args": ["mcp"] } } }`; -const claudeCode = `claude mcp add bitanon -- /usr/local/bin/bitanon mcp`; +const claudeCode = `claude mcp add bitanon -- ~/.local/bin/bitanon mcp`; -const platforms = [ - ['Linux', 'x64 and arm64'], - ['macOS', 'Apple silicon and Intel'], - ['Windows', 'x64'], -]; /** `inputFormat` -> `--input-format`. */ const flag = (name: string) => `--${name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`; @@ -87,23 +80,20 @@ const options = (t: CliTool) =>

Install

-

- Download the binary for your system from the latest release. Each release lists SHA-256 checksums in SHA256SUMS. +

Linux and macOS

+
+ +
+

Windows (PowerShell)

+
+ +
+

+ The installer downloads the binary for your system (Linux x64 or arm64, macOS on Apple silicon or Intel, Windows x64) from the{' '} + latest release, checks it against the release's SHA-256 checksums, and puts it in ~/.local/bin (on Windows, %LOCALAPPDATA%\bitanon\bin, added to your PATH). You can also download a binary yourself, or install from source with the Dart SDK:

- -
- +
+