Windows系统监控服务

提供Windows环境下的系统信息和控制工具,适用于AI应用程序。

  • by carlosedp
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 carlosedp/windows-mcp-server

使用说明

Windows MCP服务器

该项目提供了一个Windows MCP(模型上下文协议)服务器,为您的AI应用程序上的Windows环境提供有用的系统信息和控制工具。

新增内容

  • 更强大的驱动器和正常运行时间实现(没有脆弱的PowerShell解析)。
  • 顶级进程的结构化结果(具有pid、name、cpu_percent、memoryMB的对象列表)。
  • 内存和网络信息的结构化结果。
  • 通过JSON解析GPU信息,更安全地使用PowerShell。

特性

  • 系统信息(操作系统、版本、体系结构、主机名)
  • 正常运行时间和上次启动时间
  • 驱动器列表和每个驱动器的空间使用情况
  • 内存、CPU、GPU和网络信息
  • 按内存和CPU划分的顶级进程(精确采样)

可用工具

工具名称 描述 参数 返回
Windows系统信息 获取操作系统、发行版、版本、体系结构和主机名 无 对象:名称、系统、发行版本、版本、架构、主机名
Windows上次启动时间 获取系统的上次启动时间 None 字符串(时间戳)
Windows正常运行时间 获取自上次启动以来的系统正常运行时间 None string:“正常运行时间: 秒”
Windows驱动器 获取所有可用驱动器的列表 无 字符串[](例如,[“C”,“D”])
Windows驱动器状态 获取特定驱动器的已用和可用空间 驱动器:字符串 DriveInfo{name,used_spaceGB:number,free_spaceGB:number}
Windows驱动器状态简单 使用逗号分隔的驱动器号获取状态 drives_string:string DriveInfo[]
Windows内存信息 获取RAM使用情况信息 无 对象:总内存、可用内存、已用内存(带GB的字符串)
Windows网络信息 获取每个接口的网络IPv4地址 无 对象:接口->IPv4(或{error})
Windows cpu信息 获取cpu型号、逻辑计数和频率 无 字符串
Windows gpu信息 获取gpu名称和驱动程序版本 无 字符串(每个gpu一行)
按内存列出的Windows顶级进程 按内存使用情况获取前X个进程 数量:int=5 ProcessInfo[]{pid,name,memoryMB,cpu_percent?}
按cpu计算的Windows顶级进程 按cpu使用率获取前X个进程(为准确性而采样) 数量:int=5 ProcessInfo[]{pid,name,cpu_percent,memoryMB}

注:以前记录的工具 Windows-name-version, Windows-drives-status,以及 Windows-all-drives-status 目前尚未实施,以避免重复。如果需要,可以轻松添加。

需求

  • Python 3.13+
  • uv(用于快速启动和依赖管理)
# On Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

安装

  1. 克隆此存储库:
git clone https://github.com/carlosedp/windows-mcp-server.git
cd windows-mcp-server

运行开发服务器

uv run mcp dev main.py

uv 处理依赖关系的安装,并在启用MCP协议的情况下运行服务器。

然后在MCP检查器浏览器窗口中:

  • 点击“连接”以连接MCP客户端。
  • 转到“工具”选项卡查看可用工具。
  • 单击“列出工具”查看可用工具。
  • 选择一个工具,然后单击“运行工具”以执行它。

例子

Windows系统信息

{
  "name": "MY-PC",
  "system": "Windows",
  "release": "10",
  "version": "10.0.19045",
  "architecture": "64bit",
  "hostname": "MY-PC"
}

Windows驱动器状态(输入:“C”)

{
  "name": "C",
  "used_spaceGB": 120.53,
  "free_spaceGB": 380.12
}

Windows内存信息

{
  "total_memory": "32.00 GB",
  "available_memory": "18.25 GB",
  "used_memory": "13.75 GB"
}

Windows网络信息

{
  "Ethernet": "192.168.1.50",
  "Wi-Fi": "10.0.0.15"
}

按cpu划分的Windows顶级进程(数量:3)

[
  { "pid": 1234, "name": "chrome.exe", "cpu_percent": 24.7, "memoryMB": 512.3 },
  { "pid": 4321, "name": "code.exe",   "cpu_percent": 12.1, "memoryMB": 650.8 },
  { "pid": 9876, "name": "System",     "cpu_percent": 8.4,  "memoryMB": 45.0 }
]

MCP客户端配置示例

LM Studio使用Llama 3.2 3B通过MCP服务器获取系统信息:

您可以运行的更多工具示例:

要将MCP客户端连接到此服务器(如Claude Desktop、VSCode、LM Studio等),请在客户端配置中添加以下内容:

{
  "mcpServers": {
    "windows-mcp": {
      "command": "uv",
      "args": [
        "--directory",
        "C:\\Users\\Carlos Eduardo\\repos\\windows-mcp-server",
        "run",
        "mcp",
        "run",
        "main.py"
      ]
    }
  }
}

将上述路径调整到项目文件所在的位置。

包装和分销

要作为Python包发布:

  1. 编辑 pyproject.toml 使用您的元数据。
  2. 构建并上传到PyPI:
python -m build
python -m twine upload dist/*

许可证

麻省理工学院