Skip to content
Michael Whitford edited this page Jun 2, 2025 · 10 revisions

Cherry Studio

Cherry Studio setup using clojure-mcp-sse and nrepl running from a container.

I use podman, all of this should work with docker as well. I use a container to sandbox the nrepl and SSE server together, and mount my project into the container at /app/project.

Create a directory:

mkdir clojure-mcp-server && cd clojure-mcp-server

Create a file: Containerfile:

FROM docker.io/library/eclipse-temurin:21 as JAVA

FROM docker.io/library/python:3.12-bookworm

RUN mkdir /app

WORKDIR /app

COPY clojure-mcp-server.sh .

RUN chmod 0750 clojure-mcp-server.sh

RUN apt-get update
RUN apt-get upgrade -y

# last line here can be omitted for a smaller container
# these tools make troubleshooting in the container easier
RUN apt-get install -y --no-install-recommends \
    ca-certificates curl git gnupg gzip jq \
    ssh rlwrap tar zip \
    iproute2 vim-tiny strace ncat nmap less

# install uv
RUN pip install uv

# install node.js and npm via nodesource
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get update && apt-get install -y nodejs

# confirm npm and node versions
RUN node -v && npm -v

# setup yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn

# install JAVA 21 from eclipse-temurin:21
# see https://hub.docker.com/_/eclipse-temurin
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=JAVA $JAVA_HOME $JAVA_HOME

# install clojure
ENV CLOJURE_HOME=/opt/clojure
RUN curl -L -O https://github.com/clojure/brew-install/releases/latest/download/posix-install.sh
RUN chmod +x posix-install.sh
RUN ./posix-install.sh --prefix $CLOJURE_HOME
RUN rm ./posix-install.sh

# add java and clojure to the path
ENV PATH="${JAVA_HOME}/bin:${CLOJURE_HOME}/bin:${PATH}"

RUN mkdir -p /app/project

# mount your local project here
WORKDIR /app/project

# expose https sse port
EXPOSE 8078

# expose nrepl port
EXPOSE 7888

# clear package cache
RUN apt-get autoremove -y
RUN apt-get autoclean -y
RUN apt clean -y
RUN rm -rf /var/lib/apt/lists/*

CMD ["/app/clojure-mcp-server.sh"]

create a file: clojure-mcp-server.sh

#!/usr/bin/env bash

cd /app/project

clojure -M:nrepl >> /app/nrepl.out 2>&1 &

sleep 10

clojure -X:mcp-sse >> /app/mcp-sse.out 2>&1

In your clojure project, make sure you have the :nrepl and :mcp-sse aliases (BEFORE YOU RUN THE CONTAINER):

deps.edn

{:paths   ["src" "resources"]
 :deps    {}
 :aliases {:mcp-sse {:extra-deps {;; optional
                                  ;; org.slf4j/slf4j-nop {:mvn/version "2.0.16"}
                                  jakarta.servlet/jakarta.servlet-api {:mvn/version "6.1.0"}
                                  org.eclipse.jetty/jetty-server {:mvn/version "11.0.20"}
                                  org.eclipse.jetty/jetty-servlet {:mvn/version "11.0.20"}}
                      :exec-fn clojure-mcp.sse-main/start-sse-mcp-server
                      :exec-args {:port 7888 ;; the nrepl port to connect to
                                  ;; specify the :mcp-sse-port to listen on
                                  :mcp-sse-port 8078}

           :nrepl     {:extra-paths ["test"]
                       :extra-deps  {nrepl/nrepl       {:mvn/version "1.3.1"}
                                     cider/cider-nrepl {:mvn/version "0.56.0"}}
                       :jvm-opts    ["-Djdk.attach.allowAttachSelf"]
                       :main-opts   ["-m" "nrepl.cmdline" "--port" "7888" "--bind" "0.0.0.0"
                                     "--middleware" "[cider.nrepl/cider-middleware]"]}}}

Build the container:

podman build -t clojure-mcp-server .

Run the container:

Replace /path/to/project with the path to your clojure project that you added the above dependencies to deps.edn.

If you want to use the agent tools (architect, dispatch_agent, code_critique) then specify an API key for one of the major 3 providers with the -e option.

You should probably use a git repo as the base of your project, clojure-mcp can and will edit files in this project at any time.

podman run -d --replace --name clojure-mcp \
    -p 7888:7888 -p 8078:8078 \
    -e OPENAI_API_KEY=sk-..... \
    -v /path/to/project:/app/project:rw,Z \
    localhost/clojure-mcp-server:latest

In Cherry Studio add a new MCP server with the following settings:

Clone this wiki locally