WMI查询服务器

一个模型上下文协议(MCP)服务器,使LLM能够执行Windows管理工具(WMI)查询,从Windows计算机检索全面的系统信息。

  • by hasaranga
  • C++
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 hasaranga/wmi-mcp

使用说明

WMI MCP服务器

一种模型上下文协议(MCP)服务器,使LLM能够执行Windows管理规范(WMI)查询,以从Windows计算机检索全面的系统信息。

概述

这是一个 基于stdio的MCP服务器 它为LLM提供了在Windows系统中查询以下内容的能力:

  • 硬件信息(CPU、内存、磁盘、网络适配器)
  • 运行流程和服务
  • 系统配置和设置
  • 网络信息
  • 事件日志
  • 性能计数器
  • 更多通过WMI

特性

  • 对任何WMI命名空间执行WQL(WMI查询语言)查询
  • 返回结构化JSON数据,便于LLM解析
  • 支持所有主要的WMI命名空间(ROOT\CIMV2、ROOT\WMI等)
  • 全面的错误处理
  • 所有WMI属性类型的类型安全数据转换

安装

  1. 从版本下载或编译可执行文件 (wmi-mcp.exe)
  2. 放置可执行文件 在您选择的目录中(例如。, C:\Users\YourName\wmi-mcp\)
  3. 配置LLM代理 使用此MCP服务器

编译(如果从源代码构建)

# Using MSVC
cl main.cpp /EHsc ole32.lib oleaut32.lib wbemuuid.lib

# Using MinGW/GCC
g++ -std=c++11 main.cpp -lole32 -loleaut32 -lwbemuuid -o wmi-mcp.exe

配置

适用于Gemini CLI

将以下内容添加到MCP配置中:

{
  "mcpServers": {
    "WMIServer": {
      "command": "wmi-mcp.exe",
      "cwd": "C:\\Users\\XXX\\wmi-mcp",
      "timeout": 15000,
      "trust": true
    }
  }
}

适用于克劳德桌面

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "wmi-query": {
      "command": "C:\\Users\\XXX\\wmi-mcp\\wmi-mcp.exe",
      "args": []
    }
  }
}

对于其他MCP客户端

配置为指向可执行路径的stdio服务器。

询问有关系统的问题

设置后,您可以简单地问LLM问题,如“为什么我的计算机运行很热?”或“我的硬盘是否出现故障?”。LLM会将您的问题转换为必要的WMI查询,并将其发送到此MCP服务器以供执行。

几个例子

Why does my PC boot slow?
Why is my computer running hot?
Why is my internet slow?
Why is my battery draining so fast?
Why is my game lagging?
Were there failed or unexpected login attempts?
Is my hard drive failing?
Is there any suspicious process on my PC?
Can my PC run this game/software?
Which programs start with Windows?
What processes are using my network right now?
Is my antivirus active and up to date?
When was the last time my system updated?
Are critical Windows services disabled or tampered with?
Has new software installed recently?
Are there suspicious scheduled tasks?
Are my firewall and antivirus still active?
Which programs connected to suspicious IP addresses?
Are there suspicious startup programs?

刀具参数

执行WMI查询

参数:

  • namespace (可选):要查询的WMI命名空间
    • 违约: ROOT\CIMV2
    • 示例: ROOT\WMI, ROOT\RSOP\Computer, ROOT\SecurityCenter2
  • query (必填):WQL查询字符串
    • 例子: SELECT * FROM Win32_Process

退货: 结构化JSON,包括:

  • success:表示查询成功的布尔值
  • namespace:查询的命名空间
  • query:已执行的查询
  • count:返回的对象数量
  • objects:WMI对象及其属性的数组
  • error:错误消息(如有)

常见WMI类

类别 描述
Win32_Process 正在运行的进程
Win32_Service 系统服务
Win32_LogicalDisk 磁盘驱动器
Win32_ComputerSystem 计算机系统信息
Win32_OperatingSystem 操作系统信息
Win32_Processor CPU信息
Win32_PhysicalMemory RAM模块
Win32_NetworkAdapter 网络适配器
Win32_NetworkAdapterConfiguration 网络配置
Win32_EventLog 事件日志文件
Win32_NTLogEvent 事件日志条目

WMI命名空间

命名空间 用途
ROOT\CIMV2 最常见的系统信息
ROOT\WMI 硬件传感器和性能
ROOT\SecurityCenter2 安全产品信息
ROOT\RSOP 组策略信息
ROOT\Microsoft\Windows\Storage 存储管理

安全说明

  • 作为安全措施,如果以管理权限执行,服务器将不会启动。
  • 考虑允许LLM查询系统信息的安全影响

贡献

请随时提交问题、功能请求或拉取请求以改进此MCP服务器。

作者

R.哈萨兰加(https://www.hasaranga.com)