Skip to main content
Glama

winrm-mcp

一个刻意保持精简的 MCP 服务器,用于通过 WinRM 在 Windows 主机上运行 PowerShell 和 CMD 命令。它借鉴了 ssh-winrm-mcp 中的 WinRM 执行思路,增加了聚焦的多主机清单,并省略了 SSH、持久会话、作业、命令组和文件传输。

工具

  • winrm_test — 验证身份验证和连接。

  • winrm_execute_powershell — 执行 PowerShell。

  • winrm_execute_cmd — 执行 CMD。

  • winrm_inventory_statuswinrm_inventory_initwinrm_inventory_validate — 管理清单文件。

  • winrm_host_listwinrm_host_getwinrm_host_savewinrm_host_updatewinrm_host_delete — 管理可复用主机。

每个工具都接受一个可选的 connection 对象。其中的值会覆盖进程环境:

{
  "host": "192.168.1.50",
  "username": "Administrator",
  "password_env": "MY_WINRM_PASSWORD",
  "auth": "ntlm",
  "ssl": true,
  "cert_validation": false
}

ssl 选择 HTTPS(通常端口 5986)还是 HTTP(通常端口 5985)。自签名 HTTPS 监听器需要 cert_validation=false,但仅应用于受信任的主机。

支持的连接字段包括 hostusernamepasswordpassword_envportsslauthcert_validationencryptionpathconnect_timeoutread_timeoutoperation_timeout

Related MCP server: Win MCP Server

多主机清单

主机可以存储在任一清单作用域中:

  • user(默认):在 Linux/macOS 上为 ${XDG_CONFIG_HOME:-~/.config}/winrm-mcp/inventory.json,在 Windows 上为对应的 %APPDATA% 位置。

  • project:当前工作目录下的 .winrm-mcp/inventory.json

使用 WINRM_MCP_INVENTORY_SCOPE=userWINRM_MCP_INVENTORY_SCOPE=project 选择进程默认值。每个清单和主机工具也接受显式的 scope,执行工具接受 inventory_scope。项目作用域使用 WINRM_MCP_PROJECT_DIR,然后是启动器的逻辑 PWD,最后是进程工作目录。它会拒绝临时的 deepagents_server_* 路径,而不是静默保存一次性清单数据。当启动器工作目录不是所需项目根目录时,请设置 WINRM_MCP_PROJECT_DIR。通过 WINRM_MCP_INVENTORY_FILE 支持完全自定义的文件;当调用未显式选择作用域时,将使用该文件。

创建项目清单并保存两个主机:

winrm_inventory_init(scope="project")

winrm_host_save(
  name="epv1",
  scope="project",
  settings={
    "host": "10.0.110.50",
    "username": "Administrator",
    "password_env": "EPV1_WINRM_PASSWORD",
    "auth": "ntlm",
    "ssl": true,
    "cert_validation": false
  }
)

winrm_host_save(
  name="epv2",
  scope="project",
  settings={
    "host": "10.0.110.51",
    "username": "Administrator",
    "password_env": "EPV2_WINRM_PASSWORD",
    "auth": "ntlm",
    "ssl": true,
    "cert_validation": false
  }
)

按名称使用已保存的主机:

winrm_test(saved_host="epv1", inventory_scope="project")
winrm_execute_powershell(saved_host="epv1", inventory_scope="project", command="hostname")
winrm_execute_cmd(saved_host="epv2", inventory_scope="project", command="whoami")

可选的 connection 对象会覆盖该调用中已保存主机的字段。清单写入是原子的,并且在类 Unix 系统上,清单文件限制为当前用户(0600)。支持内联密码,但会以明文形式存储在该受保护的 JSON 文件中;建议使用 password_env

当不需要覆盖时,省略 connection。为了兼容将可选值序列化为文本的代理,connection="None"connection="null" 和空连接字符串均被视为 JSON null

DeepAgents

DeepAgents 可以直接从 GitHub 运行服务器,因此无需本地检出。将以下条目添加到你的 DeepAgents .deepagents/.mcp.json 文件中:

