Windows CLI MCP server

Control Windows command-line interfaces securely.
Back to servers
Setup instructions
Provider
Simon B
Release date
Dec 04, 2024
Language
TypeScript
Package
Stats
8.5K downloads
223 stars

The Windows CLI MCP Server provides a secure way to execute commands on Windows systems via Model Context Protocol. It supports multiple shells (PowerShell, CMD, Git Bash) and remote SSH connections, allowing AI assistants like Claude Desktop to perform operations on your system with configurable security controls.

Installation

You can use the Windows CLI MCP Server directly with npx or install it globally:

# Use with npx (no installation needed)
npx -y @simonb97/server-win-cli

# Or install globally
npm install -g @simonb97/server-win-cli

Setup with Claude Desktop

To integrate with Claude Desktop, modify your claude_desktop_config.json file:

{
  "mcpServers": {
    "windows-cli": {
      "command": "npx",
      "args": ["-y", "@simonb97/server-win-cli"]
    }
  }
}

To use a custom configuration file:

{
  "mcpServers": {
    "windows-cli": {
      "command": "npx",
      "args": [
        "-y",
        "@simonb97/server-win-cli",
        "--config",
        "path/to/your/config.json"
      ]
    }
  }
}

Configuration

Creating a Configuration File

You can create a default configuration file in two ways:

# Option 1: Generate a default config file
npx @simonb97/server-win-cli --init-config ./config.json

# Option 2: Copy the example file (if available)
# copy config.json.example config.json

Configuration Locations

The server looks for configuration in these locations (in order):

  1. Path specified by --config flag
  2. ./config.json in current directory
  3. ~/.win-cli-mcp/config.json in user's home directory

Security Settings

The configuration file has three main sections. Here are key security settings:

{
  "security": {
    "maxCommandLength": 2000,
    "blockedCommands": [
      "rm", "del", "rmdir", "format", "shutdown", 
      "restart", "reg", "regedit", "net", "netsh", 
      "takeown", "icacls"
    ],
    "blockedArguments": [
      "--exec", "-e", "/c", "-enc", "-encodedcommand",
      "-command", "--interactive", "-i", "--login", "--system"
    ],
    "allowedPaths": ["C:\\Users\\YourUsername", "C:\\Projects"],
    "restrictWorkingDirectory": true,
    "logCommands": true,
    "maxHistorySize": 1000,
    "commandTimeout": 30,
    "enableInjectionProtection": true
  }
}

Shell Configuration

Configure which shells are available and how they're executed:

{
  "shells": {
    "powershell": {
      "enabled": true,
      "command": "powershell.exe",
      "args": ["-NoProfile", "-NonInteractive", "-Command"],
      "blockedOperators": ["&", "|", ";", "`"]
    },
    "cmd": {
      "enabled": true,
      "command": "cmd.exe",
      "args": ["/c"],
      "blockedOperators": ["&", "|", ";", "`"]
    },
    "gitbash": {
      "enabled": true,
      "command": "C:\\Program Files\\Git\\bin\\bash.exe",
      "args": ["-c"],
      "blockedOperators": ["&", "|", ";", "`"]
    }
  }
}

SSH Configuration

Configure SSH connections for remote command execution:

{
  "ssh": {
    "enabled": false,
    "defaultTimeout": 30,
    "maxConcurrentSessions": 5,
    "keepaliveInterval": 10000,
    "keepaliveCountMax": 3,
    "readyTimeout": 20000,
    "connections": {
      "raspberry-pi": {
        "host": "raspberrypi.local",
        "port": 22,
        "username": "pi",
        "password": "raspberry"
      },
      "dev-server": {
        "host": "dev.example.com",
        "port": 22,
        "username": "admin",
        "privateKeyPath": "C:\\Users\\YourUsername\\.ssh\\id_rsa"
      }
    }
  }
}

Usage

Once configured, Claude Desktop (or other MCP clients) can interact with your system using these tools:

Basic Command Execution

Execute commands in your preferred shell:

// Example of how Claude would execute a command
execute_command({
  shell: "powershell",
  command: "Get-ChildItem",
  workingDir: "C:\\Projects"
})

SSH Commands

Execute commands on remote systems:

// Example of executing a command via SSH
ssh_execute({
  connectionId: "raspberry-pi",
  command: "ls -la"
})

Managing SSH Connections

Create, read, update, and delete SSH connections:

// Create a new SSH connection
create_ssh_connection({
  connectionId: "new-server",
  connectionConfig: {
    host: "192.168.1.100",
    port: 22,
    username: "admin",
    password: "secure_password"
  }
})

// Get all configured SSH connections
read_ssh_connections()

// Update an existing connection
update_ssh_connection({
  connectionId: "new-server",
  connectionConfig: {
    host: "192.168.1.100",
    port: 2222,
    username: "admin",
    password: "updated_password"
  }
})

// Delete a connection
delete_ssh_connection({
  connectionId: "new-server"
})

Other Useful Tools

// Get command history
get_command_history({
  limit: 10
})

// Get current working directory
get_current_directory()

Security Considerations

The server includes several security features:

  • Command and argument blocking
  • Directory restrictions
  • Command injection protection
  • Command length limits and timeouts
  • Case-insensitive command blocking
  • Smart path parsing to prevent bypasses

Always review the security settings before using the server, particularly:

  • Configure allowedPaths to limit where commands can execute
  • Review and customize blockedCommands based on your needs
  • Keep restrictWorkingDirectory enabled
  • Consider the sensitivity of data in directories you allow access to

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 "windows-cli" '{"command":"npx","args":["-y","@simonb97/server-win-cli"]}'

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": {
        "windows-cli": {
            "command": "npx",
            "args": [
                "-y",
                "@simonb97/server-win-cli"
            ]
        }
    }
}

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": {
        "windows-cli": {
            "command": "npx",
            "args": [
                "-y",
                "@simonb97/server-win-cli"
            ]
        }
    }
}

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