CLI工具桥接服务

zero-config-cli-bridge是一个无需配置的MCP服务器,允许LLM代理直接使用本地已认证的CLI工具,无需API密钥或OAuth流程。

  • by hatyibei
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 hatyibei/zero-config-cli-bridge

使用说明

零配置cli桥

零设置。API密钥为零。只需您的本地CLI。

仍然复制粘贴 GITHUB_TOKEN 进入 .env 文件夹? 还在想为什么你的人工智能代理看不到你的私人仓库? 停下。你的机器已经有了它需要的一切。

zero-config-cli-bridge 是一个MCP(模型上下文协议)服务器,它公开了您的 已通过身份验证的本地CLI工具 直接到LLM代理-没有API密钥,没有OAuth流,没有配置。

如果 gh issue list 它可以在您的终端中工作,也可以在Claude Desktop中工作。就这样


安装

# Option A: npx (no install required)
npx -y zero-config-cli-bridge

# Option B: global install
npm install -g zero-config-cli-bridge

先决条件: gh CLI已安装并经过身份验证(gh auth login)


Claude桌面设置

添加 ~/AppData/Roaming/Claude/claude_desktop_config.json (Windows)或 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
  "mcpServers": {
    "zero-config-cli-bridge": {
      "command": "npx",
      "args": ["-y", "zero-config-cli-bridge"]
    }
  }
}

重新启动克劳德桌面。完成。


你能做什么

自然地问克劳德:

  • “列出cli/cli中的未决问题”
  • “显示合并到main中的最后20个PR”
  • “哪些问题被标记为bug和未分配?”

Claude将调用MCP工具,点击您的本地 gh 使用您现有的身份验证进行二进制转换,并返回真实数据——而无需看到您的令牌。


可用工具

工具 命令 描述
gh_issue_list gh issue list 列出过滤器的问题
gh_pr_list gh pr list 使用筛选器列出拉取请求

参数

gh_issue_list

参数 类型 描述
repo 字符串 OWNER/REPO 格式。省略使用当前目录的远程。
limit number 最大结果(默认值:30)
state 字符串 open / closed / all
label string 按标签筛选
assignee string 按受让人登录名筛选

gh_pr_list

参数 类型 描述
repo 字符串 OWNER/REPO 格式
limit number 最大结果(默认值:30)
state 字符串 open / closed / merged
base string 按基分支筛选
assignee string 按受让人登录名筛选

安全:分层防御

此服务器是 设计为只读破坏性操作在多个层面受到阻碍:

Request
  │
  ▼
┌─────────────────────────────────────────────┐
│ Layer 1: LLM Self-Governance                │
│ The tool schema explicitly describes        │
│ read-only intent. Claude refuses mutating   │
│ requests before calling the tool at all.    │
└─────────────────┬───────────────────────────┘
                  │ (if bypassed)
                  ▼
┌─────────────────────────────────────────────┐
│ Layer 2: Keyword Validator (security.ts)    │
│ Blocks: create, delete, edit, rm,           │
│ update, close, reopen, merge                │
│ Returns: "Mutating commands are blocked"    │
└─────────────────┬───────────────────────────┘
                  │ (if bypassed)
                  ▼
┌─────────────────────────────────────────────┐
│ Layer 3: gh CLI Error                       │
│ Invalid commands fail at the gh binary      │
│ level with a non-zero exit code.            │
└─────────────────────────────────────────────┘

生产验证: 克劳德桌面上的测试3确认第1层阻止了 delete 甚至在工具被调用之前就进行了注入尝试。

附加保障措施

  • 超时: 进程被终止 SIGKILL 3000ms后——无挂起交互提示
  • 输出截断: stdout/stderr限制为2000个字符,以防止上下文耗尽。长输出附加 ...[Output truncated. Use grep/jq to filter]
  • CI模式: CI=true 被注入以抑制交互式提示

运作原理

Claude Desktop
     │  MCP (stdio JSON-RPC)
     ▼
zero-config-cli-bridge
     │  child_process.spawn
     ▼
gh CLI (your local binary)
     │  uses ~/.config/gh/hosts.yml
     ▼
GitHub API

你的代币永远不会离开你的机器。这座桥只是将克劳德连接到一个已经授权的流程。


路线图

  • [ ] gh issue view / gh pr view
  • [ ] gh run list / gh release list
  • []从生成动态模式 gh --help
  • []支持 git, docker, kubectl
  • []可配置的允许列表,用于附加只读命令

PR欢迎。


许可证

麻省理工学院