
Babashka
STDIOModel Context Protocol server for interacting with Babashka Clojure interpreter
Model Context Protocol server for interacting with Babashka Clojure interpreter
A Model Context Protocol server for interacting with Babashka, a native Clojure interpreter for scripting.
Babashka can be installed in several ways:
brew install borkdude/brew/babashka
bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)
# Using scoop scoop install babashka
For other installation methods, see the official Babashka installation guide.
After installation, verify Babashka works:
# Check version bb --version # Try a simple expression bb -e '(+ 1 2 3)' # Run a script from string bb -e '(defn hello [x] (str "Hello, " x "!")) (hello "World")' # Use -i flag to process lines of input ls | bb -i '(take 2 *input*)'
# Install dependencies npm install # Build the MCP server npm run build
The server can be configured through environment variables:
BABASHKA_PATH
: Path to the Babashka executable (default: "bb")Execute Babashka code with optional timeout:
{ name: "execute", arguments: { code: string; // Babashka code to execute timeout?: number; // Timeout in milliseconds (default: 30000) } }
Example:
{ name: "execute", arguments: { code: "(+ 1 2 3)", timeout: 5000 } }
The server maintains a cache of recent command executions accessible through:
babashka://commands/{index}
- Access specific command results by indexBabashka supports explicit tail call optimization through the recur
special form, but does not implement automatic TCO. For example:
;; This will cause stack overflow (defn countdown [n] (if (zero? n) :done (countdown (dec n)))) ;; This works with TCO using recur (defn countdown [n] (if (zero? n) :done (recur (dec n))))
This server is designed to eventually become self-hosting, meaning it will be rewritten in Babashka itself. The current TypeScript implementation serves as a reference and starting point.
Self-Hosted Implementation
Enhanced Features
Performance Optimizations
Testing & Documentation