Token导航 LogoToken导航TokenDH.com
PowerShell MCP Server logo
开发工具未说明官方级别未说明来源级核验

PowerShell MCP Server

MCP Server

一个用于与PowerShell交互的模型上下文协议服务器,提供执行PowerShell命令、检索系统信息、管理模块等功能。

工具数

0

提示词数

0

GitHub Stars

2

资源数

0
开发工具TypeScriptClaude命令行工具ClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

posidron

提供方

posidron

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

PowerShell MCP服务器

用于与PowerShell交互的模型上下文协议服务器。此服务器提供用于执行PowerShell命令、检索系统信息、管理模块等的工具。

需求

  • Node.js 18+
  • PowerShell 5.1或PowerShell Core 7+

安装

  1. 安装依赖项:
   npm install
  1. 构建项目:
   npm run build

配置

适用于克劳德桌面

编辑配置: $HOME/Library/Application\ Support/Claude/claude_desktop_config.json

添加到mcpServers:

{
  "mcpServers": {
    "mcp-powershell": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-powershell/dist/index.js"
      ]
    }
  }
}

VS代码

编辑配置: $HOME/Library/Application\ Support/Code/User/settings.json

添加到设置:

"mcp": {
  "servers": {
    "mcp-powershell": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-powershell/dist/index.js"
      ]
    }
  }
}

用于游标IDE

编辑配置: $HOME/.cursor/mcp.json

添加到mcpServers:

{
  "mcpServers": {
    "mcp-powershell": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-powershell/dist/index.js"
      ]
    }
  }
}

可用工具

此PowerShell MCP服务器提供以下工具:

execute_ps

执行PowerShell命令并获取结果。

Parameters:
- command (string): PowerShell command to execute

示例用法:

execute_ps(command: "Get-Process | Select-Object -First 5")

get_system_info

检索详细的系统信息,包括操作系统详细信息、处理器、内存和PowerShell版本。

Parameters: None

示例用法:

get_system_info()

list_modules

列出所有已安装的PowerShell模块,包括名称、版本和类型等详细信息。

Parameters: None

示例用法:

list_modules()

get_command_help

获取特定PowerShell命令的详细帮助,包括语法、参数和示例。

Parameters:
- command (string): PowerShell command to get help for

示例用法:

get_command_help(command: "Get-Process")

find_命令

按名称或模式搜索PowerShell命令。

Parameters:
- search (string): Search term for PowerShell commands

示例用法:

find_commands(search: "Process")

run_script

运行带有可选参数的PowerShell脚本文件。

Parameters:
- scriptPath (string): Path to the PowerShell script file
- parameters (string, optional): Optional parameters to pass to the script

示例用法:

run_script(scriptPath: "/path/to/script.ps1", parameters: "-Name 'Test' -Value 123")

发展

要在开发模式下运行:

npm run dev

扩展服务器

要添加自己的PowerShell工具,请执行以下操作:

  1. 编辑 src/index.ts
  2. 在中添加新工具 registerTools() 方法
  3. 遵循现有模式进行一致的错误处理
  4. 建立 npm run build

添加工具示例

// In the registerTools() method:
this.server.tool(
  "my_ps_tool",
  {
    param1: z.string().describe("Description of parameter 1"),
    param2: z.number().optional().describe("Optional numeric parameter"),
  },
  async ({ param1, param2 }) => {
    try {
      // Your PowerShell command
      const command = `Your-PowerShell-Command -Param1 "${param1}" ${param2 ? `-Param2 ${param2}` : ''}`;

      const { stdout, stderr } = await execAsync(`powershell -Command "${command.replace(/"/g, '\\"')}"`);

      if (stderr) {
        return {
          isError: true,
          content: [
            {
              type: "text" as const,
              text: `Error in my_ps_tool: ${stderr}`,
            },
          ],
        };
      }

      return {
        content: [
          {
            type: "text" as const,
            text: stdout,
          },
        ],
      };
    } catch (error) {
      return {
        isError: true,
        content: [
          {
            type: "text" as const,
            text: `Error in my_ps_tool: ${(error as Error).message}`,
          },
        ],
      };
    }
  }
);

安全考虑

  • 此服务器直接在您的系统上执行PowerShell命令
  • 命令的执行权限与运行MCP服务器的进程相同
  • 暴露破坏性操作时请小心
  • 考虑对敏感命令实施额外的验证

故障排除

常见问题

  1. PowerShell执行策略限制

- 您可能需要调整PowerShell执行策略以允许脚本执行 - 使用 Set-ExecutionPolicy RemoteSigned -Scope CurrentUser 允许本地脚本

  1. 未找到路径错误

- 确保文件路径是绝对路径或相对于工作目录的正确路径 - 为您的操作系统使用适当的路径分隔符

  1. 命令未找到错误

- 某些命令可能需要安装特定模块 - 使用 Install-Module ModuleName 安装所需模块

许可证

麻省理工学院

目录标签

目录标签

开发工具TypeScriptClaude命令行工具PowerShell工具本地部署系统管理自动化脚本

支持客户端

ClaudeCursor

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

部署方式(deploymentType,部署类型)

local-only

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明nonelocal-only

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP