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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mcp-wrapper

v0.0.5

Published

MCP Wrapper for cmd line tools

Readme

MCP Wrapper

MCP Wrapper for shell command line tools - Expose shell command line tools as MCP (Model Context Protocol) servers through simple YAML configuration.

Overview

MCP Wrapper allows you to easily create MCP servers that wrap shell command line tools. Define your tools in a simple YAML configuration file and expose them as MCP tools that can be used by AI assistants and other MCP clients.

Features

  • 🔧 Easy Configuration: Define tools using simple YAML configuration
  • 🌐 Cross-Platform Support: Platform-specific commands for Windows, macOS, and Unix/Linux
  • 📝 Mustache Templating: Dynamic command generation with input parameters
  • 🛡️ Input Validation: JSON Schema-based input validation using MCP SDK
  • 🔒 Advanced Security: Multi-layer security with configurable policies and sanitization
  • 📊 Comprehensive Logging: Winston-based logging with configurable levels
  • Official MCP SDK: Built on the official @modelcontextprotocol/sdk
  • 🚀 CLI Ready: Complete CLI tool with commander.js

Installation

Global Installation (Recommended)

npm install -g mcp-wrapper

Local Installation

npm install mcp-wrapper

Development Installation

git clone <repository-url>
cd mcp-wrapper
npm install
npm run build

Quick Start

  1. Create a configuration file (mcp-wrapper.yaml):
tools:
  calc:
    description: "Mathematical calculator based on bc command line"
    input:
      type: object
      properties:
        equation:
          description: "bc compatible equation"
          type: string
      required: [equation]
    cmd: "echo {{equation}} | bc -l"
  1. Start the MCP server:
mcp-wrapper --config mcp-wrapper.yaml
  1. Test thoroughly with various inputs to ensure security:
# Test with debug logging to see security actions
mcp-wrapper --config mcp-wrapper.yaml --log-level debug
  1. Use with an MCP client or test with the official MCP tools.

CLI Usage

mcp-wrapper [options]

Options:
  -c, --config <file>           Configuration file path (default: "mcp-wrapper.yaml")
  --timeout <seconds>           Command execution timeout in seconds (default: "30")
  --name <name>                 Server name
  --version-server <version>    Server version
  --log-level <level>           Log level: error|warn|info|debug (default: "info")
  -V, --version                 Display version number
  -h, --help                    Display help information

Note: Currently only stdio transport is supported.

Examples

# Start with default config file
mcp-wrapper

# Start with custom config
mcp-wrapper --config tools.yaml

# Start with debug logging
mcp-wrapper --config tools.yaml --log-level debug

# Start with custom server name and timeout
mcp-wrapper --config tools.yaml --name "My Tools Server" --timeout 60

Configuration Format

Basic Structure

tools:
  <tool_name>:
    name: <optional_display_name>
    description: <tool_description>
    input:
      type: object
      properties:
        <property_name>:
          type: <property_type>
          description: <property_description>
          default: <optional_default_value>
      required: [<required_property_names>]
    cmd: <shell_command_with_mustache_templates>

Cross-Platform Commands

For cross-platform compatibility, you can specify different commands for different operating systems:

tools:
  file_list:
    description: "List files in directory"
    input:
      type: object
      properties:
        path:
          type: string
          description: "Directory path"
          default: "."
    cmd:
      win: "dir {{path}}"
      unix: "ls -la {{path}}"
      macos: "ls -la {{path}}"
      default: "ls {{path}}"

Platform Keys:

  • win: Windows (platform() === 'win32')
  • macos: macOS (platform() === 'darwin')
  • unix: Unix/Linux (platform() === 'linux' or 'freebsd')
  • default: Fallback for any platform

Input Schema Types

Supported property types:

  • string: Text input
  • number: Floating point number
  • integer: Whole number
  • boolean: True/false value
  • array: List of values

Property Options:

  • description: Help text for the property
  • default: Default value if not provided
  • enum: Allowed values list
  • minimum/maximum: Numeric constraints
  • minLength/maxLength: String length constraints
  • pattern: Regular expression validation

Mustache Templating

Commands support Mustache templating with input parameters:

cmd: "echo {{expression}} | bc -l"

Template Features:

  • Variable substitution: {{variable}}
  • Nested properties: {{object.property}}
  • Automatic escaping for shell safety
  • Error on missing variables

Examples

See the examples/ directory for ready-to-use configuration examples including:

  • Calculator tool
  • Cross-platform file operations
  • Git repository tools
  • And more

Documentation

  • Security Guide: Comprehensive security documentation including security levels, types, and best practices
  • Examples: Ready-to-use configuration examples for various use cases

Programmatic Usage

You can also use MCP Wrapper as a library:

import { MCPWrapperServer, loadConfig } from 'mcp-wrapper';

// Load configuration
const config = loadConfig('./my-tools.yaml');

// Create server options (stdio transport is used by default)
const options = {
  configFile: './my-tools.yaml',
  name: 'My Custom Server',
  version: '1.0.0'
};

// Create and start server
const server = new MCPWrapperServer(config, options);
await server.start();

Security

This tool executes shell commands and carries inherent security risks. Users are responsible for testing configurations and implementing appropriate security measures.

📖 See docs/security.md for complete security configuration guide, including:

  • Security levels (strict, moderate, permissive)
  • Security types for input sanitization
  • Configuration options and examples
  • Best practices

Security Testing

Always test your tools with potentially malicious inputs:

# Test with debug logging to see security sanitization
mcp-wrapper --config tools.yaml --log-level debug

# Test with strict security level first
security:
  level: strict
  auditLogging: true

Example security test inputs:

  • Command injection: ; rm -rf /
  • Path traversal: ../../../etc/passwd
  • Command substitution: $(dangerous_command)
  • Special characters: |&;$()<>

Debugging

Enable debug logging to see detailed execution information:

mcp-wrapper --config tools.yaml --log-level debug

This will show:

  • Configuration loading details
  • Tool registration information
  • Security sanitization actions
  • Command execution with rendered templates
  • Error details and stack traces

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Development Setup

git clone <repository-url>
cd mcp-wrapper
npm install
npm run dev  # Development mode
npm run build  # Build for production
npm test  # Run tests

Development Tools

This tool has been developed in a hybrid mode, where the core architecture and logic were hand-crafted, while some parts of the implementation were created with the assistance of various LLM models and tools.

License

MPL-2.0 License - see LICENSE file for details.

Support

  • 🐛 Issues: Report bugs and request features on GitHub
  • 📖 Documentation: