Cover image
Try Now
2024-12-19

Espejo dehttps: //github.com/mladensu/cli-mcp-server

3 years

Works with Finder

0

Github Watches

1

Github Forks

0

Github Stars

CLI MCP Server


A secure Model Context Protocol (MCP) server implementation for executing controlled command-line operations with comprehensive security features.

License Python Version MCP Protocol smithery badge


Table of Contents

  1. Overview
  2. Features
  3. Configuration
  4. Available Tools
  5. Usage with Claude Desktop
  6. Security Features
  7. Error Handling
  8. Development
  9. License

Overview

This MCP server enables secure command-line execution with robust security measures including command whitelisting, path validation, and execution controls. Perfect for providing controlled CLI access to LLM applications while maintaining security.

Features

  • 🔒 Secure command execution with strict validation
  • ⚙️ Configurable command and flag whitelisting
  • 🛡️ Path traversal prevention
  • 🚫 Shell operator injection protection
  • ⏱️ Execution timeouts and length limits
  • 📝 Detailed error reporting
  • 🔄 Async operation support

Configuration

Configure the server using environment variables:

Variable Description Default
ALLOWED_DIR Base directory for command execution Required
ALLOWED_COMMANDS Comma-separated list of allowed commands ls,cat,pwd
ALLOWED_FLAGS Comma-separated list of allowed flags -l,-a,--help
MAX_COMMAND_LENGTH Maximum command string length 1024
COMMAND_TIMEOUT Command execution timeout (seconds) 30

Installation

To install CLI MCP Server for Claude Desktop automatically via Smithery:

npx @smithery/cli install cli-mcp-server --client claude

Available Tools

run_command

Executes whitelisted CLI commands within allowed directories.

Input Schema:

{
 "command": {
   "type": "string",
   "description": "Command to execute (e.g., 'ls -l' or 'cat file.txt')"
 }
}

show_security_rules

Displays current security configuration and restrictions.

Usage with Claude Desktop

Add to your ~/Library/Application\ Support/Claude/claude_desktop_config.json:

Development/Unpublished Servers Configuration

{
 "mcpServers": {
   "cli-mcp-server": {
     "command": "uv",
     "args": [
       "--directory",
       "<path/to/the/repo>/cli-mcp-server",
       "run",
       "cli-mcp-server"
     ],
     "env": {
       "ALLOWED_DIR": "</your/desired/dir>",
       "ALLOWED_COMMANDS": "ls,cat,pwd,echo",
       "ALLOWED_FLAGS": "-l,-a,--help,--version",
       "MAX_COMMAND_LENGTH": "1024",
       "COMMAND_TIMEOUT": "30"
     }
   }
 }
}

Published Servers Configuration

{
  "mcpServers": {
    "cli-mcp-server": {
      "command": "uvx",
      "args": [
        "cli-mcp-server"
      ],
      "env": {
        "ALLOWED_DIR": "</your/desired/dir>",
        "ALLOWED_COMMANDS": "ls,cat,pwd,echo",
        "ALLOWED_FLAGS": "-l,-a,--help,--version",
        "MAX_COMMAND_LENGTH": "1024",
        "COMMAND_TIMEOUT": "30"
      }
    }
  }
}

In case it's not working or showing in the UI, clear your cache via uv clean.

Security Features

  • ✅ Command whitelist enforcement
  • ✅ Flag validation
  • ✅ Path traversal prevention
  • ✅ Shell operator blocking
  • ✅ Command length limits
  • ✅ Execution timeouts
  • ✅ Working directory restrictions

Error Handling

The server provides detailed error messages for:

  • Security violations
  • Command timeouts
  • Invalid command formats
  • Path security violations
  • Execution failures

Development

Prerequisites

  • Python 3.10+
  • MCP protocol library

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:

    uv sync
    
  2. Build package distributions:

    uv build
    

    This will create source and wheel distributions in the dist/ directory.

  3. Publish to PyPI:

    uv publish --token {{YOUR_PYPI_API_TOKEN}}
    

Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.

You can launch the MCP Inspector via npm with this command:

npx @modelcontextprotocol/inspector uv --directory {{your source code local directory}}/cli-mcp-server run cli-mcp-server

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.

License

This project is licensed under the MIT License - see the LICENSE file for details.


For more information or support, please open an issue on the project repository.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Andris Teikmanis
  • Latvian GPT assistant for developing GPT applications

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • https://cantaspinar.com
  • Summarizes videos and answers related questions.

  • https://hashrateventures.xyz
  • Crafts custom instructions for new GPTs

  • Jan Meindl
  • Builds new GPTs

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • OffchainLabs
  • Implementación de la prueba de estaca Ethereum

  • huahuayu
  • Una puerta de enlace de API unificada para integrar múltiples API de explorador de blockchain similar a Esterscan con soporte de protocolo de contexto modelo (MCP) para asistentes de IA.

  • deemkeen
  • Controle su MBOT2 con un combo de potencia: MQTT+MCP+LLM

    Reviews

    4 (1)
    Avatar
    user_2w7VPnkq
    2025-04-16

    As a passionate MCP application user, I can confidently say that the MladenSU_cli-mcp-server by MCP-Mirror is a game-changer. This versatile server enhances functionality and seamless integration, making it an essential tool for developers. Its straightforward setup and comprehensive documentation available at https://github.com/MCP-Mirror/MladenSU_cli-mcp-server ensure a smooth experience. Highly recommended for anyone looking to optimize their MCP workflow!