nrepl-mcp-server
by: JohanCodinha
nRepl mcp server for clojure. Enables interaction with a running Clojure nREPL instance, allowing evaluation of Clojure code, namespace inspection, and other utilities via MCP.
📌Overview
Purpose: This framework serves as an MCP server for Clojure nREPL instances, enabling seamless interaction with Clojure code in various clients like Claude Desktop and CLine.
Overview: The nREPL MCP Server facilitates communication with a running Clojure nREPL, allowing users to evaluate code, inspect namespaces, and access vital project details through the Model Context Protocol (MCP).
Key Features:
-
Connect: Establish a connection to a running nREPL server by specifying its host and port.
-
Evaluate Clojure code: Run Clojure expressions in the current or designated namespace for effective code testing and debugging.
-
List project namespaces: Utilize
tools.namespace
to display all namespaces available in the project, aiding in navigation and organization. -
Retrieve nREPL connection status: Access connection details such as host, port, session ID, and errors to monitor server state.
-
Inspect public vars: Obtain metadata about public variables in any Clojure namespace, including docstrings and values, for deeper understanding of code functionality.
nREPL MCP Server
A Model Context Protocol (MCP) server designed for MCP clients, such as Claude Desktop or CLine in VSCode. This server can be used with any LLM when used with CLine. It enables interaction with a running Clojure nREPL instance, allowing evaluation of Clojure code, namespace inspection, and other utilities via MCP.
Features
- Connect to a running nREPL server by specifying host and port.
- Evaluate Clojure code in a given namespace or the current one.
- List project namespaces using
tools.namespace
. - Retrieve nREPL connection status, including host, port, and session details.
- Inspect public vars in any Clojure namespace, displaying metadata such as docstrings and values.
Installation & Setup
Installing in CLine (VSCode) or Claude Desktop
To use this server with CLine or Claude Desktop:
-
Open CLine in VSCode or Claude Desktop.
-
Navigate to MCP Settings.
-
Add a new MCP server with the following configuration:
{ "mcpServers": { "nrepl-mcp-server": { "command": "npx", "args": [ "nrepl-mcp-server" ], "disabled": false, "autoApprove": [] } } }
-
Save and restart the client to apply changes.
This allows communication with the nREPL MCP server via standard input/output.
Install via npx
Run the server quickly without cloning the repository:
npx nrepl-mcp-server
Manual Installation
-
Clone the repository
-
Install dependencies
npm install
-
Build the project
npm run build
-
Run the server
-
Production Mode: Runs from compiled output.
npm start
-
Development Mode: Uses ts-node for live changes.
npm run dev
-
This starts the server, listening on STDIO for MCP requests. MCP clients will start the server for you.
Actions
Connecting to nREPL
Establish a connection to an nREPL server by specifying a host and port.
Evaluating Clojure Code
Execute arbitrary Clojure expressions in the default namespace or a specified namespace.
Retrieving Namespace Information
List all namespaces in the current project directory using tools.namespace
.
Inspecting Public Vars
Fetch metadata and current values for all public vars in a specified namespace.
Fetching nREPL Connection Status
Get details on the current nREPL connection, including host, port, session ID, and last error (if any).
Resources
nrepl://status
Provides information about the current nREPL connection:
- Host and port
- Connection status
- Active session ID
nrepl://namespaces
Lists all namespaces detected in the project directory.
Contributing
Contributions are welcome! For feature suggestions or bug reports, please open an issue or pull request.
License
This project is licensed under the MIT License. Feel free to modify and distribute according to its terms.