Skip to content

Commit 9d18ab4

Browse files
author
Bruce Hauman
committed
Remove :parse-nrepl-port option for simpler nREPL auto-start
BREAKING CHANGE: The :parse-nrepl-port configuration option has been removed. Port parsing is now automatic based on the presence of :port. Simplifications: - When :start-nrepl-cmd is used WITHOUT :port, automatically parse from output - When :start-nrepl-cmd is used WITH :port, use that fixed port - Eliminates confusing configuration combinations - Makes the feature more intuitive for users Migration: - Remove :parse-nrepl-port from all configurations - Old: :start-nrepl-cmd [...] :parse-nrepl-port true - New: :start-nrepl-cmd [...] Documentation: - Added Claude Desktop limitations (requires :project-dir) - Emphasized Claude Code compatibility - Provided clear examples for different use cases
1 parent 4b8eacb commit 9d18ab4

File tree

10 files changed

+157
-172
lines changed

10 files changed

+157
-172
lines changed

CHANGELOG.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,71 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Simplified nREPL Auto-Start 🚀
6+
7+
**Launching an nREPL server is now incredibly simple!** Just provide `:start-nrepl-cmd` and the MCP server handles everything else - perfect for Claude Code and other CLI-based AI tools.
8+
9+
#### Quick Start Examples
10+
11+
**From your project directory**, just run:
12+
13+
```bash
14+
# For Leiningen projects
15+
clojure -X:mcp :start-nrepl-cmd '["lein" "repl" ":headless"]'
16+
17+
# For deps.edn projects
18+
clojure -X:mcp :start-nrepl-cmd '["clojure" "-M:nrepl"]'
19+
20+
# For Babashka scripts
21+
clojure -X:mcp :start-nrepl-cmd '["bb" "nrepl-server"]'
22+
```
23+
24+
That's it! The MCP server will:
25+
- Start your nREPL server automatically
26+
- Discover the port from the output
27+
- Connect and manage the process lifecycle
28+
- Clean up when you're done
29+
30+
#### Perfect for Claude Code
31+
32+
This feature is especially valuable for **Claude Code** users who want to start coding immediately without managing separate terminal windows:
33+
34+
1. Open Claude Code in your Clojure project directory
35+
2. The nREPL starts automatically when Claude connects
36+
3. Start coding with full REPL support!
37+
38+
You can also configure this in `.clojure-mcp/config.edn`:
39+
```edn
40+
{:start-nrepl-cmd ["clojure" "-M:nrepl"]}
41+
```
42+
43+
#### Note for Claude Desktop Users
44+
45+
**Important**: Claude Desktop does not start MCP servers from your project directory, so `:start-nrepl-cmd` will not work unless you also provide `:project-dir` pointing to your specific project:
46+
47+
```bash
48+
# For Claude Desktop, you must specify the project directory:
49+
clojure -X:mcp :start-nrepl-cmd '["lein" "repl" ":headless"]' :project-dir '"/path/to/your/clojure/project"'
50+
```
51+
52+
This limitation does not affect Claude Code or other CLI-based tools that you run directly from your project directory.
53+
54+
#### Using a Fixed Port
55+
56+
If you prefer a specific port, just add it:
57+
```bash
58+
clojure -X:mcp :start-nrepl-cmd '["lein" "repl" ":headless"]' :port 7888
59+
```
60+
61+
### Breaking Changes
62+
- **Removed `:parse-nrepl-port`**: This confusing option has been eliminated. The MCP server now intelligently determines whether to parse the port based on whether `:port` is provided. Simple!
63+
64+
### Migration Note
65+
If you were using `:parse-nrepl-port`, just remove it:
66+
- Old: `:start-nrepl-cmd ["..."] :parse-nrepl-port true`
67+
- New: `:start-nrepl-cmd ["..."]`
68+
369
## [0.1.9-alpha] - 2025-9-16
470

571
### Major Refactoring: Configuration-Based Agent Tools

CONFIG.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ The timestamp tracking system prevents accidental overwrites when files are modi
4444

4545
**Important**: This feature requires the MCP server to be launched from your project directory (where your `deps.edn` or `project.clj` is located). The nREPL server will be started in the current working directory. This makes it ideal for use with Claude Code and other command-line LLM clients where you want automatic nREPL startup - you can simply start Claude Code in your project directory and the nREPL will launch automatically.
4646

47+
**Note for Claude Desktop users**: Claude Desktop does not start MCP servers from your project directory, so `:start-nrepl-cmd` in your config file will not work by itself. You must also configure the `:project-dir` argument in Claude Desktop's settings to point to your specific project. This limitation does not affect Claude Code or other CLI-based tools that you run from your project directory.
48+
49+
**Behavior:**
50+
- When used without `:port`, the MCP server will automatically parse the port from the command's output
51+
- When used with `:port`, it will use that fixed port instead of parsing from output
52+
4753
**Available values:**
4854
- `["lein" "repl" ":headless"]` - Start Leiningen REPL in headless mode
4955
- `["clojure" "-M:nrepl"]` - Start Clojure with nREPL alias
@@ -54,19 +60,6 @@ The timestamp tracking system prevents accidental overwrites when files are modi
5460
- When you want automatic nREPL server management without separate terminal windows
5561
- In CI/CD environments where automatic startup is beneficial
5662

