SM

sonirico/mcp-shell

部署与 DevOps

本页由 AI 翻译,技术细节请以原文为准。 查看原文

114 stars 20 forks 质量 83 趋势 8GPL-3.0

sonirico/mcp-shell 是一个从 https://github.com/sonirico/mcp-shell. 导入的 MCP 服务器候选。

概览

sonirico/mcp-shell 是一个从 https://github.com/sonirico/mcp-shell. 导入的 MCP 服务器候选。

概述(AI 翻译)

运行shell命令的MCP服务器。你的LLM会有一个工具;你可以控制运行什么以及如何运行。

基于 mark3labs/mcp-go 构建。用 Go 编写。


跑它

Docker(最简单):

来源:


配置它

安全模式是默认状态。 没有配置文件时,mcp-shell 以安全模式启动 模式和寄存器仅输入工具:文件读取、grep/glob、git检查, 以及(选择加入)文件/git写入和操作符定义脚本。没有原始代码 shell 命令。你只需要一个配置文件来更改下面的默认值。去 完全无限制运行时,你必须明确选择加入:

要自定义策略,请指向一个YAML配置:

安全模式(默认)——仅限类型工具,所有路径限制在working_directory:


接线

Claude Desktop — 添加到你的 MCP 配置中:

自定义配置时,挂载文件并设置环境:


工具

安全模式(默认模式)会注册这些类型化工具。* 标记为 参数。

工具 参数 可用
read_file 路径*,偏移,极限,尾 始终
list_dir 路径,深度,include_hidden 总是
glob 模式*,路径,newer_than,max_results 总是

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

mcp-shell

MCP server that runs shell commands. Your LLM gets a tool; you get control over what runs and how.

Built on mark3labs/mcp-go. Written in Go.


Run it

Docker (easiest):

docker run -it --rm -v /tmp/mcp-workspace:/tmp/mcp-workspace sonirico/mcp-shell:latest

From source:

git clone https://github.com/sonirico/mcp-shell && cd mcp-shell
make install
mcp-shell

Configure it

Secure mode is the default. With no config file, mcp-shell boots in secure mode and registers only typed tools: file reads, grep/glob, git inspection, and (opt-in) file/git writes and operator-defined scripts. There is no raw shell command. You only need a config file to change the defaults below. To run fully unrestricted you must opt in explicitly:

MCP_SHELL_ALLOW_UNSAFE=1 mcp-shell   # disables secure mode; the only tool is shell_exec

To customize the policy, point to a YAML config:

export MCP_SHELL_SEC_CONFIG_FILE=/path/to/security.yaml
mcp-shell

Secure mode (default) — typed tools only, every path confined to working_directory:

security:
  enabled: true
  working_directory: /tmp/mcp-workspace
  max_execution_time: 30s
  max_output_size: 1048576
  run_as_user: ""
  audit_log: true

  # Expose file and git write tools (write_file, edit_file, mkdir, move,
  # delete, git_add, git_commit, git_switch, git_restore, git_stash). Off by
  # default.
  writes_enabled: false

  # Operator-defined scripts exposed through the run_script tool. The client
  # picks a name; the argv is yours and cannot be altered.
  # scripts:
  #   test: ["go", "test", "./..."]
  #   lint: ["golangci-lint", "run"]

Wire it up

Claude Desktop — add to your MCP config:

{
  "mcpServers": {
    "shell": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "sonirico/mcp-shell:latest"],
      "env": { "MCP_SHELL_LOG_LEVEL": "info" }
    }
  }
}

For custom config, mount the file and set the env:

{
  "command": "docker",
  "args": ["run", "--rm", "-i", "-v", "/path/to/security.yaml:/etc/mcp-shell/security.yaml", "-e", "MCP_SHELL_SEC_CONFIG_FILE=/etc/mcp-shell/security.yaml", "sonirico/mcp-shell:latest"]
}

Tools

Secure mode (the default) registers these typed tools. * marks a required parameter.

Tool Parameters Available
read_file path*, offset, limit, tail always
list_dir path, depth, include_hidden always
glob pattern*, path, newer_than, max_results always
grep pattern*, path, glob, ignore_case, context, files_only, count, max_results always
在 GitHub 查看完整 README

安装

docker run --rm -i sonirico/mcp-shell:latest
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "shell": { "command": "docker", "args": ["run", "--rm", "-i", "sonirico/mcp-shell:latest"], "env": { "MCP_SHELL_LOG_LEVEL": "info" } } } }