MCP Shell Server
MCP Shell 服务器
用于执行实现模型上下文协议 (MCP) 的 shell 命令的安全服务器。该服务器允许远程执行授权的 shell 命令,并支持通过 stdin 输入。
特征
安全命令执行:只有授权的命令才能执行
标准输入支持:通过 stdin 将输入传递给命令
综合输出:返回 stdout、stderr、退出代码和执行时间
使用 Shell 运算符的安全性:验证 Shell 运算符(;、&&、||、|)后的命令
超时控制:设置命令的最大执行时间
Related MCP server: Shell MCP Server
在 Claude.app 中配置 MCP 客户端
已发布版本
code ~/Library/Application\ Support/Claude/claude_desktop_config.json{
"mcpServers": {
"shell": {
"command": "uvx",
"args": [
"mcp-shell-server"
],
"env": {
"ALLOW_COMMANDS": "ls,cat,pwd,grep,wc,touch,find"
}
},
}
}本地版本
设置
code ~/Library/Application\ Support/Claude/claude_desktop_config.json{
"mcpServers": {
"shell": {
"command": "uv",
"args": [
"--directory",
".",
"run",
"mcp-shell-server"
],
"env": {
"ALLOW_COMMANDS": "ls,cat,pwd,grep,wc,touch,find"
}
},
}
}安装
pip install mcp-shell-server使用
启动服务器
ALLOW_COMMANDS="ls,cat,echo" uvx mcp-shell-server
# Ou usando o alias
ALLOWED_COMMANDS="ls,cat,echo" uvx mcp-shell-serverALLOW_COMMANDS环境变量(或其别名ALLOWED_COMMANDS )指定可以执行哪些命令。命令可以用逗号分隔,周围可以有空格。
ALLOW_COMMANDS 或 ALLOWED_COMMANDS 的有效格式:
ALLOW_COMMANDS="ls,cat,echo" # Formato básico
ALLOWED_COMMANDS="ls ,echo, cat" # Com espaços (usando alias)
ALLOW_COMMANDS="ls, cat , echo" # Múltiplos espaços请求格式
# Execução básica de comando
{
"command": ["ls", "-l", "/tmp"]
}
# Comando com entrada stdin
{
"command": ["cat"],
"stdin": "Hello, World!"
}
# Comando com timeout
{
"command": ["long-running-process"],
"timeout": 30 # Tempo máximo de execução em segundos
}
# Comando com diretório de trabalho e timeout
{
"command": ["grep", "-r", "pattern"],
"directory": "/path/to/search",
"timeout": 60
}响应格式
成功响应:
{
"stdout": "saída do comando",
"stderr": "",
"status": 0,
"execution_time": 0.123
}错误响应:
{
"error": "Comando não permitido: rm",
"status": 1,
"stdout": "",
"stderr": "Comando não permitido: rm",
"execution_time": 0
}安全
该服务器实施了多项安全措施:
命令白名单:只有明确允许的命令才能执行
Shell 运算符验证:shell 运算符(;、&&、||、|)后的命令也会根据白名单进行验证
无 Shell 注入:命令直接执行,无需 Shell 解释
发展
设置开发环境
克隆存储库
git clone https://github.com/yourusername/mcp-shell-server.git
cd mcp-shell-server安装依赖项,包括测试要求
pip install -e ".[test]"运行测试
pytestAPI 参考
请求参数
场地 | 类型 | 强制的 | 描述 |
命令 | 细绳[] | 是的 | 命令及其参数作为数组元素 |
标准输入 | 细绳 | 不 | 传递给命令的输入 |
目录 | 细绳 | 不 | 执行命令的工作目录 |
暂停 | 所有的 | 不 | 最大执行时间(秒) |
响应字段
场地 | 类型 | 描述 |
标准输出 | 细绳 | 命令的标准输出 |
标准错误 | 细绳 | 命令错误输出 |
地位 | 所有的 | 退出状态代码 |
执行时间 | 漂浮 | 执行所需的时间(以秒为单位) |
错误 | 细绳 | 错误消息(仅在失败时显示) |
要求
Python 3.11 或更高版本
mcp>=1.1.0
执照
MIT 许可证 - 详情请参阅许可证文件
Available Tools
1 toolshell_executeC
Execute um comando shell Comandos permitidos:
Inputs: command (required), directory (required), stdin, timeout.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
With only one tool, there is no possibility for confusion or overlap between tools. The tool 'shell_execute' has a single, clearly defined purpose of executing shell commands, so disambiguation is perfect.
Since there is only one tool, naming consistency is inherently perfect. The tool name 'shell_execute' follows a clear verb_noun pattern, but with no other tools to compare, it sets no pattern to deviate from.
A single tool is too few for a server named 'MCP Shell Server', which implies broader shell-related functionality. While the tool covers basic command execution, the scope feels thin, lacking tools for tasks like listing files, checking processes, or managing environment variables that are typical in shell operations.
The tool set is severely incomplete for a shell server. It only provides execution, missing essential operations like file manipulation (e.g., read, write, delete), directory navigation, process management, or system information retrieval. This will likely cause agent failures when trying to perform common shell tasks beyond simple command execution.
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Related MCP Servers
- AlicenseAqualityAmaintenanceA secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.1202MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.7MIT
- AlicenseBqualityDmaintenanceA secure terminal execution server that enables controlled command execution with security features and resource limits via the Model Context Protocol (MCP).14 npm11MIT
- AlicenseBqualityFmaintenanceA server that uses the Model Context Protocol (MCP) to allow AI agents to safely execute shell commands on a host system.180 npm9MIT