CL-TRON-MCP
基于AI的通用Lisp调试
一种模型上下文协议(MCP)服务器,使AI助手能够深度访问 运行SBCL Common Lisp应用程序——调试器、检查器、分析器和热 代码重新加载。
运作原理
在行动中看到它
这些演示展示了 真正的MCP JSON-RPC协议 AI代理发送给Tron --而不是内部函数调用。
协议发现 --工具、资源和指导性提示:
实时健康监测 --健康检查和运行时统计:
______________________________________________________________________
调试器功能中的热重新加载 --在调试器运行时编译函数 激活,调用 CONTINUE 要重试失败的调用,请执行以下操作:
Common Lisp的一个独特功能是能够修改正在运行的代码,而无需 展开调用堆栈。
在这个例子中,我们定义了一个函数 f1 有两个论点,立即 呼叫a _未定义_ 功能 f2 具有相同的两个论点。召唤 (f1 1 2) 立即将执行抛入调试器。然后,MCP可以在 调试器,注入以下定义 f2 (简单 (defun f2 (x y) (+ x y))) 并在中断的地方重新开始执行。
录音显示了MCP和 通用Lisp Swank服务器。
看 demo/README.md 在设置阶段(Swank启动+REPL连接)。
______________________________________________________________________
Factorial:调试、修复、验证 — DIVISION-BY-ZERO,检查重新启动,热重新加载修复程序:
看 demo/README.md 对于所有6个演示阶段。
______________________________________________________________________
建筑
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ SBCL + Swank │◄───────►│ Tron (MCP) │◄───────►│ AI Client │
│ (Port 4006) │ │ (stdio) │ │ (Kilocode, etc) │
│ │ │ │ │ │
│ Your code │ │ 92 tools: │ │ Sends prompts │
│ Debugger │ │ - swank_eval │ │ Receives │
│ Threads │ │ - inspect │ │ results │
│ State lives │ │ - profile │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
▲ │
│ │
└──────────────────────────────────────────────────────┘
Same session, no restart密钥: 所有州都生活在SBCL过程中。Tron以客户端身份连接。这 会话在调试、热重新加载和错误期间持续存在。
📖 完整的架构文档→
特性
| 类别 | 描述 | 文档 |
|---|---|---|
| 调试器 | 回溯、重启、步进、断点 | docs/tools/debugger.md |
| 检查员 | 对象、槽、类、函数、包 | docs/tools/inspector.md |
| 热重载 | 编译字符串,重新加载系统 | docs/tools/hot-reload.md |
| 分析器 | 启动/停止分析,生成报告 | docs/tools/profiler.md |
| 线程 | 列出、检查、获取回溯 | docs/tools/threads.md |
| 监视器 | 健康检查、运行时统计数据、GC | docs/tools/monitor.md |
| 诗韵 | Slime/Portacle集成(21个工具) | docs/swank-integration.md |
总共92个工具 横跨14个类别。
快速工具示例
调试错误 (使用MCP工具名称):
repl_eval code: "(my-buggy-function 7)" ; triggers error
debugger_frames ; see stack frames
repl_invoke_restart restart_index: 5 ; abort to top level
repl_compile code: "(defun my-buggy-function ...)" ; hot-reload fix配置文件性能:
profile_start
repl_eval code: "(process-data)"
profile_stop
profile_report format: "flat"查找呼叫者:
who_calls symbol_name: "my-package:process"📖 更多工作流示例→
可由AI代理发现
MCP是 完全可发现:AI代理可以在没有任何用户解释的情况下学习如何使用它。
- 短路径: 代理人打电话来
prompts/get以名字
discover-mcp。这将返回确切的步骤: resources/list → resources/read 代理商.md→ prompts/list → prompts/get 开始→ tools/list之后,代理就拥有了连接所需的一切, 评估、调试、检查、分析和热重新加载。
- 读取路径: 代理人打电话来
resources/list那么resources/read
与uri AGENTS.md该文件(以及所列其他资源) 解释了一个长时间运行的Lisp会话、连接、工具、工作流和 习俗。
不需要手动“如何使用Tron”说明。标准MCP方法 (resources/list, resources/read, prompts/list, prompts/get, tools/list)足够了。
快速开始
推荐: 将Tron作为长时间运行的HTTP服务器启动一次,然后配置 MCP客户端通过流式HTTP连接。这使得Tron在IDE中运行 会话无需重复启动。
./start-mcp.sh # Start long-running HTTP server (port 4006)
./start-mcp.sh --status # Check if server is running
./start-mcp.sh --stop # Stop the server对于需要stdio的MCP客户端(例如,较旧的配置),请使用 --stdio-only这创建了一个短暂的进程,当客户端断开连接时退出。
| 模式 | 命令 | 生命周期 | 用例 |
|---|---|---|---|
| 结合 | (默认) | 长时间运行的HTTP | 建议用于IDE会话 |
| 仅限stdio | --stdio-only | 当客户端断开连接时退出 | MCP客户端启动服务器 |
| 仅限http | --http-only | 长时间运行的HTTP | 与组合相同 |
跑 ./start-mcp.sh --help 对于所有选项。看 docs/starting-the-mcp.md 了解详情。
1.启动Swank服务器
;; In SBCL
(ql:quickload :swank)
(swank:create-server :port 4006 :dont-close t)2.配置您的AI客户端
您可以从以下位置运行MCP 本地副本 或从a GitHub仓库的克隆在这两种情况下,客户端都会运行一个命令 start-mcp.sh (或等效)在项目目录中。
获取服务器
| 选项 | 该怎么办 |
|---|---|
| 本地副本 | 您已经在磁盘上拥有仓库(例如 ~/quicklisp/local-projects/cl-tron-mcp).在下面的配置中使用该路径。 |
| 来自GitHub | 克隆仓库,然后使用克隆目录的路径: git clone https://github.com/Alba-Intelligence/cl-tron-mcp.git 和 cd cl-tron-mcp.在config中,设置克隆它的路径(例如。 ~/cl-tron-mcp). |
下面的配置示例使用 波浪线扩展 (~)对于标准Quicklisp路径。MCP客户端支持 ~ 但不支持 $HOME 或其他环境变量。如果您的Quicklisp位于其他位置,请调整路径。
快速设置: 使用配置生成器脚本创建所有具有绝对路径的MCP客户端配置:
# Interactive menu - select which clients to configure
./create_configs.sh
# Or generate all configs at once
./create_configs.sh --all
# Or generate a specific client config
./create_configs.sh --client cursor
./create_configs.sh --client kilocode
./create_configs.sh --client vscode
./create_configs.sh --client copilot
./create_configs.sh --client copilot-cli
./create_configs.sh --client opencode
./create_configs.sh --client claude
# Or use start-mcp.sh --config (same as create_configs.sh)
./start-mcp.sh --config该脚本生成具有绝对路径的配置文件(否 ~ 或 $HOME),这是JSON配置文件所必需的。
公里码
配置文件: .kilocode/mcp.json (项目)或全局MCP设置。回购提供 两者 不同服务器名称下的Tron变体,以便您可以 选一个:
| 服务器名称 | 传输 | 如果…,请选择此项 |
|---|---|---|
| cl tron mcp标准 | STDIO | 您希望Kilocode启动Tron(默认) |
| cl-tron mcp http | 流式HTTP | 您运行 ./start-mcp.sh --http 你自己 |
启用您想要的选项(disabled: false);使另一个处于禁用状态或将其删除。请参阅 examples/kilocode-mcp.json.example 对于同时包含这两个条目的模板。
STDIO(建议使用cl tron mcp STDIO):
{
"mcpServers": {
"cl-tron-mcp": {
"command": "~/quicklisp/local-projects/cl-tron-mcp/start-mcp.sh",
"args": ["--stdio-only"],
"disabled": false
}
}
}流式HTTP(cl-tron mcp-HTTP): 开始Tron ./start-mcp.sh (合并)或 ./start-mcp.sh --http-only [--port 4006],然后设置 "type": "streamable-http" 和 "url": "http://127.0.0.1:4006/mcp".
开源代码
配置文件: ~/.config/opencode/opencode.json.
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"cl-tron-mcp": {
"type": "local",
"command": "~/quicklisp/local-projects/cl-tron-mcp/start-mcp.sh",
"enabled": true
}
}
}光标
配置文件: ~/.cursor/mcp.json (或光标MCP设置)。
{
"mcpServers": {
"cl-tron-mcp": {
"command": "~/quicklisp/local-projects/cl-tron-mcp/start-mcp.sh",
"args": ["--stdio-only"],
"disabled": false,
"env": {}
}
}
}GitHub副本(VS代码)
GitHub Copilot使用VS Code的内置MCP支持(VS Code 1.99+)。将Tron添加到您的 工作区 配置在 .vscode/mcp.json:
{
"servers": {
"cl-tron-mcp": {
"type": "stdio",
"command": "bash",
"args": ["-c", "cd ~/quicklisp/local-projects/cl-tron-mcp && ./start-mcp.sh --stdio-only"]
}
}
}或添加到您的 用户设置 (settings.json):
{
"mcp": {
"servers": {
"cl-tron-mcp": {
"type": "stdio",
"command": "bash",
"args": ["-c", "cd ~/quicklisp/local-projects/cl-tron-mcp && ./start-mcp.sh --stdio-only"]
}
}
}
}回购 .vscode/mcp.json 已为此工作区预先配置。跑 ./create_configs.sh --client copilot 生成用户级配置。
GitHub Copilot命令行界面
Copilot CLI使用 ~/.copilot/mcp-config.json 和 mcpServers 在顶层和 "type": "local":
{
"mcpServers": {
"cl-tron-mcp": {
"type": "local",
"command": "bash",
"args": ["-c", "cd ~/quicklisp/local-projects/cl-tron-mcp && ./start-mcp.sh --stdio-only"],
"env": {},
"tools": ["*"]
}
}
}跑 ./create_configs.sh --client copilot-cli 生成此文件,或使用 /mcp add 在CLI内部。
克劳德桌面
配置文件: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)或 %APPDATA%\Claude\claude_desktop_config.json (Windows)。
{
"mcpServers": {
"cl-tron-mcp": {
"command": "bash",
"args": ["-c", "cd ~/quicklisp/local-projects/cl-tron-mcp && ./start-mcp.sh --stdio-only"]
}
}
}跑 ./create_configs.sh --client claude 生成此文件。
devenv(NixOS/Nix用户)
如果您使用以下方式管理您的开发环境 开发环境,Tron通过以下方式进行本地集成 devenv.nix克隆仓库后,devenv环境已经包含SBCL和所有必需的包。
两种使用模式:
| 模式 | 命令 | 最适合 |
|---|---|---|
| HTTP服务器 (持续) | devenv up | 开发——让Tron在4006端口上运行 |
| 工作室 (按需) | tron-mcp (在shell中) | 每个会话生成服务器的MCP客户端 |
快速启动: 当您输入devenv shell时(devenv shell),the tron-mcp:precompile 任务自动将Lisp源代码编译到缓存 .fasl 文件夹。后续的MCP启动需要大约2秒,而不是大约8秒。
MCP客户端配置(使用devenv): 而不是硬编码 ./start-mcp.sh,将您的客户指向 devenv shell -- tron-mcp这确保了SBCL和所有env变量都来自devenv,甚至来自shell外部:
{
"mcpServers": {
"cl-tron-mcp": {
"command": "devenv",
"args": ["shell", "--", "tron-mcp"],
"cwd": "/path/to/cl-tron-mcp"
}
}
}跑 ./create_configs.sh --client devenv 查看当前路径的完整说明。
注: devenv mcp 是devenv自己的内置MCP服务器(用于查询Nix包/选项)。它与Tron无关,不能用于运行Tron。其他客户(克劳德代码等)
任何运行以下命令的MCP客户端 本地指挥 可以以相同的方式使用Tron:
- 克隆或复制仓库:
git clone https://github.com/Alba-Intelligence/cl-tron-mcp.git(或使用现有的本地路径)。 - 在客户端的MCP配置中,添加一个服务器条目,其 命令 通过stdio运行MCP,例如:
- 首选: ["~/quicklisp/local-projects/cl-tron-mcp/start-mcp.sh", "--stdio-only"] - 备选方案(仅限SBCL): ["sbcl", "--non-interactive", "--noinform", "--eval", "(ql:quickload :cl-tron-mcp :silent t)", "--eval", "(cl-tron-mcp/core:start-server :transport :stdio-only)"]
确保 SBCL (或ECL)以及 Quicklisp 当客户端启动服务器时,它们位于PATH上。要强制ECL,请使用 ["~/quicklisp/local-projects/cl-tron-mcp/start-mcp.sh", "--use-ecl"].
配置文件示例: examples/cursor-mcp.json.example, examples/kilocode-mcp.json.example, examples/opencode-mcp.json.example.
3.开始调试
问你的AI: _“连接到端口4006上的Swank并调试factorial-example.lisp”_
安装
Quicklisp
(ql:quickload :cl-tron-mcp)来自源头
git clone https://github.com/Alba-Intelligence/cl-tron-mcp.git
cd cl-tron-mcp
sbcl --eval '(load "cl-tron-mcp.asd")' --eval '(ql:quickload :cl-tron-mcp)'发展
运行测试
(asdf:test-system :cl-tron-mcp)
;; Or with Rove
(ql:quickload :rove)
(rove:run :cl-tron-mcp/tests)项目结构
cl-tron-mcp/
├── src/ # Source code
│ ├── core/ # Core infrastructure
│ ├── swank/ # Swank client
│ ├── tools/ # Tool definitions
│ └── ...
├── tests/ # Rove test suites
├── scripts/ # run-http.sh, tutorial-run.lisp, debug-mcp-stdio.sh
├── examples/ # MCP config examples, mcp-kilocode.json, example Python clients
├── docs/ # Documentation
│ ├── architecture.md # How it works
│ ├── DEVELOPERS.md # Developer guide (where to add features)
│ ├── swank-integration.md
│ └── tools/ # Tool docs
├── prompts/ # Workflow guides
├── demo/ # Demo scripts, asciinema recordings (.cast), and GIFs (see [demo/README.md](demo/README.md))
└── AGENTS.md # AI agent guidelines文档
| 文件 | 目的 |
|---|---|
| 代理商.md | 使用Tron快速启动AI代理 |
| docs/architecture.md | 系统架构与设计 |
| docs/swank-integration.md | Swank协议详细信息 |
| docs/mcp-resources-prompts.md | MCP可发现性特征 |
| docs/protocol-handlers.md | JSON-RPC协议处理程序文档 |
| docs/starting-the-mcp.md | 启动MCP并排除故障 |
| docs/demo-create.md | 如何创建演示GIF |
| 教程/e2e-mcp-workflow.md | 端到端工作流(连接、评估、错误、重新启动、热修复) |
| 提示/工作流-examples.md | 分步使用示例 |
| 提示/调试工作流.md | 调试模式 |
贡献
看 贡献.md 用于设置、测试和PR过程,以及 docs/DEVELOPERS.md 在哪里添加功能以及如何组织代码库。
- 分叉存储库
- 创建要素分支
- 遵循以下指南 代理商.md
- 添加测试
- 提交拉取请求
需求
- SBCL 2.0.0或更高版本,或 ECL (可嵌入的Common Lisp)。MCP服务器使用其中之一运行。
start-mcp.sh通过以下方式选择Lisp:--use-sbcl/--use-ecl(CLI)或自动检测(sbcl,然后ecl)。跑./start-mcp.sh --help完全使用。 - Quicklisp
- 诗韵 (适用于Slime/Portacle/Sly)
服务器管理
对于HTTP和组合模式, start-mcp.sh 包括服务器检测和会话管理:
./start-mcp.sh --status # Check if server is running (shows PID, port, uptime)
./start-mcp.sh --stop # Stop a running server gracefully
./start-mcp.sh --restart # Stop existing and start new instancePID文件(.tron-server.pid)包含JSON元数据: {"pid": 12345, "port": 4006, "transport": "combined", "started": 1709000000}该脚本会自动检测服务器是否已在运行(通过PID文件和健康端点),并成功退出,而不会启动重复的实例。
使用 --restart 当你想停止一个旧实例并启动一个新实例时(例如,在更新代码之后)。
故障排除
| 问题 | 解决方案 |
|---|---|
| “找不到包” | (ql:quickload :cl-tron-mcp) 首先 |
| 客户端显示“失败” | 使用 start-mcp.sh 正确处理stdio |
| “未连接到REPL” | 运行 swank_connect 或 repl_connect 首先 |
| 测试因FASL过时而失败 | (asdf:compile-system :cl-tron-mcp :force t) |
许可证
Apache许可证2.0。看 许可证 文件。
