Token导航 LogoToken导航TokenDH.com
Fast Bash MCP logo
开发工具未说明官方级别未说明来源级核验

Fast Bash MCP

MCP Server

一个高性能的MCP服务器,为Claude Code提供快速的Bash命令执行功能,绕过基于haiku的预检检查,减少30秒以上的延迟。

工具数

3

提示词数

0

GitHub Stars

1

资源数

0
TypeScriptClaude高性能Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

NikkeTryHard

提供方

NikkeTryHard

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

克劳德代码的快速Bash MCP服务器

一个高性能的MCP服务器,为Claude Code提供快速的bash命令执行,绕过了导致30秒以上延迟的基于俳句的慢速飞行前检查。

问题

Claude Code内置的Bash工具 每个命令有两个LLM API调用:

  1. bash_extract_prefix -执行前的飞行前检查
  2. bash_extract_command_paths -执行后文件路径提取

这些调用经过配置的俳句模型,可以添加 30+秒的延迟 每个bash命令,即使是简单的操作,如 git statusls.

调查结果

因素影响状态
Shell配置文件启动95ms不是问题
代理延迟1-2s不是问题
Bubblewrap沙盒最小不是问题
命令注入检查最小不是问题
Haiku LLM来电30+秒根本原因

GitHub相关问题

  • #10181 -壳体轮廓干扰
  • #3505 -2分钟超时问题
  • #19585 -Shell快照创建超时
  • #4049 -飞行前Haiku模型访问被拒绝
  • #19247 -基本工具调用挂起

解决方案

此MCP服务器提供无需LLM飞行前检查的直接bash执行,为您提供Claude Code的速度 ! 前缀,但代理可以通过编程访问。

特性

工具说明
fast_bash具有所有选项的单一命令执行
fast_bash_parallel使用摘要同时运行多个命令
fast_bash_sequence在单个shell会话中按顺序运行命令

fast_bash参数

参数类型默认值说明
commandstring必需要执行的bash命令
cwdstring项目目录工作目录
timeoutnumber420000超时(毫秒)(最大600000)
descriptionstring-日志记录的简短描述
shellstringbash外壳:bash、zsh或sh
envobject-其他环境变量
stdinstring-输入管道到命令
max_outputnumber30000截断限制(字符)
output_filestring-将完整的stdout保存到文件
stderr_filestring-将完整的stderr保存到文件
login_shellbooleantrue以登录shell(-l标志)运行到源配置文件

fast_bash_paralle参数

参数类型默认值说明
commandsarrayrequired命令对象数组(请参阅fast_bash)
default_cwdstring项目目录所有命令的默认工作目录
default_timeoutnumber420000所有命令的默认超时时间(毫秒)
output_filestring-将组合输出保存到文件

fast_bash_sequence参数

参数类型默认值说明
commandsarrayrequired{command,description?}对象数组
stop_on_failurebooleantrue命令失败时停止执行
continue_on_codesnumber\[\]\[0\]退出代码被视为成功
cwdstring项目初始工作目录
timeoutnumber420000所有命令的总超时时间(毫秒)
shellstringbash外壳:bash、zsh或sh
envobject-其他环境变量
output_filestring-将完整输出保存到文件

v3.2功能

  • 7分钟默认超时:所有工具默认为420秒(7分钟),每次请求最多可覆盖10分钟
  • 安全强化 (可通过以下方式切换 FAST_BASH_HARDENED):

- 路径遍历和系统目录写保护 output_file/stderr_file - 环境变量注入过滤(LD_PRELOAD, DYLD_INSERT_LIBRARIES等等) - max_output 天花板(10MB)

  • OOM保护:stdout/stderr累积的内存上限为50MB(始终处于活动状态)
  • Sudo拒绝:命令包含 sudo 被一条询问人类的消息屏蔽
  • 默认登录shell:来源 .bashrc/.profile 因此,PATH和别名是可用的
  • 顺序执行: fast_bash_sequence 在单个shell会话中运行命令,其中 cdexport 在命令之间保持不变
  • 指数化产出:并行命令显示 [N] 前缀为故障摘要
  • 错误分类:退货 error_type (超时、已杀死、spawn_error、command_not_found、permission_desided、cwd_not_found)
  • CWD验证:工作目录不存在时清除错误消息
  • 优雅的超时:SIGTERM优先,5秒宽限期后SIGKILL
  • 输出文件重定向:在截断之前保存完整输出 output_file/stderr_file
  • 中间截断:保留大量产出的开始和结束

快速安装

使用Claude CLI(推荐)

# Clone the repo
git clone https://github.com/nikketryhard/fast-bash-mcp.git ~/.claude/mcp-servers/fast-bash

# Install dependencies
cd ~/.claude/mcp-servers/fast-bash && bun install

# Add MCP server using Claude CLI
claude mcp add --transport stdio -e FAST_BASH_DEFAULT_CWD='${PWD}' fast-bash -- bun run ~/.claude/mcp-servers/fast-bash/src/index.ts

# Restart Claude Code

作用域选项

# User scope (default) - available in all projects
claude mcp add fast-bash -- bun run ~/.claude/mcp-servers/fast-bash/src/index.ts

# Project scope - only in current project (.claude/settings.local.json)
claude mcp add --scope project fast-bash -- bun run ~/.claude/mcp-servers/fast-bash/src/index.ts

# Local scope - gitignored, only your machine (.claude/settings.local.json)
claude mcp add --scope local fast-bash -- bun run ~/.claude/mcp-servers/fast-bash/src/index.ts

手动安装

# Clone the repo
git clone https://github.com/nikketryhard/fast-bash-mcp.git ~/.claude/mcp-servers/fast-bash

