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
14.9K downloads
246 stars

The Windows CLI MCP Server allows secure command-line interactions on Windows systems, enabling MCP clients like Claude Desktop to perform operations via PowerShell, CMD, Git Bash, and SSH connections. It provides controlled access with configurable security restrictions to protect your system.

Installation

You can install the Windows CLI MCP Server using npm:

npx -y @simonb97/server-win-cli

To create a default configuration file, run:

npx @simonb97/server-win-cli --init-config ./config.json

Integration with Claude Desktop

To use this server with Claude Desktop, add the following to your claude_desktop_config.json:

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

If you want to use a specific configuration file:

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

Configuration

The server uses a JSON configuration file to customize its behavior. It looks for configuration in the following 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 security section controls access and permissions:

{
  "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 operate:

{
  "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

Enable and configure SSH connections:

{
  "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"
      }
    }
  }
}

Available Tools

Command Execution

Execute commands in different shells:

execute_command(shell, command, workingDir)
  • shell: "powershell", "cmd", or "gitbash"
  • command: The command to execute
  • workingDir (optional): Working directory

Command History

Retrieve execution history:

get_command_history(limit)
  • limit (optional): Maximum number of entries to return

SSH Operations

Execute commands on remote systems:

ssh_execute(connectionId, command)
  • connectionId: ID of the SSH connection
  • command: Command to execute remotely

Manage SSH connections:

ssh_disconnect(connectionId)
create_ssh_connection(connectionId, connectionConfig)
read_ssh_connections()
update_ssh_connection(connectionId, connectionConfig)
delete_ssh_connection(connectionId)

System Information

Get current directory:

get_current_directory()

Available Resources

The server provides several resources:

  • SSH Connections: ssh://{connectionId} - Details about specific SSH connections
  • SSH Configuration: ssh://config - Overall SSH settings
  • Current Directory: cli://currentdir - Current working directory
  • CLI Configuration: cli://config - Server configuration

Security Considerations

The server includes several security features:

  • Case-insensitive command blocking
  • Smart path parsing to prevent bypass attempts
  • Input validation
  • Process management
  • Sensitive data masking
  • Configurable command and argument blocking
  • Directory restrictions
  • Command length limits and timeouts

Be aware that commands can access environment variables and file systems within allowed paths, so configure security settings carefully.

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