Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

babashka-mcp-server

MCP.Pizza Chef: bmorphism

The babashka-mcp-server is a Model Context Protocol server designed to integrate with Babashka, a native Clojure interpreter optimized for scripting. It allows users to execute Babashka code through MCP tools, providing a seamless interface for running Clojure scripts in real-time. The server supports caching of recent command results to improve efficiency and offers access to command history through MCP resources. Additionally, it features configurable command timeouts to manage execution duration. This server is ideal for developers looking to embed Clojure scripting capabilities into AI workflows or automation pipelines, leveraging Babashka's fast startup and scripting power within the MCP ecosystem.

Use This MCP server To

Execute Clojure scripts via MCP tools Cache recent Babashka command results Access Babashka command history Configure command execution timeouts Integrate Babashka scripting in AI workflows Automate Clojure script execution in pipelines

README

Babashka MCP Server

A Model Context Protocol server for interacting with Babashka, a native Clojure interpreter for scripting.

Features

  • Execute Babashka code through MCP tools
  • Cache recent command results
  • Access command history through MCP resources
  • Configurable command timeouts

Prerequisites

Install Babashka

Babashka can be installed in several ways:

macOS
brew install borkdude/brew/babashka
Linux
bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)
Windows
# Using scoop
scoop install babashka

For other installation methods, see the official Babashka installation guide.

Verify Installation

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*)'

Installation

# Install dependencies
npm install

# Build the MCP server
npm run build

Configuration

The server can be configured through environment variables:

  • BABASHKA_PATH: Path to the Babashka executable (default: "bb")

Tools

execute

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
  }
}

Resources

The server maintains a cache of recent command executions accessible through:

  • babashka://commands/{index} - Access specific command results by index

Babashka Language Features

Tail Call Optimization (TCO)

Babashka 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))))

Useful Resources

Official Resources

Community Tools & Libraries

Development Tools

Development

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.

Roadmap

  1. Self-Hosted Implementation

    • Rewrite the MCP server in Babashka
    • Leverage Babashka's native capabilities for better performance
    • Remove Node.js dependency
    • Maintain full compatibility with MCP protocol
    • Support all current features:
      • Command execution
      • Resource management
      • Command history
      • Timeout handling
  2. Enhanced Features

    • Add support for Babashka pods
    • Implement file watching capabilities
    • Add REPL integration
    • Support for multiple Babashka instances
  3. Performance Optimizations

    • Implement caching strategies
    • Optimize resource usage
    • Reduce startup time
  4. Testing & Documentation

    • Comprehensive test suite
    • API documentation
    • Usage examples
    • Performance benchmarks

babashka-mcp-server FAQ

How do I install Babashka to use with babashka-mcp-server?
Babashka can be installed via Homebrew on macOS, a shell script on Linux, or Scoop on Windows. Refer to the official Babashka installation guide for detailed instructions.
How can I verify that Babashka is correctly installed?
Run 'bb --version' to check the version and 'bb -e "(+ 1 2 3)"' to execute a simple expression, ensuring Babashka works before using the MCP server.
What features does babashka-mcp-server provide for command management?
It supports caching recent command results, accessing command history, and configurable timeouts for command execution.
Can I customize the timeout for Babashka command execution?
Yes, babashka-mcp-server allows configuring command timeouts to control how long scripts are allowed to run.
Is babashka-mcp-server compatible with multiple LLM providers?
Yes, it works within the MCP ecosystem, enabling integration with models from OpenAI, Anthropic Claude, and Google Gemini.
Does babashka-mcp-server support running scripts from strings or files?
Yes, you can execute Babashka code snippets or scripts passed as strings through the MCP interface.
How does babashka-mcp-server improve efficiency when running repeated commands?
It caches recent command results to avoid redundant executions and speed up response times.
What operating systems are supported for babashka-mcp-server?
It supports macOS, Linux, and Windows, matching Babashka's cross-platform compatibility.