clojure-mcp

by bhauman

Not rated
GitHub

About

An MCP server providing a complete toolset for Clojure development, requiring a running nREPL server.

Details

Author
bhauman
Categories
Developer Tools, Other

Setup

Install clojure-mcp in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/bhauman/clojure-mcp

Follow the installation instructions in the repository README, then restart your MCP client.

Clojure MCP: REPL-Driven Development with AI Assistance

ClojureMCP is an MCP server for Clojure!

- What is ClojureMCP?
-
How do I use it?
-
Main Features
-
Help and Community Resources
-
📋 Installation
-
CLI Assistants
-
Claude Desktop

- Project Summary Management
-
Chat Session Summarize and Resume

ClojureMCP is an MCP server that connects an LLM client (like Claude Code or Claude Desktop) to your Clojure project. It provides REPL tools and Clojure-aware editing tools designed to handle Clojure's parentheses and formatting reliably.

Depending on your LLM client, ClojureMCP can either:

- Provide acomplete set of Clojure aware code assistance toolsfor desktop chat apps like Claude Desktop, or
- Fill in Clojure-specific gaps forCLI assistantsthat already have great file editing and shell tools (such as REPL integration + Clojure-aware edits).
- Install ClojureMCP (clojure -Ttools install-latest ...).
- Register it as an MCP server in your LLM client.

If you're using a CLI assistant, you'll usually prefer to keep the CLI's native file editing tools and use ClojureMCP mainly for REPL integration (and as an editing fallback).

If you're using a desktop chat app, you'll typically use the full ClojureMCP toolchain.

- Clojure REPL Connection- which repairs delimiters prior to evaluation
- Clojure Aware editing- Using parinfer, cljfmt, and clj-rewrite
- Optimized set of tools for Clojure Development

- The#ai-assisted-coding Channel on Clojurians Slackis very active and where I spend a lot of time.
- The
ClojureMCP Wikihas info on various integrations and sandboxing.

- Clojure
-
Java(JDK 17 or later)
- Optional but HIGHLY recommended:
ripgrepfor bettergrepandglob_filesperformance

Install ClojureMCP using the Clojure tools installer:

clojure -Ttools install-latest :lib io.github.bhauman/clojure-mcp :as mcp

This installs ClojureMCP globally, makingclojure -Tmcp startavailable from any directory.

CLI coding assistants (Claude Code, Codex, Gemini CLI) already have great inline-diff editing and shell tools.

Start withclojure-mcp-light- it provides REPL integration and delimiter repair while preserving your CLI's native inline-diff display. This works well for most Clojure development.

Consider adding ClojureMCPwith the:cli-assistprofile if you want:

- Structural editing fallback- clojure-mcp-light can repair parens after an edit succeeds, but can't help when the find/replace match string doesn't match the code (happens <5% of the time, but can throw off the LLM). Structural editing targets forms by type and name, avoiding this problem.
- First-class REPL tool- LLMs tend to use MCP tools more readily than CLI commands, which may lead to more frequent REPL usage.

Adding ClojureMCP to clojure-mcp-light can provide an enhanced Clojure development experience for CLI assistants.

# Claude Code claude mcp add clojure-mcp -- clojure -Tmcp start :config-profile :cli-assist # OpenAI Codex codex mcp add clojure-mcp -- clojure -Tmcp start :config-profile :cli-assist # Google Gemini CLI gemini mcp add clojure-mcp clojure -Tmcp start :config-profile :cli-assist

