Nanobot与Claude code best协作
Nanobot[GitHub - HKUDS/nanobot: Lightweight, open-source AI agent for your tools, chats, and workflows. · GitHub]已经更新到0.2.0,能力提升并更稳定,Claude-code-best[GitHub - claude-code-best/claude-code: 原汁原昧 Claude Code 可运行,可构建, 可调试版; 生产级工程化, 企业级可靠性; 安全无毒, 内存泄露修复 · GitHub]更新至2.6.6,一个多月的使用没有出现问题。现将Nanobot与CCB的mcp配置做一介绍。
一、配置nanobot
1.修改nanobot的配置文件
我的系统是Windows11,nanobot的默认配置文件放在 c:\users\<用户名>\.nanobot\config.json,
在“tools"中加入以下内容:
"mcpServers": {
"claude": {
"type": "stdio",
"command": "bun",
"args": [
"d:/opc_woxili/claude-code/dist/cli.js",
"mcp",
"serve"
],
"env": {},
"cwd": "d:/opc_woxili/claude-code",
"url": "",
"headers": {},
"toolTimeout": 30,
"enabledTools": [
"*"
]
}
},
在nanobot的文档中配置mpc服务没有更详细的说明,这些配置项目最基础的是"command"和”args"两个参数,command指定为bun,cli.js的path应替换为CCB代码目录。后续的"cwd”参数是我对CCB做了修改,加入了一个“--cwd"命令行参数,在使用bun run scripts\dev.ts时,可以指定工作目录。读者可忽略此参数。
2.启动nanobot gateway
nanobot会自行加载claude mcp,如果配置无误,应不会出现错误提示,若claude mcp配置有误,会出现claude mcp加载失败提示。
二、CCB在windows环境的微调
bun安装在windows中后,运行where bun,会有bun、bun.cmd、bun.exe三个输出项,在我的path环境变量设置中,nodejs环境中的bun、bun.cmd在bun.exe之前,所以在cmd.exe的命令行窗口中运行CCB中的 bun run dev会出现问题,我修改了CCB中package.json文件内容,将”Scripts"节中的 “bun"替换成了"bun.exe",以确保bun应用程序引用正确。
"scripts": {
"build": "bun.exe run build.ts",
"build:vite": "vite build && bun.exe run scripts/post-build.ts",
"build:vite:only": "vite build",
"build:bun": "bun.exe run build.ts",
"dev": "bun.exe run scripts/dev.ts",
"dev:inspect": "bun.exe run scripts/dev-debug.ts",
"prepublishOnly": "bun.exe run build:vite",
"lint": "biome lint .",
"lint:fix": "biome lint --fix .",
"format": "biome format --write .",
"check": "biome check .",
"check:fix": "biome check --fix .",
"prepare": "husky",
"test": "bun test",
"test:production": "bun.exe run scripts/production-test.ts",
"test:production:offline": "bun.exe run scripts/production-test.ts --offline",
"test:production:verbose": "bun.exe run scripts/production-test.ts --verbose",
"test:production:bun": "bun.exe run scripts/production-test.ts --bun",
"check:bundle": "bun.exe run scripts/check-bundle-integrity.ts",
"check:unused": "knip-bun",
"health": "bun.exe run scripts/health-check.ts",
"postinstall": "node scripts/run-parallel.mjs scripts/postinstall.cjs scripts/setup-chrome-mcp.mjs",
"docs:dev": "npx mintlify dev",
"typecheck": "tsc --noEmit",
"precheck": "bun.exe run typecheck && bun.exe run check:fix && bun test",
"rcs": "bun.exe run scripts/rcs.ts"
},
三、Nanobot的web ui
1.webui需要初始化
进入naobot项目的webui目录,先运行以下命令:
bun install
bun run dev
控制台显示:
Local: http://127.0.0.1:5173/
2.webui需要访问Nanobot gateway
打开一个新的cmd.exe控制台窗口,在Nanobot项目根目录执行命令:
nanobot gateway
3.在浏览器中打开http://127.0.0.1:5173/
四、Nanobot环境中的claude mcp使用验证:
在浏览器对话窗口中输入以下两句提示词验证:
1.当前 claude mcp 服务是否可用?
反馈:
是的,Claude MCP 服务当前是可用的。我们刚刚成功调用了 mcp_claude_ListPeers 工具,返回了一个本地对等节点(self),表明 MCP 服务正在运行且可响应。如果您需要执行其他 MCP 相关操作(如调用工具、检查技能等),它们也应该能够正常工作。
2.使用 claude mcp 合建一个rust项目,在console中显示字符串 ”hello rust !"
nanobot会调用claude mcp 在nanobot的workspace中建立一个hello_rust_project目录,生成代码,并调用cargo编译生成exe文件。
五、Nanobot配置文件的更新
Nanobot项目保持着持续的更新,配置文件应根据其更新进度进行更新,我的方法是使用以下命令:
nanobot onboard --wizard
在不修改内容的情况下选择 ”Save and Exit",程序退出时,会花一点时间自动更新config.json文件。
上述是我自己的配置经验,尤其是对CCB做了修改,claude mcp的配置可能与读者现有项目不一致,如存在问题,请方家指正。
最后,使用 以下命令安装的CCB:
npm i -g claude-code-best
运行中要切换plan模型,使用的是 meta+t 键盘组合,我的系统无法支持,我也不想重新绑定键盘指令,所以选择使用CCB的git源代码,如有能解决此问题的朋友,可以留言指教。
更多推荐


所有评论(0)