使用说明
nxs
一个管道友好的CLI,通过MCP服务器传递将对话发送到Anthropic消息API。
nxs有两种工作模式:用于多回合对话的交互式聊天TUI,以及用于脚本编写和自动化的从stdin读取的管道模式。MCP服务器直接传递给API-不需要本地MCP客户端。
需求
- 转到1.21+
- 一 无烟煤API键
安装
go install github.com/ironystock/nxs/cmd/nxs@latest
或者从源代码构建:
git clone https://github.com/ironystock/nxs.git
cd nxs
go build -o bin/nxs cmd/nxs/main.go
设置
将API密钥设置为环境变量:
export ANTHROPIC_API_KEY="sk-ant-..."
用法
交互式聊天
nxs
启动聊天TUI。键入信息并按 进入 发送。 Shift+Enter 对于新生儿。 Ctrl+C 或 退出键 退出。
管道模式
echo "explain this error" | nxs
读取stdin,将其发送到API,并将响应打印到stdout。
将stdin与查询组合:
cat main.go | nxs "find bugs in this code"
git diff | nxs "write a commit message for this diff"
输出原始JSON而不是文本:
echo "hello" | nxs --json
旗帜
| 标志 | 描述 |
|---|---|
--model |
覆盖模型(默认值: claude-sonnet-4-5-20250514) |
--json |
将API完整响应打印为JSON(仅限管道模式) |
--profile |
配置文件(尚未实现) |
MCP在nxs中的工作原理
nxs使用 mcp_servers 现场。API连接到MCP服务器并在服务器端执行工具。当API使用工具使用块进行响应时,nxs会自动处理多回转循环,直到最终响应就绪。
许可证
麻省理工学院
