Badulaque
Two MCP tools, one of them read-only: a sandboxed terminal with CLIs built for agents. Any AI client reaches all my services and spends 66% less.
- Role
- Solo project
- When
- Oct 2026 – present
- Stack
- NixOS · Node.js · TypeScript · React · MCP · sandbox-runtime · bubblewrap · agent-browser · CalDAV · CardDAV
I switch AI clients constantly (Claude Code, claude.ai, Codex, opencode…) and want all of them to reach my services through one URL and key. Badulaque — named after the 24-hour shop in The Simpsons — is that single door, on my own server.
Premise: 594 tools do not fit in context
Tool definitions and instructions, in tokens, before doing anything.
Plain MCP alone almost fills a 200,000-token window. Tool search lowered that floor, yet every intermediate result still bounced through the model.
Architecture shift: one sandboxed terminal with CLIs
Instead of back-and-forth tool calls, one command chains the work inside a sandbox and returns only what matters. Across 7 real read-only tasks (×2, Claude Sonnet):
Terminal vs. previous tool search, summed across the 7 tasks.
Previous tool searchTerminal
Six of the seven tasks finish in a single call. Switching to the terminal drove the cost drop; later work on guides, aliases and navigation improved reliability, not the bill.
Second pass: compact signatures, parallel execution and lower footprint
After a follow-up audit inspired by Code Mode and Anthropic’s code-execution patterns, I tightened the rest of the pipeline (measured live on the server before and after the change):
Apples-to-apples measurements on the same server before and after retiring 6 redundant MCPs, adding TypeScript signatures, a local Unix bridge and parallel execution.
Full JSON Schema (before)TypeScript signatures (after)
When exploring generic connectors with detalle: "firma", the search proxy returns one-line TypeScript-style signatures instead of full JSON Schemas (−51% to −87% per query). Across all 6 real queries combined: ~23,100 → ~6,300 tokens.
- No internet hairpinning: a local HMAC-authenticated Unix socket bridge connects the
badulaqueCLI straight to the local search proxy.badulaque serviciosinside the sandbox dropped from 780 to 470 ms (−40%; subtracting ~423 ms ofsrtstartup, the call itself went from ~350 to ~47 ms). - Concurrency in JavaScript and on-demand credentials: querying calendar, reminders and unread mail in one call dropped from 6.70 s sequentially to 5.43 s with OAuth caching (−19%) and 3.45 s in parallel through a JavaScript code mode (−48%), returning only the filtered summary. Dynamic credentials (such as the Legálitas session) are fetched only when a command actually touches that service (0 calls otherwise).
- Smaller server footprint: retiring 6 MCP servers already covered by native CLIs (GitHub, Hevy, calendar and contacts, DNS, USC Moodle and browser) and turning off the browser by default cut the internal catalogue from 595 to 250 tools (346 → 121 for
claude-ai, −65%) and freed ~1.5 GB of RAM (the gateway alone dropped from 420 to 104 MB).
Sandboxing and credentials the agent never sees
- only its CLIs and domains
- only its folders
- time and output caps
Each command runs inside sandbox-runtime (bubblewrap on Linux) and is destroyed on exit. The agent never sees real secrets:
placeholder token→✓ authorized service→server swaps in real secret on exitplaceholder sent elsewhere→✕ rejected (403)A pre-swap filter enforces where each secret may travel, allowed HTTP methods (read-only for Hevy and Fitbit) and blocked routes (certificates and purchases at the domain registrar).Each MCP service also runs under its own Unix user, and internal ports are firewalled off from other processes. The server’s browser — disabled by default — follows the same rule: an out-of-sandbox bridge drives tabs, uploads and downloads without exposing cookies or eval.
Reading without asking for permission
The terminal now offers two tools instead of one: consultar (look up) and ejecutar (run). An AI client decides whether to ask for confirmation based on how each tool is announced, and a single tool that can also delete and send was, rightly, announced as destructive: Gemini asked for permission even to glance at the calendar. Now consultar is announced as read-only and is the default, and the server enforces it: it parses every command the way bash would and only runs it if each step is a lookup from its allowlist (memoria buscar, correo leer, calendario eventos, grep, jq…), with no $(…) and no writes to files, and it also runs it with the files mounted read-only. Anything else is rejected with the reason and pointed to ejecutar, which still asks for confirmation.
Three CLI design principles
Built from whatever connections are enabled in the dashboard — defaults, not locks. Carries a brief reference inside the tool description for web clients that ignore MCP instructions, plus English aliases and typo hints.
Short summaries and section outlines instead of dumping whole files or truncating blindly.
Packaged declaratively with Nix on the server; each custom CLI is moving to its own repo (cli-memoria was first).
What it connects
- memory
- files
- calendar
- contacts
- reminders
- GitHub
- Legálitas
- Hevy
- Fitbit
- DNS
- USC Moodle
- browser (off by default)
- deployments (not configured)
- web analytics
- Overleaf
- Zenodo
- the TV
Native CLI (14)Generic connector (5)
Calendar, reminders and contacts run over CalDAV and CardDAV without needing my devices awake. Custom connectors also include campus-usc and open-grocery-mcp (supermarket basket comparison with a public read-only instance at open-grocery-mcp.vercel.app/mcp).
All benchmarks, discarded ideas and bibliography are in this blog post. The dashboard and shared memory have their own pages: Self-hosted AI assistant and cli-memoria.