# Install dependencies
cd ~/.claude/mcp-servers/fast-bash && bun install

# Restart Claude Code

然后添加到 ~/.claude.json:

{
  "mcpServers": {
    "fast-bash": {
      "command": "bun",
      "args": ["run", "/home/YOUR_USERNAME/.claude/mcp-servers/fast-bash/src/index.ts"],
      "env": {
        "FAST_BASH_DEFAULT_CWD": "${PWD}"
      }
    }
  }
}

配置

环境变量

变量默认值描述
FAST_BASH_DEFAULT_CWDprocess.cwd()默认工作目录
FAST_BASH_HARDENEDoff设置为 1 实现安全强化(见下文)

安全强化

默认情况下,强化模式为 。要启用它,请设置 FAST_BASH_HARDENED=1 在MCP配置中:

{
  "mcpServers": {
    "fast-bash": {
      "command": "bun",
      "args": ["run", "/path/to/fast-bash-mcp/src/index.ts"],
      "env": {
        "FAST_BASH_DEFAULT_CWD": "${PWD}",
        "FAST_BASH_HARDENED": "1"
      }
    }
  }
}

启用硬化模式时:

保护说明
路径净化output_file/stderr_file 无法使用 .. 或写信至 /etc/, /usr/, /bin/, /sbin/, /boot/, /dev/, /proc/, /sys/
Env-var滤波积木 LD_PRELOAD, LD_LIBRARY_PATH, DYLD_INSERT_LIBRARIES, DYLD_LIBRARY_PATHenv 参数
输出上限max_output 上限为10MB

始终处于活动状态 (无论硬化模式如何):

  • Sudo拒绝 --命令包含 sudo 被封锁
  • OOM保护 --stdout/stderr累积的内存上限为50MB
  • 超时上限 --每个命令最多10分钟(600000ms)

MCP服务器配置(~/.claude.json)

添加 mcpServers 到你的 ~/.claude.json:

{
  "mcpServers": {
    "fast-bash": {
      "command": "bun",
      "args": ["run", "/path/to/fast-bash-mcp/src/index.ts"],
      "env": {
        "FAST_BASH_DEFAULT_CWD": "${PWD}"
      }
    }
  }
}

禁用内置Bash(可选)

增添 ~/.claude/settings.json:

{
  "permissions": {
    "deny": ["Bash"]
  }
}

指导Claude使用Fast Bash

增添 ~/.claude/CLAUDE.md:

BASH COMMANDS 0. ALWAYS use fast-bash MCP tools instead of the built-in Bash tool.

1. Use mcp**fast-bash**fast_bash for single commands
2. Use mcp**fast-bash**fast_bash_parallel for multiple independent commands
3. Use mcp**fast-bash**fast_bash_sequence for sequential commands where cd/export persist
4. Commands run from project directory by default. Pass cwd parameter to override.

使用示例

单一命令

{
  "command": "git status",
  "description": "Check git status"
}

带输出文件的单个命令

{
  "command": "npm test",
  "output_file": "/tmp/test-output.txt",
  "stderr_file": "/tmp/test-errors.txt"
}

并行命令

{
  "commands": [
    { "command": "git status", "description": "Git status" },
    { "command": "npm test", "description": "Run tests" },
    { "command": "npm run build", "description": "Build project" }
  ],
  "default_cwd": "/path/to/project"
}

输出包括索引结果和摘要:

[1] === Git status ===
$ git status
...
[exit code: 0]
[52ms]

[2] === Run tests ===
...

=== Summary ===
Total: 1523ms | Succeeded: 2 | Failed: 1
Failed: [3]
Longest: [2] Run tests (1200ms)

顺序命令(有状态)

{
  "commands": [
    { "command": "cd /tmp", "description": "Change dir" },
    { "command": "export FOO=bar", "description": "Set env" },
    { "command": "echo $FOO && pwd", "description": "Verify" }
  ],
  "stop_on_failure": true,
  "continue_on_codes": [0]
}

与平行不同, cdexport 在命令之间持续。

运作原理

Claude Code的Bash工具

Command -> Haiku LLM (prefix extraction) -> Execute -> Haiku LLM (path extraction) -> Result
           ~15-30 seconds                              ~15-30 seconds

快速Bash MCP

Command -> Execute -> Result
           ~50ms

MCP服务器使用Node.js child_process.spawn 直接绕过所有基于LLM的检查。

工作目录行为

  • 命令从以下位置运行 项目目录 默认情况下(Claude Code启动的地方)
  • ${PWD} 在Claude Code启动时被捕获,并通过env var传递
  • 对于 fast_bashfast_bash_parallel: cd不坚持 通话之间
  • 对于 fast_bash_sequence: cd 持续 序列内(单个shell会话)
  • 使用 cd dir && command 或传递显式 cwd 参数

与内置Bash的比较

特性内置Bash快速Bash MCP
速度30+秒~50ms
飞行前LLM检查
飞行后LLM检查
沙盒是(气泡膜)
cwd持久性是(仅序列)
输出截断是(30k)是(可配置)
并行命令
顺序命令
错误分类
输出文件重定向
优雅超时是(SIGTERM+SIGKILL)
默认超时10分钟7分钟
OOM保护是(50MB上限)
安全强化基于沙盒可切换(环境变量)

需求

  • 包子 运行时
  • 克劳德代码2.0+

许可证

麻省理工学院

贡献

PR欢迎!请先打开一个问题来讨论更改。

目录标签

目录标签

TypeScriptClaude高性能Bash执行本地部署低延迟命令工具开发工具

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP