CLI MCP server

Execute system commands and scripts on the host machine.
Back to servers
Setup instructions
Provider
g0t4
Release date
Nov 29, 2024
Language
TypeScript
Package
Stats
13.5K downloads
173 stars

This MCP server allows your large language model (like Claude) to execute commands and scripts on your system directly from the chat interface. It provides two main tools: running shell commands and executing scripts in various interpreters, making it easier to perform system operations without leaving your AI assistant.

Installation

Using NPM Package

The simplest way to install is through the published npm package:

  1. Create or edit the Claude Desktop configuration file:

    • On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • On Windows: %APPDATA%/Claude/claude_desktop_config.json
  2. Add the following configuration:

{
  "mcpServers": {
    "mcp-server-commands": {
      "command": "npx",
      "args": ["mcp-server-commands"]
    }
  }
}

Using Local Build

If you prefer to build from source:

  1. Clone the repository
  2. Edit the Claude Desktop configuration file (same location as above)
  3. Add the following configuration, replacing the path with your actual path:
{
  "mcpServers": {
    "mcp-server-commands": {
      "command": "/path/to/mcp-server-commands/build/index.js"
    }
  }
}

Usage

Available Tools

run_command

This tool allows Claude to execute shell commands on your system:

  • Executes commands like hostname, ls -al, echo "hello world", etc.
  • Returns both STDOUT and STDERR as text in the chat

Example usage: Ask Claude to "Show me the files in my current directory" and it will use this tool to run ls or equivalent.

run_script

This tool enables Claude to write and execute scripts in various languages:

  • Scripts can be written in bash, fish, zsh, python, etc.
  • The script content is passed via STDIN
  • Claude can get creative, such as using cat as the interpreter to create new files

Example usage: Ask Claude to "Write a Python script that sorts a list of numbers" and it can both write and execute the script.

Safety Considerations

⚠️ Important safety warning:

  • Always use "Approve Once" in Claude Desktop app (not "Allow for This Chat")
  • Review each command before approving
  • Use "Deny" if you don't trust the command
  • Never run the server with sudo privileges
  • The server has the same permissions as the user running it

Logging

Claude Desktop writes logs to:

  • macOS: ~/Library/Logs/Claude/mcp-server-mcp-server-commands.log

For more detailed logs, add --verbose to the args in your configuration:

{
  "mcpServers": {
    "mcp-server-commands": {
      "command": "npx",
      "args": ["mcp-server-commands", "--verbose"]
    }
  }
}

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-server-commands" '{"command":"npx","args":["mcp-server-commands"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mcp-server-commands": {
            "command": "npx",
            "args": [
                "mcp-server-commands"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp-server-commands": {
            "command": "npx",
            "args": [
                "mcp-server-commands"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later