{
  "winrm": {
    "type": "stdio",
    "command": "uv",
    "args": [
      "tool",
      "run",
      "--with",
      "mcp>=1.28,<2",
      "--from",
      "git+https://github.com/bigbatmanorg/winrm-mcp.git",
      "winrm-mcp"
    ],
    "env": {
      "WINRM_MCP_HOST": "192.168.1.50",
      "WINRM_MCP_USERNAME": "Administrator",
      "WINRM_MCP_PASSWORD": "YOUR_SECRET",
      "WINRM_MCP_PORT": "5986",
      "WINRM_MCP_AUTH": "ntlm",
      "WINRM_MCP_SSL": "true",
      "WINRM_MCP_CERT_VALIDATION": "false",
      "WINRM_MCP_INVENTORY_SCOPE": "project",
      "WINRM_MCP_PROJECT_DIR": "${PWD}",
      "WINRM_MCP_CONNECT_TIMEOUT": "30",
      "WINRM_MCP_READ_TIMEOUT": "60",
      "WINRM_MCP_OPERATION_TIMEOUT": "30"
    }
  }
}

对于可重现的安装,请将仓库固定到发布标签或提交:

"git+https://github.com/bigbatmanorg/winrm-mcp.git@YOUR_TAG_OR_COMMIT"

该示例使用 HTTPS,并针对具有自签名证书的受信任开发主机禁用了证书验证。当监听器证书受信任时,请保持 WINRM_MCP_CERT_VALIDATION=true。不要将真实密码提交到源代码控制;请使用你正常的 DeepAgents 秘密注入工作流来处理 WINRM_MCP_PASSWORD。DeepAgents 在启动 MCP 服务器之前会展开 ${PWD}。如果 DeepAgents 本身是从项目根目录以外的位置启动的,请将其替换为绝对路径。

安装与运行

uv sync --extra dev
uv run pytest
uv run winrm-mcp

默认传输是 stdio。客户端配置可以提供稳定的连接默认值,而无需在每个工具调用中放入凭据:

{
  "servers": {
    "winrm": {
      "type": "stdio",
      "command": "uv",
      "args": ["--directory", "/home/toor/projects/winrm-mcp", "run", "winrm-mcp"],
      "env": {
        "WINRM_MCP_HOST": "192.168.1.50",
        "WINRM_MCP_USERNAME": "Administrator",
        "WINRM_MCP_PASSWORD_ENV": "MY_WINRM_PASSWORD",
        "MY_WINRM_PASSWORD": "replace-me",
        "WINRM_MCP_AUTH": "ntlm",
        "WINRM_MCP_SSL": "true",
        "WINRM_MCP_CERT_VALIDATION": "false"
      }
    }
  }
}

可用的环境默认值对应于连接字段,并使用 WINRM_MCP_ 前缀。服务器设置为 WINRM_MCP_TRANSPORTWINRM_MCP_SERVER_HOSTWINRM_MCP_SERVER_PORT。清单设置为 WINRM_MCP_INVENTORY_SCOPEWINRM_MCP_PROJECT_DIRWINRM_MCP_INVENTORY_FILE

如需 Kerberos 或 CredSSP 支持,请安装匹配的可选附加组件:

uv sync --extra kerberos
uv sync --extra credssp
Install Server
A
license - permissive license
B
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables management of Windows servers from Linux through an MCP server with per-user installation. Provides tools to control Windows systems via API with secure credential management.
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to securely manage and execute commands on remote Windows servers via WinRM, including PowerShell execution, system information retrieval, and service management.
    5
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Enables executing commands and transferring files over SSH on multiple hosts concurrently, with auto-discovery from SSH config and support for various authentication methods.
    3
    13
    MIT

View all related MCP servers

Related MCP Connectors

  • Execute PowerShell commands securely with controlled timeouts and input validation. Retrieve syste…

  • Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.

  • Eyes and hands on real Windows PCs — observe, click, type via Glasswarp API.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bigbatmanorg/winrm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server