Skip to content
Radford Smith edited this page May 28, 2025 · 21 revisions

Warning

While you can use these tools alongside Claude Code and other code assistants with their own tooling, we recommend trying the Clojure MCP tools independently first to experience their full capabilities.

See the README for more details.

Setup

1. Clone clojure-mcp to a Local Directory

⚠️ There is currently a bug where Claude Code will report tool errors from Clojure MCP as undefined. To work around this, you can cherry-pick a workaround which converts tool errors to MCP exceptions and allows Claude Code to see the error messages.

# Clone the official repo
git clone https://github.com/bhauman/clojure-mcp.git

# Cherry-pick the error message workaround
cd clojure-mcp
git remote add rads https://github.com/rads/clojure-mcp.git
git fetch rads
git cherry-pick fbdcc73

2. Add the MCP Server to Claude Code

The following command registers the Clojure MCP server with claude so it will connect to the nREPL in the current project. Change /path/to/clojure-mcp to the directory where you cloned clojure-mcp in the previous step.

claude mcp add clojure-mcp -- /bin/sh -c 'PORT=$(cat .nrepl-port); cd /path/to/clojure-mcp && clojure -X:mcp :port $PORT'

3. Start the nREPL for Your Project

To use the Clojure MCP server, you need to start an nREPL for your project. If you don't already have a way to start an nREPL, there is an example :nrepl alias in the README. Make sure the nREPL server is running before moving to the next step.

4. Start Claude Code

Run the claude command in your project directory to start Claude Code and run the Clojure MCP server as a subprocess. Since it may take some time to start the MCP server and connect to the project's nREPL, you can check the status with the /mcp command:

> /mcp
  ⎿  MCP Server Status

     • clojure-mcp: connected

5. Optional: Configure Claude Code

Since Claude Code does not allow users to disable the native tools directly, the following prompt is a starting point to encourage Claude to use the Clojure MCP server as intended:

~/.claude/CLAUDE.md (user configuration)

## Clojure MCP

Claude is being used for Clojure projects with the Clojure MCP server, which replaces the built in Claude Code tools. If `clojure-mcp` is available, Claude should ONLY use the tools provided by Clojure MCP server:

- Instead of the `Grep` tool, use `mcp__clojure-mcp__fs_grep`.
- Instead of the `Bash` tool, use `mcp__clojure-mcp__bash`.
- Instead of the `Read` tool, use `mcp__clojure-mcp__read_file`.
- Instead of the `Edit` tool, use `mcp__clojure-mcp__clojure_edit`.
- Instead of the `Agent` tool, use `mcp__clojure-mcp__dispatch_agent`.
- When thinking, use the `mcp__clojure-mcp__think` tool.
- When editing a Clojure file, use the `mcp__clojure-mcp__clojure_edit` tool.
- When editing a non-Clojure file, use the `mcp__clojure-mcp__file_edit` tool.
- To evaluate Clojure code, use `mcp__clojure-mcp__clojure_eval`.

We can also set permissions to prevent Claude Code from using most of its built-in tools. This doesn't seem to disable the native tools completely, but it will at least prevent additional tools from being used:

/your/project/dir/.claude/settings.local.json (local project configuration)

{
  "permissions": {
    "allow": [],
    "deny": [
      "Agent",
      "Bash",
      "Glob",
      "Grep",
      "LS",
      "Read",
      "Edit",
      "Write",
      "NotebookEdit",
      "NotebookRead",
      "WebFetch"
    ]
  }
}
Clone this wiki locally