Skip to main content
Glama
posidron

PowerShell MCP Server

by posidron

PowerShell MCP-сервер

Сервер Model Context Protocol для взаимодействия с PowerShell. Этот сервер предоставляет инструменты для выполнения команд PowerShell, получения системной информации, управления модулями и т. д.

Требования

  • Node.js 18+

  • PowerShell 5.1 или PowerShell Core 7+

Related MCP server: Command Executor MCP Server

Установка

  1. Установить зависимости:

    npm install
  2. Создайте проект:

    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 предоставляет следующие инструменты:

выполнить_пс

Выполните команду PowerShell и получите результат.

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

Пример использования:

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

получить_системную_информацию

Получите подробную информацию о системе, включая сведения об ОС, процессоре, памяти и версии PowerShell.

Parameters: None

Пример использования:

get_system_info()

список_модулей

Выведите список всех установленных модулей PowerShell с указанием таких сведений, как имя, версия и тип.

Parameters: None

Пример использования:

list_modules()

получить_команду_помощь

Получите подробную справку по конкретной команде PowerShell, включая синтаксис, параметры и примеры.

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

Пример использования:

get_command_help(command: "Get-Process")

find_commands

Поиск команд PowerShell по имени или шаблону.

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

Пример использования:

find_commands(search: "Process")

запустить_скрипт

Запустите файл скрипта 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 для разрешения локальных скриптов.

  2. Ошибки «Путь не найден»

    • Убедитесь, что пути к файлам являются абсолютными или правильно указаны относительно рабочего каталога.

    • Используйте соответствующие разделители пути для вашей ОС.

  3. Ошибки «Команда не найдена»

    • Некоторые команды могут потребовать установки определенных модулей.

    • Используйте Install-Module ModuleName для установки необходимых модулей.

Лицензия

Массачусетский технологический институт

Install Server
F
license - not found
C
quality
D
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

  • A
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that provides programmatic access to the Windows terminal, enabling AI models to interact with the Windows command line through standardized tools for writing commands, reading output, and sending control signals.
    3
    19
    MIT
  • A
    license
    A
    quality
    F
    maintenance
    A secure Model Context Protocol server that allows AI models to safely interact with Windows command-line functionality, enabling controlled execution of system commands, project creation, and system information retrieval.
    8
    10
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A comprehensive Model Context Protocol server that enables AI assistants to interact with and manage Windows systems, providing capabilities for file system operations, process management, system information retrieval, registry operations, service management, network diagnostics, and performance monitoring.
    7
    26
    5
    Apache 2.0

View all related MCP servers

Related MCP Connectors

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

  • A Model Context Protocol server for Wix AI tools

  • Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.

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/posidron/mcp-powershell'

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