Prefer clojure-mcp's editing/reading tools?If you let the agent drive and care less about the native inline diff, swap:cli-assistfor:cli-assist-full. It makesread_file,clojure_edit,clojure_edit_replace_sexp, andparen_repairfirst-class (instead of fallbacks) and instructs the assistant to doallClojure-file edits through them — which sidesteps the host editor's "file modified since read" conflict without any permission configuration. (Power users who want a hard guarantee can additionally add Claude Codepermissions.denyrules like"Edit(//.clj)"so the native editor can't touch Clojure files at all.)

clojure -Tmcp start :config-profile :cli-assist

You should see JSON-RPC output like this:

{"jsonrpc":"2.0","method":"notifications/tools/list_changed"} {"jsonrpc":"2.0","method":"notifications/tools/list_changed"} {"jsonrpc":"2.0","method":"notifications/resources/list_changed"} {"jsonrpc":"2.0","method":"notifications/prompts/list_changed"}

Desktop chat apps (like Claude Desktop) start MCP servers outside your project directory and do not provide built-in coding tools. In this environment, you’ll typically use the full ClojureMCP toolchain and connect it to an nREPL running in your project.

ClojureMCP was initially developed to turn Claude Desktop into a coding assistant similar to Claude Code with tools designed to work effectively with the Clojure programming language.

Start an nREPL server from your project directory. If you don't already have an nREPL alias or configuration, seedoc/nrepl.md.

Pick the shell executable that will most likely pick up your environment config:

If you are usingBashfind the explicitbashexecutable path:

If you are usingZ Shellfind the explicitzshexecutable path:

Now we're going to use this explicit shell path in thecommandparameter in the Claude Desktop configuration as seen below.

Create or edit~/Library/Application\ Support/Claude/claude_desktop_config.json:

{ "mcpServers": { "clojure-mcp": { "command": "/opt/homebrew/bin/bash", "args": [ "-c", "clojure -Tmcp start :not-cwd true :port 7888" ] } } }

The:not-cwd trueflag tells ClojureMCP not to use the current working directory (which for Claude Desktop is not your project). Instead, it introspects the nREPL connection to discover the project's working directory.

This allows a simple working pattern of starting a REPL on 7888, then starting Claude Desktop and allowing it to detect where you are working.

When you want to switch to a different project you would stop the current REPL running on 7888 and start a nREPL server in the project you want to work in on port 7888.

cd /path/to/your/project clojure -M:nrepl

Look for:nREPL server started on port 7888...

Restart Claude Desktop(required after configuration changes)

Verify Connection: In Claude Desktop, click the+button in the chat area. You should see "Add from clojure-mcp" in the menu. It's important to note that it may take a few moments for this to show up.

If there was an error please see theTroubleshooting Guide. If it connected, go see theStarting a new conversation in Claude Desktopsection.

IMPORTANT: Turn Claude Desktop capabilities off

Code execution and file creation provides tools that compete with ClojureMCP; it's best to turn them off.

Go to settings > Capabilities > Code Execution and file creation and toggle it off.

You may also want to turnArtifactsoff as well.

See theWikifor information on setting up other MCP clients.

Starting a new conversation in Claude Desktop

Once everything is set up I'd suggest starting a new chat in Claude.

The first thing you are going to want to do is initialize context about the Clojure project in the conversation attached to the nREPL.

In Claude Desktop click the+tools and optionally add

- resourcePROJECT_SUMMARY.md- (have the LLM create this) see below
- resourceClojure Project Info- which introspects the nREPL connected project
- resourceLLM_CODE_STYLE.md- Which is your personal coding style instructions (copy the one in this repo to the root of your project)
- promptclojure_repl_system_prompt- instructions on how to code - cribbed a bunch from Claude Code

I would start by stating a problem and then chatting with the LLM to interactively design a solution. You can ask Claude to "present a solution for my review".

Iterate on that a bit then have it either:

A. code and validate the idea in the REPL.

Don't underestimate LLMs abilities to use the REPL! Current LLMs are absolutely fantastic at using the Clojure REPL.

B. ask the LLM to make the changes to the source code and then have it validate the code in the REPL after file editing.

C. ask to run the tests. D. ask to commit the changes.

Make a branch and have the LLM commit often so that it doesn't ruin good work by going in a bad direction.

This project includes a workflow for maintaining an LLM-friendlyPROJECT_SUMMARY.mdthat helps assistants quickly understand the codebase structure.
-

Creating the Summary: To generate or update the PROJECT_SUMMARY.md file, use the MCP prompt in the+>clojure-mcpmenucreate-update-project-summary. This prompt will:

- Analyze the codebase structure
- Document key files, dependencies, and available tools
- Generate comprehensive documentation in a format optimized for LLM assistants

Using the Summary: When starting a new conversation with an assistant:

- The "Project Summary" resource automatically loads PROJECT_SUMMARY.md
- This gives the assistant immediate context about the project structure
- The assistant can provide more accurate help without lengthy exploration

Keeping It Updated: At the end of a productive session where new features or components were added:

- Invoke thecreate-update-project-summaryprompt again
- The system will update the PROJECT_SUMMARY.md with newly added functionality
- This ensures the summary stays current with ongoing development

This workflow creates a virtuous cycle where each session builds on the accumulated knowledge of previous sessions, making the assistant increasingly effective as your project evolves.

The Clojure MCP server provides a pair of prompts that enable conversation continuity across chat sessions using thescratch_padtool. By default, data is storedin memory onlyfor the current session. To persist summaries across server restarts, you must enable scratch pad persistence using the configuration options described in the scratch pad section.

The system uses two complementary prompts:
-

chat-session-summarize: Creates a summary of the current conversation

- Saves a detailed summary to the scratch pad
- Captures what was done, what's being worked on, and what's next
- Accepts an optionalchat_session_keyparameter (defaults to"chat_session_summary")

chat-session-resume*: Restores context from a previous conversation

- Reads the PROJECT_SUMMARY.md file
- Callsclojure_inspect_projectfor current project state
- Retrieves the previous session summary from scratch pad
- Provides a brief 8-line summary of where things left off
- Accepts an optionalchat_session_keyparameter (defaults to"chat_session_summary")
- At the end of a productive conversation, invoke thechat-session-summarizeprompt
- The assistant will store a comprehensive summary in the scratch pad
- This summary persists across sessions thanks to the scratch pad's global state
- When continuing work, invoke thechat-session-resumeprompt
- The assistant will load all relevant context and provide a brief summary
- You can then continue where you left off with full context

You can maintain multiple parallel conversation contexts by using custom keys:

# For feature development chat-session-summarize with key "feature-auth-system" # For bug fixing chat-session-summarize with key "debug-memory-leak" # Resume specific context chat-session-resume with key "feature-auth-system"

This enables switching between different development contexts while maintaining the full state of each conversation thread.

Withlist_nrepl_ports, the agent can discover both your Clojure and shadow-cljs REPLs simultaneously. The tool identifies which REPLs are shadow-cljs instances, allowing the agent to evaluate on either REPL usingclojure_evalwith the appropriateportparameter.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.