57-
### `:parse-nrepl-port`
58-
**Optional** - When `true` and used with `:start-nrepl-cmd`, automatically discovers the nREPL port from the command's stdout output. Defaults to `true` when `:start-nrepl-cmd` is provided. The parser recognizes common nREPL port announcement formats.
59-
60-
**Available values:**
61-
- `true` (default when `:start-nrepl-cmd` is provided) - Parse port from nREPL output
62-
- `false` - Don't parse port; requires `:port` to be explicitly provided
63-
64-
**When to use:**
65-
- `true` - When the nREPL server announces its port in stdout (most common case)
66-
- `false` - When using a fixed port configuration or when port is known in advance
67-
68-
**Note:** When `:parse-nrepl-port` is `false`, you must provide the `:port` configuration.
69-
7063
### `:emacs-notify`
7164
Boolean flag to enable Emacs integration notifications.
7265

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ For a quick start: **[Creating Your Own Custom MCP Server](doc/custom-mcp-server
933933
Using the -X invocation requires EDN values.
934934

935935
#### `:port`
936-
**Optional** - The nREPL server port to connect to. **Required** unless using `:start-nrepl-cmd` with `:parse-nrepl-port`
936+
**Optional** - The nREPL server port to connect to. When using `:start-nrepl-cmd` without `:port`, the port will be automatically discovered from the command output.
937937

938938
`:port 7888`
939939

@@ -943,16 +943,15 @@ Using the -X invocation requires EDN values.
943943
`:host "localhost"` or `:host "0.0.0.0"`
944944

945945
#### `:start-nrepl-cmd`
946-
**Optional** - A command to automatically start an nREPL server if one is not already running. Must be specified as a vector of strings. The MCP server will start this process and manage its lifecycle.
946+
**Optional** - A command to automatically start an nREPL server if one is not already running. Must be specified as a vector of strings. The MCP server will start this process and manage its lifecycle.
947947

948-
**Important**: This option requires launching `clojure-mcp` from your project directory (where your `deps.edn` or `project.clj` is located). The nREPL server will be started in the current working directory. This is particularly useful for Claude Code and other command-line LLM clients where you want automatic nREPL startup without manual process management.
948+
When used without `:port`, the MCP server will automatically parse the port from the command's output. When used with `:port`, it will use that fixed port instead.
949949

950-
`:start-nrepl-cmd ["lein" "repl" ":headless"]` or `:start-nrepl-cmd ["clojure" "-M:nrepl"]`
950+
**Important**: This option requires launching `clojure-mcp` from your project directory (where your `deps.edn` or `project.clj` is located). The nREPL server will be started in the current working directory. This is particularly useful for Claude Code and other command-line LLM clients where you want automatic nREPL startup without manual process management.
951951

952-
#### `:parse-nrepl-port`
953-
**Optional** - When `true` and used with `:start-nrepl-cmd`, automatically discovers the nREPL port from the command's stdout output. Defaults to `false`. The parser recognizes common nREPL port announcement formats.
952+
**Note for Claude Desktop users**: Claude Desktop does not start MCP servers from your project directory, so `:start-nrepl-cmd` will not work unless you also provide `:project-dir` as a command line argument pointing to your specific project. For example: `:project-dir '"/path/to/your/clojure/project"'`. This limitation does not affect Claude Code or other CLI-based tools that you run from your project directory.
954953

955-
`:parse-nrepl-port true`
954+
`:start-nrepl-cmd ["lein" "repl" ":headless"]` or `:start-nrepl-cmd ["clojure" "-M:nrepl"]`
956955

957956
#### `:config-file`
958957
**Optional** - Specify the location of a configuration file. Must be a path to an existing file.
@@ -982,14 +981,17 @@ clojure -X:mcp :port 7888
982981

983982
# With automatic nREPL server startup and port discovery
984983
# Perfect for Claude Code - run this from your project directory
985-
clojure -X:mcp :start-nrepl-cmd '["lein" "repl" ":headless"]' :parse-nrepl-port true
984+
clojure -X:mcp :start-nrepl-cmd '["lein" "repl" ":headless"]'
986985

987986
# For Claude Code with Clojure projects (from project directory)
988-
clojure -X:mcp :start-nrepl-cmd '["clojure" "-M:nrepl"]' :parse-nrepl-port true
987+
clojure -X:mcp :start-nrepl-cmd '["clojure" "-M:nrepl"]'
989988

990-
# Auto-start with explicit port (doesn't parse from output)
989+
# Auto-start with explicit port (uses fixed port, no parsing)
991990
clojure -X:mcp :port 7888 :start-nrepl-cmd '["clojure" "-M:nrepl"]'
992991

992+
# For Claude Desktop: must provide project-dir since it doesn't run from your project
993+
clojure -X:mcp :start-nrepl-cmd '["lein" "repl" ":headless"]' :project-dir '"/path/to/your/clojure/project"'
994+
993995
# With custom host and project directory
994996
clojure -X:mcp :port 7888 :host '"0.0.0.0"' :project-dir '"/path/to/project"'
995997

deps.edn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
:exec-args {:port 7888
7878
;; test auto starting the repl
7979
;; :start-nrepl-cmd ["clojure" "-M:nrepl"]
80-
;; :parse-nrepl-port true
8180
}}
8281

