Back to MCP directory
publicPublicdnsLocal runtime

Clojure nREPL

一个为MCP客户端(如Claude Desktop或VSCode的CLine)设计的nREPL服务器,支持通过MCP协议与Clojure nREPL实例交互,实现代码评估、命名空间检查等功能。

article

README

🚀 nREPL MCP 服务器

nREPL MCP 服务器是专门为 Model Context Protocol (MCP) 客户端设计的,像 Claude Desktop 或者 VSCode 里的 CLine 都能使用。此服务器可与任何大语言模型(LLM)配合(在通过 CLine 使用时),还能和运行中的 Clojure nREPL 实例 交互,实现指定命名空间或当前命名空间中评估 Clojure 代码、检查命名空间等实用功能。

🚀 快速开始

nREPL MCP 服务器可与多种客户端配合使用,为您提供便捷的 Clojure 代码评估和命名空间管理功能。下面为您介绍不同的安装与使用方式。

✨ 主要特性

  • 连接功能:可连接到正在运行的 nREPL 服务器,只需指定主机和端口。
  • 代码评估:能在指定的命名空间或当前命名空间中评估 Clojure 代码。
  • 命名空间管理:使用 tools.namespace 列出项目命名空间。
  • 状态检索:可检索 nREPL 连接状态,包括主机、端口和会话详细信息。
  • 变量检查:能检查公开变量,获取任何 Clojure 命名空间中的元数据(如文档字符串和值)。

📦 安装指南

在 CLine (VSCode) 或 Claude Desktop 中安装

若要使用此服务器与 CLineClaude Desktop,请按以下步骤操作:

  1. 打开 VSCode 中的 CLineClaude Desktop
  2. 导航到 MCP 设置
  3. 添加一个新的 MCP 服务器,按如下配置:
{
  "mcpServers": {
    "nrepl-mcp-server": {
      "command": "npx",
      "args": [
        "nrepl-mcp-server"
      ],
      "disabled": false,
      "autoApprove": []
    }
  }
}
  1. 保存并重新启动客户端以应用更改。 这样客户端就能通过标准输入/输出与 nREPL MCP 服务器通信。

通过 npx 安装

若想快速运行服务器而无需克隆仓库,可使用以下命令:

npx nrepl-mcp-server

手动安装

  1. 克隆仓库
  2. 安装依赖项
npm install
  1. 构建项目(将 TypeScript 转换为 JavaScript)
npm run build
  1. 运行服务器
    • 生产模式:从编译输出运行。
npm start
- **开发模式**:使用 ts-node 进行实时更改。
npm run dev

执行以上步骤后,服务器将启动,侦听标准输入/输出中的 MCP 请求。MCP 客户端会为您启动服务器。

💻 使用示例

基础用法

以下是通过 npx 快速启动服务器的示例:

npx nrepl-mcp-server

高级用法

手动安装并在开发模式下运行服务器:

# 克隆仓库
git clone <repository-url>
cd <repository-directory>

# 安装依赖项
npm install

# 构建项目
npm run build

# 开发模式运行
npm run dev

📚 详细文档

操作说明

连接到 nREPL

允许通过指定 主机端口 建立与 nREPL 服务器的连接。

评估 Clojure 代码

可执行任意 Clojure 表达式,能在 默认命名空间指定命名空间 中运行。

检索命名空间信息

使用 tools.namespace 列出项目目录中的所有命名空间。

检查公开变量

获取指定命名空间中所有 公共变量 的元数据和当前值。

检索 nREPL 连接状态

提供有关当前 nREPL 连接的详细信息,包括主机、端口、会话 ID 和最后错误(如果有)。

资源信息

nrepl://status

提供有关当前 nREPL 连接的信息,包括:

  • 主机和端口
  • 连接状态
  • 活动会话 ID

nrepl://namespaces

列出项目目录中检测到的所有命名空间。

📄 许可证

该项目遵循 MIT License 许可,您可根据其条款自由修改和分发。

🔗 贡献

欢迎大家贡献代码!如果您有任何功能建议或错误报告,请打开问题或拉取请求。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client