Clojure LSP analysis addon for hive-mcp. Provides structural code analysis via three strategies:
Registered as an IAddon (lsp.mcp). The engine discovers it automatically from the classpath manifest.
lsp-mcp/
src/lsp_mcp/
bridge.clj # ILspBridge protocol (DIP abstraction)
emacs_bridge.clj # EmacsBridge -- Emacs backend (optional)
tools.clj # MCP tool handlers + command dispatch
init.clj # IAddon implementation + nil-railway pipeline
core.clj # Analysis orchestration
cache.clj # Docker sidecar cache client
analysis.clj # Extraction helpers (vars, calls, ns-graph)
kg_bridge.clj # Knowledge Graph sync bridge
log.clj # Logging shim (timbre/stderr)
src-cljel/
hive_lsp_bridge.cljel # Elisp source (Clojure syntax)
resources/
elisp/
hive-lsp-bridge.el # Compiled output (checked in)
META-INF/hive-addons/
lsp-mcp.edn # Addon manifest
.cljel to .elThe src-cljel/ directory contains Elisp source written in Clojure syntax using clojure-elisp. The compiler translates .cljel files to standard Emacs Lisp .el files.
From the lsp-mcp project root:
clojure \
-Sdeps '{:deps {io.github.lages/clojure-elisp {:local/root "/home/lages/PP/clojure-elisp"}}}' \
-M -e '(require (quote [clojure-elisp.core :as clel]))
(clel/compile-file "src-cljel/hive_lsp_bridge.cljel"
"resources/elisp/hive-lsp-bridge.el")'
This reads the .cljel source, compiles all forms through the clojure-elisp analyzer/emitter, and writes the output .el file. The compiled file:
;;; hive-lsp-bridge.el --- -*- lexical-binding: t; -*-clojure-elisp-runtime (must be on Emacs load-path)(provide 'hive-lsp-bridge).cljel source | compiled .el output | Elisp feature name |
|---|---|---|
hive_lsp_bridge.cljel | hive-lsp-bridge.el | hive-lsp-bridge |
The compiler converts underscores to hyphens and derives the feature name from the (ns ...) form.
.cljel definition | compiled Elisp name |
|---|---|
(defn status ...) | hive-lsp-bridge-status |
(defn -find-workspace ...) | hive-lsp-bridge--find-workspace |
(defn hover ...) | hive-lsp-bridge-hover |
Public functions get the namespace prefix (hive-lsp-bridge-). Private functions (prefixed with -) get a double-dash (hive-lsp-bridge--).
For interactive development without recompiling the whole file:
hive_lsp_bridge.cljel in Emacscider-jack-in to the clojure-elisp projectM-x cider-cljel-start to enable the cljel CIDER sessionC-c C-e on any defn form -- compiles to Elisp and evals in Emacs immediatelyM-: (hive-lsp-bridge-status) to verify the function worksRecompile and commit the .el output after changing any .cljel source. The compiled .el is checked into version control so that Emacs can load it at runtime without needing the compiler on the classpath.
.el gets loadedThe compiled .el is loaded on-the-fly by the Clojure bridge, not by user Emacs config. The sequence:
lsp command=emacs-hover)emacs_bridge.clj injects resources/elisp/ into Emacs load-path (once)require-and-call-json generates: (progn (require 'hive-lsp-bridge nil t) (json-encode (hive-lsp-bridge-hover ...)))eval-elisp-with-timeout sends it to Emacs via emacsclient --evalPrerequisites:
clojure-elisp-runtime must be on Emacs load-path (from the clojure-elisp project)lsp-mode and clojure-lsp active| Command | Description |
|---|---|
analyze | Project summary (files, namespaces, vars) |
definitions | List var definitions, optionally filtered by namespace |
calls | Call graph, filtered by namespace/function |
callers | Find callers of a function |
references | Find references to a function |
ns-graph | Namespace dependency graph |
sync | Sync analysis to Knowledge Graph |
status | Cache and bridge status |
| Command | Parameters | Description |
|---|---|---|
emacs-status | -- | Check bridge availability and workspace count |
emacs-workspaces | -- | List active LSP workspaces |
emacs-hover | project_root, file_path, line, column | Hover info at position |
emacs-definition | project_root, file_path, line, column | Go-to-definition |
emacs-references | project_root, file_path, line, column | Find all references |
emacs-symbols | project_root, file_path | Document symbols |
emacs-cursor-info | project_root, file_path, line, column | clojure-lsp cursor info |
emacs-server-info | project_root | clojure-lsp server info |
line and column are 0-based.
MCP tool call
-> tools.clj (command dispatch)
|
+-- Static: core.clj -> cache.clj / clojure-lsp.api
|
+-- Live: ILspBridge protocol
|
+-- EmacsBridge (emacs_bridge.clj)
|
+-- emacsclient --eval
|
+-- (require 'hive-lsp-bridge) [compiled .el]
|
+-- lsp-request -> clojure-lsp in Emacs
The ILspBridge protocol (DIP) decouples tools.clj from any specific LSP backend. EmacsBridge is one implementation; a future StdioBridge could talk to clojure-lsp directly over stdio.
MIT
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |