Babashka MCP Server

by bmorphism
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • The MCP server provides integration with Babashka, which is a native Clojure interpreter for scripting. It allows execution of Clojure code through the MCP protocol.

  • The README mentions GitHub Actions tools for Babashka, including setup-babashka and babashka-docker-action, which are recommended for using Babashka in GitHub Actions workflows.

Babashka MCP 服务器

用于与Babashka (用于脚本的本机 Clojure 解释器)交互的模型上下文协议服务器。

特征

  • 通过 MCP 工具执行 Babashka 代码
  • 缓存最近的命令结果
  • 通过 MCP 资源访问命令历史记录
  • 可配置命令超时

先决条件

安装 Babashka

Babashka 可以通过多种方式安装:

macOS

brew install borkdude/brew/babashka

Linux

bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)

视窗

# Using scoop scoop install babashka

其他安装方法请参见Babashka官方安装指南

验证安装

安装后,验证 Babashka 是否正常工作:

# 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

配置

可以通过环境变量配置服务器:

  • BABASHKA_PATH :Babashka 可执行文件的路径(默认值:“bb”)

工具

执行

使用可选超时执行 Babashka 代码:

{ name: "execute", arguments: { code: string; // Babashka code to execute timeout?: number; // Timeout in milliseconds (default: 30000) } }

例子:

{ name: "execute", arguments: { code: "(+ 1 2 3)", timeout: 5000 } }

资源

服务器维护最近执行的命令的缓存,可通过以下方式访问:

  • babashka://commands/{index} - 通过索引访问特定的命令结果

Babashka 语言功能

尾部调用优化(TCO)

Babashka 通过recur特殊形式支持显式尾调用优化,但不实现自动 TCO。例如:

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

有用的资源

官方资源

社区工具和图书馆

开发工具

发展

该服务器最终设计为自托管,这意味着它将用 Babashka 本身重写。当前的 TypeScript 实现可作为参考和起点。

路线图

  1. 自托管实施
    • 使用 Babashka 重写 MCP 服务器
    • 利用 Babashka 的原生功能获得更好的性能
    • 删除 Node.js 依赖项
    • 保持与 MCP 协议的完全兼容
    • 支持所有当前功能:
      • 命令执行
      • 资源管理
      • 命令历史记录
      • 超时处理
  2. 增强功能
    • 添加对 Babashka pods 的支持
    • 实现文件监视功能
    • 添加 REPL 集成
    • 支持多个 Babashka 实例
  3. 性能优化
    • 实施缓存策略
    • 优化资源使用
    • 减少启动时间
  4. 测试与文档
    • 综合测试套件
    • API 文档
    • 使用示例
    • 性能基准

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

Tools

使用模型上下文协议实现 Babashka 脚本的执行和管理,提供缓存、命令历史记录访问和可配置超时等功能,以增强脚本工作流程。

  1. Features
    1. Prerequisites
      1. Install Babashka
      2. Verify Installation
    2. Installation
      1. Configuration
        1. Tools
          1. execute
        2. Resources
          1. Babashka Language Features
            1. Tail Call Optimization (TCO)
          2. Useful Resources
            1. Official Resources
            2. Community Tools & Libraries
            3. Development Tools
          3. Development
            1. Roadmap
              ID: 5x0u155x1h