8382
;; DEV setup needs logback.xml

resources/configs/example-auto-start-nrepl.edn

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
;; Must be a vector of strings representing the command and arguments
1010
:start-nrepl-cmd ["clojure" "-M:nrepl"]
1111

12-
;; Parse the port from nREPL output (default: true when :start-nrepl-cmd is provided)
13-
;; Set to false if you want to use a fixed port specified below
14-
:parse-nrepl-port true
15-
16-
;; Port is optional when :parse-nrepl-port is true
17-
;; Required when :parse-nrepl-port is false
12+
;; Port is optional - if not provided, MCP will parse it from nREPL output
13+
;; Provide :port if you want to use a fixed port instead of parsing
1814
;; :port 7888
1915

2016
;; Other common configurations
@@ -26,16 +22,13 @@
2622
;; Alternative configurations:
2723

2824
;; For Leiningen projects (great for Claude Code):
29-
;; {:start-nrepl-cmd ["lein" "repl" ":headless"]
30-
;; :parse-nrepl-port true}
25+
;; {:start-nrepl-cmd ["lein" "repl" ":headless"]}
3126

3227
;; For Babashka:
33-
;; {:start-nrepl-cmd ["bb" "nrepl-server"]
34-
;; :parse-nrepl-port true}
28+
;; {:start-nrepl-cmd ["bb" "nrepl-server"]}
3529

3630
;; With fixed port (no port parsing):
3731
;; {:start-nrepl-cmd ["clojure" "-M:nrepl"]
38-
;; :parse-nrepl-port false
3932
;; :port 7888}
4033

4134
;; Claude Code usage:

src/clojure_mcp/config/schema.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,8 @@
263263
[:bash-over-nrepl {:optional true} :boolean]
264264
[:nrepl-env-type {:optional true} [:enum :clj :bb :basilisp :scittle]]
265265
[:start-nrepl-cmd {:optional true} [:sequential NonBlankString]]
266-
[:parse-nrepl-port {:optional true} :boolean]
267266

268-
;; Scratch pad configuration
267+
;; Scratch pad configuration
269268
[:scratch-pad-load {:optional true} :boolean]
270269
[:scratch-pad-file {:optional true} Path]
271270

src/clojure_mcp/core.clj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,9 @@
364364
(and (.exists f) (.isFile f)))
365365
(catch Exception _ false))))
366366
(s/def ::start-nrepl-cmd (s/coll-of string? :kind vector?))
367-
(s/def ::parse-nrepl-port boolean?)
368367
(s/def ::nrepl-args (s/keys :req-un []
369368
:opt-un [::port ::host ::config-file ::project-dir ::nrepl-env-type
370-
::start-nrepl-cmd ::parse-nrepl-port]))
369+
::start-nrepl-cmd]))
371370

372371
(def nrepl-client-atom (atom nil))
373372

@@ -552,7 +551,7 @@
552551
553552
If auto-start conditions are met (see nrepl-launcher/should-start-nrepl?), it will:
554553
1. Start an nREPL server process using :start-nrepl-cmd
555-
2. Parse the port from process output (if :parse-nrepl-port is true)
554+
2. Parse the port from process output (if no :port provided)
556555
3. Pass the discovered port to the main MCP server setup
557556
558557
Otherwise, it requires a :port parameter.
@@ -561,10 +560,10 @@
561560
- nrepl-args: Map with connection settings and optional nREPL start
562561
configuration
563562
- :port (required if not auto-starting) - nREPL server port
563+
When provided with :start-nrepl-cmd, uses fixed port instead of parsing
564564
- :host (optional) - nREPL server host (defaults to localhost)
565565
- :project-dir (optional) - Root directory for the project
566566
- :start-nrepl-cmd (optional) - Command to start nREPL server
567-
- :parse-nrepl-port (optional) - Parse port from command output (default true)
568567
569568
- component-factories: Map with factory functions
570569
- :make-tools-fn - (fn [nrepl-client-atom working-dir] ...) returns seq of tools

0 commit comments

Comments
 (0)