Claude Command Runner MCP server

Provides terminal command execution and management capabilities for macOS, bridging with terminal applications like Warp, iTerm2, and Terminal.app through AppleScript automation and SQLite-based command history tracking for intelligent command suggestions based on execution history and project context.
Back to servers
Setup instructions
Provider
M-Pineapple
Release date
Jun 30, 2025
Language
Python
Stats
5 stars

Claude Command Runner is a powerful Model Context Protocol (MCP) server that connects Claude Desktop with terminal applications. It enables Claude to execute commands and intelligently retrieve outputs, creating a seamless integration between AI assistance and your terminal environment.

Installation

Prerequisites

  • macOS 13.0 or later
  • Swift 6.0+ (Xcode 16+)
  • Claude Desktop
  • A supported terminal (Warp is strongly recommended)

Quick Setup

  1. Clone and build the server:

    git clone https://github.com/M-Pineapple/claude-command-runner.git
    cd claude-command-runner
    ./build.sh
    
  2. Configure Claude Desktop by adding to your MCP settings:

    {
      "claude-command-runner": {
        "command": "/path/to/claude-command-runner/.build/release/claude-command-runner",
        "args": ["--port", "9876"],
        "env": {}
      }
    }
    
  3. Restart Claude Desktop

Usage

Available Tools

Claude Command Runner provides several tools you can use:

  1. execute_command - Execute with manual output retrieval
  2. execute_with_auto_retrieve - Execute with intelligent auto-retrieval (recommended)
  3. get_command_output - Manually retrieve command output
  4. preview_command - Preview without executing
  5. suggest_command - Get command suggestions

Example Workflow

You: "Build my Swift project"
Claude: [Executes: swift build]
[Waits intelligently up to 77 seconds]
Claude: "Build completed successfully! Here's the output..."

Smart Auto-Retrieve

The execute_with_auto_retrieve command intelligently adjusts wait times based on command type:

  • Simple commands (echo, pwd): 2-6 seconds
  • Moderate commands (git, npm): up to 20 seconds
  • Build commands (swift build, make): up to 77 seconds
  • Test commands: up to 40 seconds

Configuration

You can customize the server's behavior through the configuration file located at ~/.claude-command-runner/config.json:

{
  "terminal": {
    "preferred": "auto",
    "fallbackOrder": ["Warp", "WarpPreview", "iTerm", "Terminal"]
  },
  "security": {
    "blockedCommands": ["rm -rf /", "format"],
    "maxCommandLength": 1000
  },
  "history": {
    "enabled": true,
    "maxEntries": 10000
  }
}

Troubleshooting

MCP Not Responding

  1. Check if the server is running: lsof -i :9876
  2. Restart Claude Desktop
  3. Rebuild with ./build.sh

Commands Not Appearing in Terminal

  1. Ensure Warp/WarpPreview is running
  2. Check Claude Desktop logs for errors
  3. Verify your MCP configuration path

Auto-Retrieve Not Working

  1. Ensure you're using execute_with_auto_retrieve (not execute_command)
  2. Check if command output file exists: ls /tmp/claude_output_*.json
  3. For long commands, wait for timeout message then use manual retrieval

Database Issues

If commands execute but aren't saved to the database:

  1. Check database integrity:

    sqlite3 ~/.claude-command-runner/claude_commands.db "PRAGMA integrity_check;"
    
  2. If corrupted, backup and remove the database:

    mv ~/.claude-command-runner/claude_commands.db ~/.claude-command-runner/claude_commands.db.backup
    # Restart Claude Desktop - a new database will be created automatically
    
  3. Verify the database is working:

    sqlite3 ~/.claude-command-runner/claude_commands.db "SELECT COUNT(*) FROM commands;"
    

Terminal Compatibility

For the best experience, Warp Terminal is recommended as it supports advanced features:

  • Automatic output capture
  • Command history integration
  • Modern UI/UX

While basic command execution works with Terminal.app and iTerm2, these terminals lack support for automatic output capture and advanced features.

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 "claude-command-runner" '{"command":"/path/to/claude-command-runner/.build/release/claude-command-runner","args":["--port","9876"]}'

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": {
        "claude-command-runner": {
            "command": "/path/to/claude-command-runner/.build/release/claude-command-runner",
            "args": [
                "--port",
                "9876"
            ]
        }
    }
}

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": {
        "claude-command-runner": {
            "command": "/path/to/claude-command-runner/.build/release/claude-command-runner",
            "args": [
                "--port",
                "9876"
            ]
        }
    }
}

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