Purpose
MCPShell is used to establish a secure bridge between LLMs and operating system commands: it wraps shell commands as MCP tools so that LLM clients supporting the MCP protocol can call them. It is suitable for quickly prototyping MCP tools; you only need to write a small amount of shell code and configure it as a tool to use it.
Main capabilities
- Flexible command execution: any shell command can be run as an MCP tool, with parameter substitution via templates.
- Configuration-based tool definitions: define tools in YAML, including parameters, constraints, and output formats.
- Security through constraints: validate tool parameters with CEL expressions before execution, and optionally run commands in a sandbox environment.
- Rapid prototyping of MCP tools: add shell code and it can be used as an MCP tool by LLMs.
- Simple integration: works with any LLM client that supports the MCP protocol, such as Cursor, VSCode, Witsy.
Usage
- Create a YAML configuration file to define tools. The example defines a disk usage analysis tool with parameters directory and max_depth; the constraints require directory to be an absolute path, prohibit it from containing "..", limit max_depth to between 1 and 3, and restrict path characters to prevent command injection; run.command uses a du command template, and output.prefix sets the output prefix.
- Configure the MCP server in an MCP client. Taking Cursor as an example, create .cursor/mcp.json and use the go command to run github.com/inercia/MCPShell@v0.1.8, with arguments including mcp, --tools to specify the configuration file, and --logfile to specify the log path. You can also use a relative path and omit the .yaml extension; in that case the corresponding file is looked up in the tools directory (default ~/.mcpshell/tools/). Configuration for other LLM clients that support MCP is similar.
- Make sure the MCP client has refreshed its configuration, then ask the LLM a question to invoke the new tool.
Configuration uses the YAML format, and the repository provides an examples directory; for container and Kubernetes deployment, refer to the Container Deployment Guide. There is also the Don project, which provides direct LLM connectivity, RAG support, and a multi-agent architecture, and uses MCPShell's tool configuration format.
Use cases
It can be used to let LLMs analyze disk usage, learn about Kubernetes clusters via kubectl, run AWS CLI commands, and more; see the examples directory for more usages.
Limitations and security considerations
The project explicitly recommends not creating tools that can modify the system, such as deleting files, and instead limiting tools to read-only operations; using constraints to restrict command execution parameters; considering a sandbox environment; reviewing all command templates for injection vulnerabilities; and exposing only tools that are safe for external use. Read the security considerations documentation before use. The project is licensed under the MIT License.