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-terminal-runner

v0.2.2

Published

MCP server for executing shell commands safely

Readme

MCP Terminal Runner

An MCP server that allows AI agents to execute terminal commands on the host system.

Features

  • Execute Command: Run shell commands and retrieve stdout, stderr, and exit code. Supports pipes, redirects, and command chaining (e.g., &&).
  • Security: Strict allowlist system via ALLOWED_COMMANDS environment variable.
  • Cross-Platform: Works on Linux, macOS, and Windows.

Prerequisites

  • Node.js (version 18 or higher)

Configuration

Security: Allowed Commands

For security reasons, this server requires an explicit list of allowed commands. This is configured via the ALLOWED_COMMANDS environment variable.

  • Format: Comma-separated list of command binaries (e.g., ls,cat,echo).
  • Wildcard: Set to * to allow ALL commands (⚠️ DANGEROUS: Only use in trusted environments).
  • Validation: The server validates only the first command in the chain against the allowlist. For example, in echo hello && ls, only echo is checked.

Security (Optional): Allowed Working Directory Roots

If you enable cwd (see tool input below), you can optionally restrict which working directories are allowed via ALLOWED_CWD_ROOTS.

  • Format: Comma-separated list of allowed root paths.
  • Behavior:
    • If unset or empty, cwd is not restricted (any existing directory is allowed).
    • If set, the resolved and canonical cwd must be within at least one configured root.
    • If set and any configured root cannot be canonicalized (e.g., does not exist), requests that provide cwd are rejected (configuration error).

Usage

MCP Client Configuration

Add the following to your MCP client configuration (e.g., VS Code settings.json):

Basic Configuration

{
  "mcpServers": {
    "terminal-runner": {
      "command": "npx",
      "args": ["-y", "mcp-terminal-runner"],
      "env": {
        "ALLOWED_COMMANDS": "ls,cat,grep,echo"
      }
    }
  }
}

Configuration with Allowed Working Directories

{
  "mcpServers": {
    "terminal-runner": {
      "command": "npx",
      "args": ["-y", "mcp-terminal-runner"],
      "env": {
        "ALLOWED_COMMANDS": "ls,cat,grep,echo",
        "ALLOWED_CWD_ROOTS": "/home/user/projects,/tmp"
      }
    }
  }
}

Available Tools

execute_command

Executes a shell command.

  • Input:
    • command (string): The full command string to execute (e.g., ls -la src).
    • cwd (string, optional): Working directory to execute the command within.
  • Output:
    • Returns a YAML-formatted string containing:
      • exit_code: The command's exit code.
      • stdout: Standard output.
      • stderr: Standard error.

Development

Setup

  1. Clone the repository:
git clone <repository-url>
cd mcp-terminal-runner
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Available Scripts

  • npm run build - Build the TypeScript project
  • npm run dev - Run in development mode
  • npm start - Run the built JavaScript version
  • npm run check - Check code with Ultracite
  • npm test - Run tests with Vitest

Project Structure

mcp-terminal-runner/
├── src/
│   └── index.ts          # Main server implementation
├── dist/                 # Built JavaScript files
├── .husky/              # Git hooks
├── biome.json           # Biome configuration
├── tsconfig.json        # TypeScript configuration
├── package.json         # Project dependencies and scripts
└── README.md           # This file

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run npm run quality to ensure code quality
  5. Commit your changes (Husky will run pre-commit hooks)
  6. Push to your branch
  7. Create a Pull Request

Troubleshooting

Common Issues

  1. Server not starting: Ensure all dependencies are installed and the project is built
  2. Tools not appearing: Check that the MCP client configuration points to the correct path
  3. Permission errors: Make sure the built JavaScript file has execute permissions

Debug Mode

To enable debug logging, set the environment variable:

DEBUG=mcp* npm start