MCP-ShellJS
MCP 服务器为 Claude 等 LLM 提供安全、可控的 ShellJS 访问。
概述
MCP-ShellJS 将模型上下文协议 (MCP) 与 ShellJS 连接起来,使 AI 系统能够在安全沙盒中执行 Shell 命令。它通过多层安全机制提供受控的文件系统访问。
特征
- 简化的安全性:
- 默认为只读模式
- 通过命令行标志可选的读写模式
- 通过命令行标志可选的执行权限
- 使用 Zod 进行基于模式的验证
- 完整的 ShellJS 功能(
ls
、grep
、sed
、find
等) - 强类型 TypeScript 实现
- 用于 LLM 集成的简单 API
安装
用法
命令行
TypeScript 集成
安全设计
MCP-ShellJS 实现了一个简单的安全模型:
- 只读模式(默认):只有不修改文件系统的命令可用
- 读写模式(
--enable-rw
):启用可以创建、修改或删除文件的命令 - 执行模式(
--enable-exec
):启用潜在危险的exec
命令来执行任意 shell 命令
该服务器仅使用 stdio 传输运行,使其适合与桌面 LLM 应用程序集成。
为什么使用 MCP-ShellJS?
对于 AI 开发人员来说,MCP-ShellJS 可以在控制风险的情况下实现强大的文件系统功能:
- 高效探索:使用
grep
快速搜索并跨代码库find
- 文本处理:使用
sed
转换文件而不完全加载它们 - 安全自动化:让人工智能帮助组织和管理文件
- 强大的管道:使用 Unix 风格管道进行链式操作
资源
目录资源
提供具有强大过滤功能的目录列表:
范围 | 描述 |
---|---|
include | 要包含的 Glob 模式(例如, *.js,*.ts ) |
exclude | 要排除的 Glob 模式(例如, node_modules,dist ) |
honor_gitignore | 当true 时,过滤掉与 .gitignore 中的模式匹配的文件 |
recursive | 当为true 时,递归包含子目录 |
例子:
文件资源
提供文件内容以及查看特定部分的选项:
范围 | 描述 |
---|---|
lines | 如果为true ,则在输出中包含行号 |
start | 要包含的第一行(从 1 开始的索引) |
end | 最后一行包括 |
highlight | 使用 Glob 模式突出显示匹配的文本 |
例子:
工具
MCP-ShellJS 将 ShellJS 命令公开为工具,并按安全风险级别分组:
只读工具
工具 | 描述 | 参数 |
---|---|---|
cat | 输出文件内容 | files :字符串/数组, options :带有-n 的对象(数字行) |
grep | 搜索文件中的模式 | regex 、 files 、 options :带有-v (反转)、 -l (仅文件名)、 -i (忽略大小写)的对象 |
find | 递归查找文件 | paths :字符串/数组(返回包括基本目录的文件路径) |
ls | 列出目录内容 | paths :字符串/数组, options :对象,带有-R (递归)、 -A (全部)、 -L (跟随符号链接)、 -d (仅限目录) |
which | 找到命令 | command :字符串(返回命令路径) |
pwd | 打印工作目录 | (无争论) |
test | 测试文件条件 | expression :字符串(例如, -d path 目录存在, -f path 文件存在) |
head | 显示第一行 | files :字符串/数组, options :带有-n <num> 对象(要显示的行数) |
tail | 显示最后几行 | files :字符串/数组, options :带有-n <num> 对象(要显示的行数) |
sort | 排序行 | files :字符串/数组, options :带有-r (反向)、 -n (数字)的对象 |
uniq | 过滤重复的行 | input :字符串, output :字符串, options :对象,带有-i (忽略大小写)、 -c (计数)、 -d (仅重复) |
读写工具
工具 | 描述 | 参数 |
---|---|---|
mkdir | 创建目录 | dir :字符串/数组, options :带有-p 的对象(创建中间目录) |
touch | 创建/更新文件 | files :字符串/数组, options :对象, -c (不创建)、 -a (仅访问时间)、 -m (仅修改时间) |
cp | 复制文件/目录 | source :字符串/数组, dest :字符串, options :对象,带有-R (递归)、 -n (无破坏)、 -f (强制) |
mv | 移动文件/目录 | source :字符串/数组, dest :字符串, options :带有-f (强制)、 -n (无破坏)的对象 |
rm | 删除文件/目录 | files :字符串/数组, options :带有-r/-R (递归)、 -f (强制)的对象 |
sed | 文件流编辑器 | search_regex :正则表达式, replacement :字符串, files :字符串/数组, options :带有-i 对象(就地) |
特殊许可工具
工具 | 描述 | 参数 |
---|---|---|
exec | 执行命令 | command :字符串, options :具有async 、 silent 对象,需要allowExec: true 配置 |
执照
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
安全的 MCP 服务器为 LLM 提供受控的 ShellJS 访问,使 AI 系统能够安全地执行 shell 命令并与可配置的安全沙箱中的文件系统交互。
Related MCP Servers
- AsecurityAlicenseAqualityA secure MCP server for executing whitelisted shell commands with resource and timeout controls, designed for integration with Claude and other MCP-compatible LLMs.Last updated -201432TypeScriptMIT License
- AsecurityAlicenseAqualityAn MCP server that enables secure terminal command execution, directory navigation, and file system operations through a standardized interface for LLMs.Last updated -1058PythonMIT License
- -securityAlicense-qualityA secure, container-based implementation of the Model Context Protocol (MCP) that provides sandboxed environments for AI systems to safely execute code, run commands, access files, and perform web operations.Last updated -9PythonApache 2.0
- -securityAlicense-qualityAn MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.Last updated -13JavaScriptMIT License