trackmcp
Back to directory
Sunwood-ai-labs

command-executor-mcp-server

View on GitHub

Model Context Protocol Server for Safely Executing Pre-approved Commands

21 stars JavaScriptAI & Machine Learning Updated Aug 19, 2025

Documentation

A Model Context Protocol server for executing pre-approved commands securely.

๐ŸŽฅ Demo

https://github.com/user-attachments/assets/ed763a12-b685-4e0b-b9a5-bc948a590f51

โœจ Features

  • Secure command execution with pre-approved command list
  • Configurable allowed commands through environment variables
  • Built with TypeScript and MCP SDK
  • Communication via stdio for seamless integration
  • Error handling and security validations
  • Real-time command output streaming

๐Ÿš€ Installation

Install dependencies:

bash
npm install

Build the server:

bash
npm run build

For development with auto-rebuild:

bash
npm run watch

โš™๏ธ Configuration

๐Ÿ”’ Allowed Commands

By default, the following commands are allowed:

  • git
  • ls
  • mkdir
  • cd
  • npm
  • npx
  • python

You can customize the allowed commands by setting the `ALLOWED_COMMANDS` environment variable:

bash
export ALLOWED_COMMANDS=git,ls,mkdir,python

๐Ÿ”Œ Claude Desktop Integration

To use with Claude Desktop, add the server config:

On MacOS:

bash
~/Library/Application Support/Claude/claude_desktop_config.json

On Windows:

code
%APPDATA%/Claude/claude_desktop_config.json

Configuration example:

json
{
  "mcpServers": {
    "command-executor": {
      "command": "/path/to/command-executor/build/index.js"
    }
  }
}

๐Ÿ›ก๏ธ Security Considerations

The command-executor server implements several security measures:

1. Pre-approved Command List

    2. Command Validation

      3. Error Handling

        4. Environment Isolation

          ๐Ÿ’ป Development

          ๐Ÿ“ Project Structure

          code
          command-executor/
          โ”œโ”€ src/
          โ”‚  โ””โ”€ index.ts      # Main server implementation
          โ”œโ”€ build/
          โ”‚  โ””โ”€ index.js      # Compiled JavaScript
          โ”œโ”€ assets/
          โ”‚  โ””โ”€ header.svg    # Project header image
          โ””โ”€ package.json     # Project configuration

          ๐Ÿ› Debugging

          Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector:

          bash
          npm run inspector

          The Inspector will provide a URL to access debugging tools in your browser.

          ๐Ÿ› ๏ธ Tool API

          The server provides a single tool:

          execute_command

          Executes a pre-approved command.

          Parameters:

          • `command` (string, required): The command to execute

          Example Request:

          json
          {
            "name": "execute_command",
            "arguments": {
              "command": "git status"
            }
          }

          Example Response:

          json
          {
            "content": [
              {
                "type": "text",
                "text": "On branch main\nNothing to commit, working tree clean"
              }
            ]
          }

          Error Response:

          json
          {
            "content": [
              {
                "type": "text",
                "text": "Command execution failed: Command not allowed"
              }
            ],
            "isError": true
          }

          โŒ Error Handling

          The server provides detailed error messages for various scenarios:

          1. Unauthorized Commands

          json
          {
               "code": "InvalidParams",
               "message": "Command not allowed: [command]. Allowed commands: git, ls, mkdir, cd, npm, npx, python"
             }

          2. Execution Failures

          json
          {
               "content": [
                 {
                   "type": "text",
                   "text": "Command execution failed: [error message]"
                 }
               ],
               "isError": true
             }

          ๐Ÿค Contributing

          1. Fork the repository

          2. Create your feature branch

          3. Commit your changes

          4. Push to the branch

          5. Create a new Pull Request

          ๐Ÿ“„ License

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

          Frequently asked questions

          What is command-executor-mcp-server?

          command-executor-mcp-server is Model Context Protocol Server for Safely Executing Pre-approved Commands

          How do I install command-executor-mcp-server?

          Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

          Is command-executor-mcp-server open source?

          Yes โ€” it is hosted on GitHub at https://github.com/Sunwood-ai-labs/command-executor-mcp-server and has 21 stars.

          Related MCP tools

          Mintplex-Labsanything-llm

          The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.

          50,686 JavaScript
          ai-agentscustom-ai-agentsdeepseek+16
          eyaltoledanoclaude-task-master

          An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others. Built for the Model Context Protocol to enhance AI capabiliti

          23,033 JavaScript
          aicursorcursor-ai+9
          xszyoufay

          Fayๆ˜ฏไธ€ไธชๅธฎๅŠฉๆ•ฐๅญ—ไบบ๏ผˆ2.5dใ€3dใ€็งปๅŠจใ€pcใ€็ฝ‘้กต๏ผ‰ๆˆ–ๅคง่ฏญ่จ€ๆจกๅž‹๏ผˆopenaiๅ…ผๅฎนใ€deepseek๏ผ‰่ฟž้€šไธšๅŠก็ณป็ปŸ็š„mcpๆก†ๆžถใ€‚ JavaScript-based implementation. Trusted by 12000+ developers.

          12,003 JavaScript
          aiandroidapi+4
          sonnylazuardicursor-talk-to-figma-mcp

          CTTF: MCP integration between Cursor and Figma, allowing Cursor Agentic AI to communicate with Figma for reading designs and modifying them programmatically.

          5,539 JavaScript
          agentagenticagentic-ai+11
          mendableaifirecrawl-mcp-server

          ๐Ÿ”ฅ Official Firecrawl MCP Server - Adds powerful web scraping and search to Cursor, Claude and any other LLM clients. JavaScript-based implementation.

          4,847 JavaScript
          batch-processingclaudecontent-extraction+11
          wonderwhy-erdesktopcommandermcp

          This is MCP server for Claude that gives it terminal control, file system search and diff file editing capabilities JavaScript-based implementation.

          4,840 JavaScript
          agentaicode-analysis+5

          Run your own MCP server? See who uses it and what to fix.

          Measure it with TrackMCP