MCP Connector

Securely Execute OS Commands via LLM

Turn any shell command into a constraint-validated MCP tool via YAML config - a safe bridge between LLMs and CLI tools.

Works with githubkubectlaws cli

91
Spark score
out of 100
Updated 27 days ago
Version 0.2.0
Models
universal

Add to Favorites

Why it matters

Enable Large Language Models to safely execute command-line operations on your operating system. This asset acts as a secure bridge, allowing LLMs to interact with your system's commands through a configurable and constraint-based interface.

Outcomes

What it gets done

01

Define and manage executable tools for LLMs using YAML configurations.

02

Implement security constraints with CEL expressions to validate parameters and prevent injection.

03

Integrate with LLM clients like Cursor and VSCode for seamless interaction.

04

Support for containerized and Kubernetes deployments.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-mcpshell | bash

Capabilities

Tools your agent gets

disk_usage

Check disk usage for a directory with customizable depth analysis

Overview

MCPShell MCP Server

MCPShell lets LLMs safely execute shell commands as MCP tools defined in YAML, with CEL-expression parameter constraints and optional sandboxed execution. It works with any MCP-compatible client like Cursor or VS Code. Use it to quickly prototype safe, read-only MCP tools around existing CLI utilities. Avoid exposing tools that can modify or delete state without strict constraints and sandboxing.

What it does

MCPShell lets LLMs safely execute command-line tools through the Model Context Protocol by defining shell commands as MCP tools in a YAML configuration file. Each tool declares parameters, CEL-expression constraints that validate inputs before execution, a shell command template with parameter substitution, and output formatting - turning arbitrary CLI utilities (disk usage, kubectl, AWS CLI, etc.) into safe, callable LLM tools.

When to use - and when NOT to

Use it when you want to quickly prototype an MCP tool around an existing shell command or CLI utility - for example, letting an LLM analyze disk usage, inspect a Kubernetes cluster read-only, or query AWS networking - without writing a full MCP server from scratch. It works with any MCP client (Cursor, VS Code, Witsy, etc.). Do not expose tools that can modify or delete state (e.g., a file-removal tool) without strict safeguards - the project explicitly warns against this. Limit exposed tools to read-only actions, rely on CEL constraints to restrict parameters, and consider a sandboxed runner for command execution; review every command template for injection vulnerabilities before exposing it externally.

Capabilities

  • Flexible command execution: run any shell command as an MCP tool with template-based parameter substitution.
  • Configuration-based tool definitions: define tools, parameters, constraints, and output formatting in YAML.
  • Security through constraints: validate parameters with CEL expressions before execution (e.g., requiring an absolute path, blocking .. traversal, restricting to safe path characters, bounding numeric ranges) and optionally run commands in a sandboxed environment.
  • Quick prototyping: turn a snippet of shell code into a usable MCP tool with minimal setup.
  • Broad client compatibility: works with any MCP-compatible client, including Cursor, VS Code, and Witsy.

Example tool definition (disk_usage): takes a directory and optional max_depth (1-3), validated by constraints against path traversal and command injection, and runs du -h --max-depth={{ .max_depth }} {{ .directory }} | sort -hr | head -20.

How to install

Requires the go command. Define your tools in a YAML file (e.g. /my/example.yaml), then configure your MCP client - for Cursor, in .cursor/mcp.json:

{
  "mcpServers": {
    "mcp-cli-examples": {
      "command": "go",
      "args": ["run", "github.com/inercia/MCPShell@v0.1.8", "mcp", "--tools", "/my/example.yaml", "--logfile", "/some/path/mcpshell/example.log"]
    }
  }
}

Relative tool names are looked up under ~/.mcpshell/tools/ by default. Refresh the MCP client after any config change. Container and Kubernetes deployment is also documented. For a fuller agent runtime built on the same tool configuration format (direct LLM connectivity, RAG, multi-agent support), see the companion Don project.

Who it's for

Developers who want to quickly wrap existing shell commands and CLI tools (disk analysis, kubectl, AWS CLI) as safe, constraint-validated MCP tools without building a full custom MCP server.

Source README

MCPShell

banner

The MCPShell is a tool that allows LLMs to safely execute command-line tools
through the Model Context Protocol (MCP).
It provides a secure bridge between LLMs and operating system commands.

