-
-
Notifications
You must be signed in to change notification settings - Fork 56
Documentation for auto-start nREPL feature #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -933,7 +933,7 @@ For a quick start: **[Creating Your Own Custom MCP Server](doc/custom-mcp-server | |||||||||||||||||||||||||
Using the -X invocation requires EDN values. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
#### `:port` | ||||||||||||||||||||||||||
**Required** - The nREPL server port to connect to. | ||||||||||||||||||||||||||
**Optional** - The nREPL server port to connect to. Required unless using `:start-nrepl-cmd` with `:parse-nrepl-port` or relying on an existing `.nrepl-port` file. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
`:port 7888` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -942,6 +942,18 @@ Using the -X invocation requires EDN values. | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
`:host "localhost"` or `:host "0.0.0.0"` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
#### `:start-nrepl-cmd` | ||||||||||||||||||||||||||
**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. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
**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. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
`:start-nrepl-cmd ["lein" "repl" ":headless"]` or `:start-nrepl-cmd ["clojure" "-M:nrepl"]` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+945
to
+951
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Clarify location requirement applies only to auto-start mode. Avoid contradiction with “Location Independence” later in the doc. -**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.
+**Important (auto-start mode only)**: When using `:start-nrepl-cmd`, you must launch `clojure-mcp` from your project directory (where your `deps.edn` or `project.clj` is located). The nREPL server is started in the current working directory. Outside of auto-start mode, you can run the MCP server from any directory. This is particularly useful for Claude Code and other CLI LLM clients where you want automatic nREPL startup without manual process management. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
#### `:parse-nrepl-port` | ||||||||||||||||||||||||||
**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. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
`:parse-nrepl-port true` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+953
to
+956
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix default to match CONFIG.md and clarify stdout-only parsing. Current text says default is false; CONFIG.md says default true when :start-nrepl-cmd is set. Recommend align to true-when-present and mention stdout-only. -**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.
+**Optional** - When `true` and used with `:start-nrepl-cmd`, automatically discovers the nREPL port from the command's stdout (stdout-only) output. Defaults to `true` when `:start-nrepl-cmd` is provided. The parser recognizes common nREPL port announcement formats. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
#### `:config-file` | ||||||||||||||||||||||||||
**Optional** - Specify the location of a configuration file. Must be a path to an existing file. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -968,12 +980,25 @@ Using the -X invocation requires EDN values. | |||||||||||||||||||||||||
# Basic usage with just port | ||||||||||||||||||||||||||
clojure -X:mcp :port 7888 | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# With automatic nREPL server startup and port discovery | ||||||||||||||||||||||||||
# Perfect for Claude Code - run this from your project directory | ||||||||||||||||||||||||||
clojure -X:mcp :start-nrepl-cmd '["lein" "repl" ":headless"]' :parse-nrepl-port true | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# For Claude Code with Clojure projects (from project directory) | ||||||||||||||||||||||||||
clojure -X:mcp :start-nrepl-cmd '["clojure" "-M:nrepl"]' :parse-nrepl-port true | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Auto-start with explicit port (doesn't parse from output) | ||||||||||||||||||||||||||
clojure -X:mcp :port 7888 :start-nrepl-cmd '["clojure" "-M:nrepl"]' | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# With custom host and project directory | ||||||||||||||||||||||||||
clojure -X:mcp :port 7888 :host '"0.0.0.0"' :project-dir '"/path/to/project"' | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Using a custom config file | ||||||||||||||||||||||||||
clojure -X:mcp :port 7888 :config-file '"/path/to/custom-config.edn"' | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Using existing .nrepl-port file (no explicit port needed) | ||||||||||||||||||||||||||
clojure -X:mcp | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Specifying Babashka environment | ||||||||||||||||||||||||||
clojure -X:mcp :port 7888 :nrepl-env-type :bb | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||||
;; Example configuration for automatic nREPL server startup | ||||||||||||||
;; Place this in .clojure-mcp/config.edn in your project root | ||||||||||||||
;; | ||||||||||||||
;; IMPORTANT: This feature requires launching clojure-mcp from your project directory | ||||||||||||||
;; Perfect for Claude Code and other CLI-based LLM tools where you want automatic | ||||||||||||||
;; nREPL startup without managing separate processes | ||||||||||||||
|
||||||||||||||
{;; Automatically start an nREPL server when MCP server starts | ||||||||||||||
;; Must be a vector of strings representing the command and arguments | ||||||||||||||
:start-nrepl-cmd ["clojure" "-M:nrepl"] | ||||||||||||||
|
||||||||||||||
;; Parse the port from nREPL output (default: true when :start-nrepl-cmd is provided) | ||||||||||||||
;; Set to false if you want to use a fixed port specified below | ||||||||||||||
:parse-nrepl-port true | ||||||||||||||
|
||||||||||||||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Clarify stdout-only parsing and implied default. Match the docs: stdout-only, and default true when :start-nrepl-cmd is present. -;; Parse the port from nREPL output (default: true when :start-nrepl-cmd is provided)
+;; Parse the port from nREPL stdout only (default: true when :start-nrepl-cmd is provided)
;; Set to false if you want to use a fixed port specified below
:parse-nrepl-port true 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||
;; Port is optional when :parse-nrepl-port is true | ||||||||||||||
;; Required when :parse-nrepl-port is false | ||||||||||||||
;; :port 7888 | ||||||||||||||
|
||||||||||||||
;; Other common configurations | ||||||||||||||
:allowed-directories ["." "src" "test" "resources"] | ||||||||||||||
:write-file-guard :partial-read | ||||||||||||||
:cljfmt true | ||||||||||||||
:bash-over-nrepl true} | ||||||||||||||
|
||||||||||||||
;; Alternative configurations: | ||||||||||||||
|
||||||||||||||
;; For Leiningen projects (great for Claude Code): | ||||||||||||||
;; {:start-nrepl-cmd ["lein" "repl" ":headless"] | ||||||||||||||
;; :parse-nrepl-port true} | ||||||||||||||
|
||||||||||||||
;; For Babashka: | ||||||||||||||
;; {:start-nrepl-cmd ["bb" "nrepl-server"] | ||||||||||||||
;; :parse-nrepl-port true} | ||||||||||||||
|
||||||||||||||
;; With fixed port (no port parsing): | ||||||||||||||
;; {:start-nrepl-cmd ["clojure" "-M:nrepl"] | ||||||||||||||
;; :parse-nrepl-port false | ||||||||||||||
;; :port 7888} | ||||||||||||||
|
||||||||||||||
;; Claude Code usage: | ||||||||||||||
;; 1. Place this config in your-project/.clojure-mcp/config.edn | ||||||||||||||
;; 2. Open Claude Code in your project directory | ||||||||||||||
;; 3. The nREPL will start automatically when Claude Code connects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default mismatch with README; align on a single truth and clarify stdout-only.
CONFIG.md says default is true when :start-nrepl-cmd is provided, but README says default is false. Recommend making the default “true when :start-nrepl-cmd is set” in both places and reiterating stdout-only behavior to match project preference.
📝 Committable suggestion
🤖 Prompt for AI Agents