PolarHub
  • Agents
  • MCP Servers
  • Skills
  • PolarBear
PolarHub © 2026
MCP Serversshell-accessMCP PowerShell助手
返回「shell-access」

MCP PowerShell助手

modelscope·@posidron/mcp-powershell

shell-access0下载LocalModelScope

简介

一种模型上下文协议服务器,使AI助手能够执行PowerShell命令、检索系统信息、管理模块以及在Windows系统上运行脚本。

MCP Server 详情

来自 ModelScope 索引

PowerShell MCP 服务器

用于与 PowerShell 交互的 Model Context Protocol 服务器。此服务器提供了执行 PowerShell 命令、检索系统信息、管理模块等功能。

要求

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

安装

  1. 安装依赖项: bash npm install

  2. 构建项目: bash npm run build

配置

对于 Claude Desktop

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

在 mcpServers 中添加以下内容: json { "mcpServers": { "mcp-powershell": { "command": "node", "args": [ "/absolute/path/to/mcp-powershell/dist/index.js" ] } } }

对于 VS Code

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

在设置中添加以下内容: json "mcp": { "servers": { "mcp-powershell": { "command": "node", "args": [ "/absolute/path/to/mcp-powershell/dist/index.js" ] } } }

对于 Cursor IDE

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

在 mcpServers 中添加以下内容: json { "mcpServers": { "mcp-powershell": { "command": "node", "args": [ "/absolute/path/to/mcp-powershell/dist/index.js" ] } } }

可用工具

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

execute_ps

执行一个 PowerShell 命令并获取结果。

参数:

  • command (string): 要执行的 PowerShell 命令

使用示例:

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

get_system_info

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

参数:无

使用示例:

get_system_info()

list_modules

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

参数:无

使用示例:

list_modules()

get_command_help

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

参数:

  • command (string): 要获取帮助的 PowerShell 命令

使用示例:

get_command_help(command: "Get-Process")

find_commands

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

参数:

  • search (string): PowerShell 命令的搜索词

使用示例:

find_commands(search: "Process")

run_script

运行一个 PowerShell 脚本文件,并可选地传递参数。

参数:

  • scriptPath (string): PowerShell 脚本文件的路径
  • parameters (string, optional): 传递给脚本的可选参数

使用示例:

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

开发

以开发模式运行: bash npm run dev

扩展服务器

要添加自己的 PowerShell 工具:

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

添加工具示例

typescript // 在 registerTools() 方法中: this.server.tool( "my_ps_tool", { param1: z.string().describe("参数 1 的描述"), param2: z.number().optional().describe("可选的数值参数"), }, async ({ param1, param2 }) => { try { // 你的 PowerShell 命令 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: `my_ps_tool 错误: ${stderr}`,
        },
      ],
    };
  }

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

} );## 安全注意事项

  • 该服务器直接在您的系统上执行 PowerShell 命令
  • 命令以运行 MCP 服务器进程的相同权限执行
  • 在暴露破坏性操作时需谨慎
  • 考虑为敏感命令实现额外的验证

故障排除

常见问题

  1. PowerShell 执行策略限制

    • 您可能需要调整 PowerShell 执行策略以允许脚本执行
    • 使用 Set-ExecutionPolicy RemoteSigned -Scope CurrentUser 允许本地脚本执行
  2. 找不到路径错误

    • 确保文件路径是绝对路径或相对于工作目录的正确相对路径
    • 使用适合您操作系统的路径分隔符
  3. 找不到命令错误

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

许可证

MIT

相关 MCP Servers(来自「shell-access」)

NoveltyEngine

暂无描述。

@NoveltyEngine/python-hello-warp-mcp

mcp-server-terminal

暂无描述。

@aybelatchane/mcp-server-terminal

20250923MCPtest

暂无描述。

@WeiWeicode/20250923MCPtest

docker-mcp-server

暂无描述。

@kenforthewin/docker-mcp-server

drapon

暂无描述。

@drapon/claude-mcp-servers

first_mcp

暂无描述。

@koopatroopa787/first_mcp

自动安装

点击按钮会唤起 PolarBear 客户端,并把当前 MCP Server 的 Markdown 详情文档地址传给客户端。

/api/mcps/posidron-mcp-powershell/markdown
打开 PolarBear 安装查看 Markdown 文档

手动安装

在 PolarBear 或其他支持 MCP 的客户端中,新建 MCP Server,并参考下方来源或安装提示配置。

暂未识别到安装命令,请打开 ModelScope 详情查看完整配置。

基本信息

分类
shell-access / os-automation / command-line
运行方式
No
许可证
Unknown
详情文件
posidron-mcp-powershell.md