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 like Claude Desktop or CLine in VSCode. This server interacts with a running Clojure nREPL instance, allowing the evaluation of Clojure code, namespace inspection, and more.
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 like docstrings and values.
Installation & Setup
Installing in CLine (VSCode) or Claude Desktop
- Open CLine or Claude Desktop.
- Navigate to MCP Settings.
- Add a new MCP server configuration:
{ "mcpServers": { "nrepl-mcp-server": { "command": "npx", "args": [ "nrepl-mcp-server" ], "disabled": false, "autoApprove": [] } } }
- Save and restart the client.
Install via npx
To quickly run the server:
npx nrepl-mcp-server
Manual Installation
- Clone the repository.
- Install dependencies:
npm install
- Build the project:
npm run build
- Run the server:
- Production Mode:
npm start
- Development Mode:
npm run dev
- Production Mode:
Actions
Connecting to nREPL
Connects to an nREPL server by specifying a host and port.
Evaluating Clojure Code
Executes arbitrary Clojure expressions in the default or specified namespace.
Retrieving Namespace Information
Lists all namespaces in the current project directory using tools.namespace
.
Inspecting Public Vars
Fetches metadata and current values for public vars in a specified namespace.
Fetching nREPL Connection Status
Provides details on the current nREPL connection, including host, port, session ID, and potential last error.
Resources
nrepl://status
Provides information about the current nREPL connection, including host and port, connection status, and active session ID.
nrepl://namespaces
Lists all detected namespaces in the project directory.
Contributing
Contributions are welcome! If you have feature suggestions or bug reports, please open an issue or pull request.
License
This project is licensed under the MIT License.