Skip to content

Clojure-mcp fails when CIDER middleware is enabled (project directory detection fails) #137

@u473t8

Description

@u473t8

Description

I’m seeing a crash in clojure-mcp when connecting to an nREPL that was started with CIDER middleware enabled.

The MCP server throws ex-info "No project directory!!" and kills the REPL process.
The same setup works correctly if CIDER middleware is removed.

This looks like an incompatibility between clojure-mcp’s project directory detection and cider.nrepl/cider-middleware.

Version used:

v0.1.12

Reproduction Steps

1. deps.edn (project directory)

{:aliases
 {:nrepl
  {:extra-deps
   {nrepl/nrepl                   {:mvn/version "1.5.1"}
    cider/cider-nrepl             {:mvn/version "0.58.0"}
    refactor-nrepl/refactor-nrepl {:mvn/version "3.11.0"}}

   :main-opts
   ["-m"           "nrepl.cmdline"
    "--middleware" "[refactor-nrepl.middleware/wrap-refactor]"
    "--middleware" "[cider.nrepl/cider-middleware]" ;; the issue disappears when this middleware is commented out
    "--port"       "7888"]}}}

2. Start nREPL (this works by itself)

clojure -M:nrepl --port 7888

3. Start clojure-mcp

clojure -X:mcp

4. Result
The MCP server fails with:

ex-info: No project directory!!

and the REPL process is terminated.

Expected behavior

Clojure-mcp should correctly determine the project directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions