MCP Shell Server 是一个借助 Model Context Protocol (MCP) 来执行 shell 命令的服务器。它搭建起一座桥梁,让 AI 代理能够安全地执行 shell 命令,为相关操作提供有力支持。
# 使用 npm
npm install -g @mkusaka/mcp-shell-server
# 使用 yarn
yarn global add @mkusaka/mcp-shell-server
# 使用 pnpm
pnpm add -g @mkusaka/mcp-shell-server
# 克隆仓库
git clone https://github.com/mkusaka/mcp-shell-server.git
cd mcp-shell-server
# 安装依赖项
pnpm install
# 构建项目
pnpm build
将以下内容添加到你的游标配置文件(~/.cursor/config.json)中:
{
"mcpServers": {
"shell": {
"command": "npx",
"args": ["-y", "@mkusaka/mcp-shell-server"]
}
}
}
将以下内容添加到 ~/.config/cursor/cursor.json:
{
"shell": {
"serverUrl": "http://localhost:13000"
}
}
npx mcp-shell-server
访问以下接口获取系统信息:
http://localhost:13000/system-infohttp://localhost:13000/shell(返回当前使用的 shell 路径){
"name": "shell_exec",
"parameters": {
"command": "echo Hello, World!"
}
}
{
"name": "shell_exec",
"parameters": {
"command": "cat << EOF | grep 'example'\nThis is an example text.\nAnother line without the keyword.\nEOF"
}
}
npx mcp-shell-server --port=13000 --config=config.json
参数说明:
--port:指定服务器监听的端口,默认为 13000。--config:指定配置文件路径。src/
├── index.ts # 主入口文件
└── shell-server/
├── index.ts # Shell 服务器实现
└── lib/
└── logger.ts # 日志配置
日志输出到 mcp-shell.log 文件中。
本项目采用 MIT 许可证。