npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mcp-cli

v1.0.5

Published

A secure MCP CLI server implementation with comprehensive path whitelist validation, providing controlled file system operations and command execution in a protected environment. Features include strict security measures, real-time path validation, secure

Downloads

113

Readme

MCP CLI Server

NPM Version License

A secure Node.js implementation of the Model Context Protocol (MCP) that provides controlled file system operations and command execution capabilities. This server implements a comprehensive path whitelist validation mechanism as its core security feature, meticulously validating whether the working path or target path is within the specified whitelist before each file operation or command execution. This strict validation ensures that operations are confined to designated safe directories, preventing accidental or malicious access to sensitive system data.

Key Security Features:

  • Path Whitelist Validation: Every file and directory operation is validated against a predefined whitelist
  • Secure Command Execution: All shell commands are executed in a controlled environment with strict directory restrictions
  • Access Control: Prevents unauthorized access to system files and directories outside the whitelist
  • Error Prevention: Comprehensive error handling to prevent system data corruption

English | 繁體中文 | 日本語 | 한국어 | Español | Français | Deutsch | Italiano

Using with Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "cli": {
      "command": "npx",
      "args": [
        "-y", 
        "mcp-cli", 
        "/path/to/allowed/directory", 
        "/path/to/allowed/directory2", 
        ...
        ]
    }
  }
}

Security Features

Path Security

  • Strict path whitelist validation mechanism
    • Every path operation is validated against the whitelist
    • Prevents directory traversal attacks
    • Blocks access to sensitive system directories
    • Validates both absolute and relative paths
  • Real-time path validation
    • Pre-execution validation for all operations
    • Continuous monitoring of path boundaries
    • Prevention of path manipulation attempts
  • Access control enforcement
    • Strict directory permissions
    • Prevention of unauthorized access
    • Protection against privilege escalation

Command Execution Security

  • Controlled execution environment
    • Commands run in isolated contexts
    • Working directory restrictions
    • Environment variable sanitization
  • Command validation
    • Pre-execution security checks
    • Parameter sanitization
    • Output handling security
  • Resource usage controls
    • Process isolation
    • Resource limitation
    • Execution timeout management

File System Operations

Secure File Operations

  • Read file content (with whitelist validation)
    • Content access control
    • Binary file handling
    • Stream-based reading for large files
  • Write file (with whitelist validation)
    • Atomic write operations
    • Backup creation
    • Permission preservation
  • Copy file (source and target path validation)
    • Secure copy mechanisms
    • Metadata preservation
    • Error recovery
  • Move file (source and target path validation)
    • Atomic move operations
    • Cross-device support
    • Permission handling
  • Delete file (with whitelist validation)
    • Secure deletion
    • Resource cleanup
    • Deletion verification

Directory Operations

  • Create directory (with whitelist validation)
    • Permission structure setup
    • Parent directory validation
    • Recursive creation support
  • Remove directory (with whitelist validation)
    • Safe recursive deletion
    • Resource cleanup
    • Permission verification
  • List directory contents (with whitelist validation)
    • Content filtering
    • Permission-based listing
    • Metadata inclusion

System Integration

Environment Management

  • Node.js runtime integration
  • Python version compatibility
  • Shell environment configuration
  • Cross-platform support
    • Windows compatibility
    • Unix-like systems support
    • Path normalization

Resource Monitoring

  • CPU usage tracking
  • Memory allocation monitoring
  • Disk space management
  • Process monitoring
    • Active process tracking
    • Resource limitation
    • Performance optimization

Available Tools

The server provides a comprehensive set of secure tools:

  • validatePath: Validates path against whitelist with detailed security checks
  • executeCommand: Executes shell commands in a secure, controlled environment
  • readFile: Securely reads file content with access control
  • writeFile: Performs secure file writing with atomic operations
  • copyFile: Implements secure file copying with integrity checks
  • moveFile: Executes secure file moving with transaction support
  • deleteFile: Performs secure file deletion with verification
  • createDirectory: Creates directories with proper security controls
  • removeDirectory: Safely removes directories with resource cleanup
  • listDirectory: Lists directory contents with security filtering
  • getSystemInfo: Retrieves system information securely

Error Handling

Comprehensive error handling system:

  • Path validation errors
    • Invalid path detection
    • Whitelist violation alerts
    • Path manipulation attempts
  • File operation errors
    • Access denied handling
    • Resource unavailable
    • Corruption prevention
  • Command execution errors
    • Execution failure handling
    • Resource exhaustion
    • Security violation detection
  • System information errors
    • Data collection failures
    • Resource access issues
    • Permission problems

Implementation Details

Built with enterprise-grade security:

  • Model Context Protocol SDK
    • Secure communication
    • Protocol validation
    • Data integrity checks
  • shelljs for secure file system operations
    • Command sanitization
    • Path validation
    • Error handling
  • cross-env for secure cross-platform support
    • Environment isolation
    • Variable sanitization
    • Platform compatibility
  • Zod for strict data validation
    • Schema enforcement
    • Type safety
    • Input sanitization