Skip to main content

MCP server for Windows Remote Management (WinRM) with secure domain authentication

Project description

WinRM MCP Server

A Model Context Protocol (MCP) server that provides AI agents with the ability to interact with Windows servers using Windows Remote Management (WinRM). This server enables secure remote PowerShell execution and system management tasks on Windows hosts.

Features

  • Secure Authentication: Uses domain credentials stored in macOS Keychain with TouchID authentication
  • PowerShell Execution: Execute arbitrary PowerShell commands on remote Windows hosts
  • System Information: Get basic system information, running services, and disk space
  • Error Handling: Comprehensive error handling with helpful error messages
  • Memory Safety: Credentials are cleared from memory immediately after use

Installation

From PyPI (Recommended)

pip install winrm-mcp-server

From Source

git clone https://github.com/rorymcmahon/winrm-mcp-server.git
cd winrm-mcp-server
pip install -e .

Configuration

Prerequisites

  1. WinRM Configuration: Ensure target Windows hosts have WinRM enabled and configured.

  2. Credential Setup: The server will prompt for credentials on first use and cache them securely in macOS Keychain with 4-hour expiration.

MCP Configuration

Add to your MCP settings file (e.g., ~/.config/mcp/settings.json):

{
  "mcpServers": {
    "winrm": {
      "command": "winrm-mcp-server"
    }
  }
}

Available Tools

setup_credentials(hostname: str)

Setup credentials for a Windows host (interactive mode).

Parameters:

  • hostname: The target Windows hostname (FQDN)

Returns:

  • status: Success or error status
  • message: Confirmation message

execute_powershell(hostname: str, command: str)

Execute arbitrary PowerShell commands on a remote Windows host.

Parameters:

  • hostname: The target Windows hostname (FQDN)
  • command: PowerShell command to execute

Returns:

  • status: Exit code of the command
  • stdout: Standard output from the command
  • stderr: Standard error from the command

get_system_info(hostname: str)

Get basic system information from a Windows host.

Returns: JSON with Windows product name, total physical memory, and processor information.

get_running_services(hostname: str)

Get list of running services from a Windows host.

Returns: JSON array of running services with name, status, and start type.

get_disk_space(hostname: str)

Get disk space information from a Windows host.

Returns: JSON array of logical disks with device ID, total size, and free space in GB.

Usage Examples

Initial Setup

"Setup credentials for server01.domain.local"

Basic System Check

"Get system info and disk space for server01.domain.local"

Service Management

"Check if IIS is running on webserver.domain.local"
"Get running services on server01.domain.local"

Custom PowerShell Commands

"Run 'Get-EventLog -LogName System -Newest 10' on server01.domain.local"
"Execute 'Get-Process | Sort-Object CPU -Descending | Select-Object -First 10' on server01.domain.local"

Security

  • Credential Storage: Domain credentials are securely stored in macOS Keychain
  • TouchID Authentication: Credentials require TouchID authentication for access
  • Memory Safety: Passwords are immediately cleared from memory after use
  • Transport Security: Uses NTLM authentication over HTTP (configurable for HTTPS)
  • Automatic Expiration: Cached credentials expire after 4 hours
  • Secure Prompting: Password input is hidden and never logged

Development

Setup Development Environment

git clone https://github.com/rorymcmahon/winrm-mcp-server.git
cd winrm-mcp-server
pip install -e ".[dev]"

Running Tests

pytest

Code Formatting

black src/
isort src/

Requirements

  • Python 3.8+
  • macOS (for Keychain integration)
  • Target Windows hosts with WinRM enabled

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Support

For issues and questions:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

win_mcp_server-0.2.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

win_mcp_server-0.2.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file win_mcp_server-0.2.0.tar.gz.

File metadata

  • Download URL: win_mcp_server-0.2.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for win_mcp_server-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8f3fffe761f21abbe4e9e3df865db7034fb322b426bbb69ce328ee4882b65b67
MD5 4b172b54b7f3354eb4d943bfb3ce5cc4
BLAKE2b-256 7a97ec8590d52c507c7a145738da2393065fc6cd20cdb85afebcf82ec4975e65

See more details on using hashes here.

File details

Details for the file win_mcp_server-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: win_mcp_server-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for win_mcp_server-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a36e1df4d6eaacb20eb15cbb0b7d010b6acec9b746989ada2e70ee7bc7fc3bf
MD5 ec6ec530cf8cd439ac5f89e7b1999636
BLAKE2b-256 fc30eefa3ba070946d6260e514174586fe90462825a4113e1fc7b064801a0dab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page