command-executor MCP Server logo

command-executor MCP Server

Community
Sunwood-ai-labs

Model Context Protocol Server for Safely Executing Pre-approved Commands

PublisherSunwood-ai-labs
Repositorycommand-executor-mcp-server
LanguageJavaScript
Forks
4
Stars
22
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    command-executor MCP Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    22 stars and 4 forks from the linked repository.

command-executor MCP Server

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:

%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

    • Only explicitly allowed commands can be executed
    • Default list is restrictive and security-focused
    • Commands are validated by prefix to prevent injection
  2. Command Validation

    • Command prefix validation prevents command injection
    • No shell execution for improved security
    • Environment variables are properly sanitized
  3. Error Handling

    • Comprehensive error handling for unauthorized commands
    • Clear error messages for debugging
    • Failed commands don't crash the server
  4. Environment Isolation

    • Server runs in its own environment
    • Environment variables can be controlled
    • Limited system access

💻 Development

📁 Project Structure

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.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "sunwood-ai-labs-command-executor-mcp-server": {
      "command": "",
      "args": []
    }
  }
}

Use command-executor MCP Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once command-executor MCP Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add command-executor MCP Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the command-executor MCP Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "sunwood-ai-labs-command-executor-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "command-executor"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the command-executor MCP Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the command-executor MCP Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use command-executor MCP Server to help me with this task?
command-executor MCP Server
Sure. I read it.
Here is what I found using command-executor MCP Server.

Frequently asked questions

What is the command-executor MCP Server MCP server used for?

command-executor MCP Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use command-executor MCP Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use command-executor MCP Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use command-executor MCP Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With command-executor MCP Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect command-executor MCP Server MCP to TypingMind?

command-executor MCP Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does command-executor MCP Server MCP provide in TypingMind?

command-executor MCP Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use command-executor MCP Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If command-executor MCP Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