Features

  • Flexible command execution: Run any shell commands as MCP tools,
    with parameter substitution through templates.
  • Configuration-based tool definitions: Define tools in YAML with parameters,
    constraints, and output formatting.
  • Security through constraints: Validate tool parameters using CEL expressions
    before execution, as well as optional sanboxed environments
    for running commands.
  • Quick proptotyping of MCP tools: just add some shell code and use it as
    a MCP tool in your LLM.
  • Simple integration: Works with any LLM client supporting the MCP protocol
    (ie, Cursor, VSCode, Witsy...)

Quick Start

Imagine you want Cursor (or some other MCP client) help you with your
space problems in your hard disk.

  1. Create a configuration file /my/example.yaml defining your tools:

    mcp:
      description: |
        Tool for analyzing disk usage to help identify what's consuming space.
      run:
        shell: bash
      tools:
        - name: "disk_usage"
          description: "Check disk usage for a directory"
          params:
            directory:
              type: string
              description: "Directory to analyze"
              required: true
            max_depth:
              type: number
              description: "Maximum depth to analyze (1-3)"
              default: 2
          constraints:
            - "directory.startsWith('/')"  # Must be absolute path
            - "!directory.contains('..')"  # Prevent directory traversal
            - "max_depth >= 1 && max_depth <= 3"  # Limit recursion depth
            - "directory.matches('^[\\w\\s./\\-_]+$')"  # Only allow safe path characters, prevent command injection
          run:
            command: |
              du -h --max-depth={{ .max_depth }} {{ .directory }} | sort -hr | head -20
          output:
            prefix: |
              Disk Usage Analysis (Top 20 largest directories):
    

    Take a look at the examples directory for more sophisticated and useful examples.
    Maybe you prefer to let the LLM know about your Kubernetes cluster with
    kubectl?
    Or let it run some AWS CLI commands?

  2. Configure the MCP server in Cursor (or in any other LLM client with support for MCP)

    For example, for Cursor, create .cursor/mcp.json:

    {
        // you need the "go" command available
        "mcpServers": {
            "mcp-cli-examples": {
                "command": "go",
                "args": [
                   "run", "github.com/inercia/MCPShell@v0.1.8",
                   "mcp", "--tools", "/my/example.yaml",
                   "--logfile", "/some/path/mcpshell/example.log"
                ]
            }
        }
    }
    

    You can also use relative paths and omit the .yaml extension:

    {
        "mcpServers": {
            "mcp-cli-examples": {
                "command": "go",
                "args": [
                   "run", "github.com/inercia/MCPShell@v0.1.8",
                   "mcp", "--tools", "example",
                   "--logfile", "/some/path/mcpshell/example.log"
                ]
            }
        }
    }
    

    This will look for example.yaml in the tools directory (~/.mcpshell/tools/ by default).

    See more details on how to configure Cursor or
    Visual Studio Code. Other LLMs with support for MCPs
    should be configured in a similar way.

  3. Make sure your MCP client is refreshed (Cursor should recognize it automatically the
    firt time, but any change in the config file will require a refresh).

  4. Ask your LLM some questions it should be able to answer with the new tool. For example:
    "I'm running out of space in my hard disk. Could you help me finding the problem?".

Usage and Configuration

Take a look at all the command in this document.

Configuration files use a YAML format defined here.
See the this directory for some examples.

For deploying MCPShell in containers and Kubernetes, see the Container Deployment Guide.

Agent Mode

For AI agent functionality that connects LLMs directly to tools, see the
Don project. Don provides:

  • Direct LLM connectivity without requiring a separate MCP client
  • RAG (Retrieval-Augmented Generation) support
  • Multi-agent architecture
  • Uses MCPShell's tool configuration format

Security Considerations

So you will probably thing
"this AI has helped me finding all those big files. What if I create another tool for removing files?".
Don't do that!.

  • Limit the scope of these tools to read-only actions, do not give the LLM the power to change things.
  • Use constraints to limit command execution to safe parameters
  • Consider using a sanboxed environment for running commands.
  • Review all command templates for potential injection vulnerabilities
  • Only expose tools that are safe for external use
  • All of the above!

Please read the Security Considerations document before using this software.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.