IM

inercia/mcpshell

开发工具

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

72 stars 16 forks 质量 73 趋势 22MIT

inercia/mcpshell 是一个从 https://github.com/inercia/mcpshell. 导入的 MCP 服务器候选

概览

inercia/mcpshell 是一个从 https://github.com/inercia/mcpshell. 导入的 MCP 服务器候选

概述(AI 翻译)

MCPShell 是一个允许大型语言模型安全执行命令行工具的工具 通过模型上下文协议(MCP)。 它为大型语言模型(LLM)与操作系统命令之间提供了安全的桥梁。

特色

  • 灵活命令执行:将任何shell命令作为MCP工具运行, 通过模板进行参数替换。
  • 基于配置的工具定义:在YAML中定义带有参数的工具, 约束和输出格式。
  • 通过约束实现安全:使用CEL表达式验证工具参数 执行前,以及可选的无盒环境 用于执行命令。
  • 快速原型化MCP工具:只需添加一些shell代码,作为 作为你LLM中的MCP工具。
  • 简单集成:支持任何支持 MCP 协议的大型语言模型客户端 (例如,光标、VSCode、Witsy…)

快速启动

想象一下你想让Cursor(或其他MCP客户端)帮你处理 硬盘空间问题。

  1. 创建一个配置文件 /my/example.yaml,定义你的工具:

可以看看示例目录,里面有更复杂、更实用的例子。 也许你更愿意让LLM知道你的Kubernetes集群情况,

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

README

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

MCPShell

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/[email protected]",
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

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