MCP Shell 服务器
使用模型上下文协议 (MCP) 执行 Shell 命令的服务器。它充当桥梁,使 AI 代理能够安全地执行 Shell 命令。
特征
- 执行shell命令(单行和多行支持)
- 支持各种shell(bash、zsh、fish、powershell、cmd等)
- 详细的错误处理和日志记录
- 兼容 MCP Inspector
安装
从 npm(作为用户)
从源头(用于开发)
MCP 配置
游标配置
将以下内容添加到您的 Cursor 配置文件( ~/.cursor/config.json
):
克莱恩积分
Cline是一个 VS Code 扩展,允许您将 MCP 服务器与 Claude AI 结合使用。要使用 Cline 设置此 MCP shell 服务器,请执行以下操作:
- 打开您的 Cline MCP 设置文件:
- macOS:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
- Windows:
%APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
- Linux:
~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
- macOS:
- 添加shell服务器MCP配置:或者,如果您想使用本地安装的包:
规则配置
将以下内容添加到您的 AI 助手的规则或提示中:
用法
直接执行
开发模式
使用 MCP Inspector 进行测试
命令行参数
工具参考
shell_exec
在指定的 shell 中执行命令。
参数:
command
(字符串,必需):要执行的 shell 命令workingDir
(字符串,可选):执行命令的工作目录。必须在 $HOME 下。
资源参考
服务器提供以下系统信息作为资源:
主机名
返回系统的主机名。
URI: hostname://
平台
返回操作系统平台。
URI: platform://
壳
返回服务器正在使用的 shell 路径。
URI: shell://
用户名
返回当前用户名。
URI: username://
系统信息
以 JSON 格式返回全面的系统信息,包括:
- 主机名
- 平台
- 壳
- 用户名
- CPU 数量
- 总内存
- 释放内存
- 系统正常运行时间
使用示例
基本命令执行
多行命令(Heredoc)执行
发展
项目结构
日志记录
日志写入mcp-shell.log
文件。
执照
麻省理工学院
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
使用模型上下文协议 (MCP) 的服务器允许 AI 代理在主机系统上安全地执行 shell 命令。
Related MCP Servers
- AsecurityAlicenseAqualityA 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.Last updated -174PythonMIT License
- -securityAlicense-qualityA Model Context Protocol (MCP) server that allows AI models to safely access and interact with local file systems, enabling reading file contents, listing directories, and retrieving file metadata.Last updated -471JavaScriptMIT 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
- AsecurityAlicenseAqualityA server that enables AI assistants to execute terminal commands and retrieve outputs via the Model Context Protocol (MCP).Last updated -36PythonMIT License