PowerShell MCP Server

by posidron

Integrations

  • Offers a Node.js-based server for executing PowerShell commands, with support for system information retrieval, module management, and script execution through Node.js runtime.

  • Enables interaction with PowerShell, providing tools for executing commands, retrieving system information, managing modules, getting command help, finding commands, and running scripts.

PowerShell MCP サーバー

PowerShell と連携するためのモデルコンテキストプロトコルサーバー。このサーバーは、PowerShell コマンドの実行、システム情報の取得、モジュールの管理などを行うツールを提供します。

要件

  • Node.js 18歳以上
  • PowerShell 5.1 または PowerShell Core 7+

インストール

  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 サーバーは、次のツールを提供します。

実行ps

PowerShell コマンドを実行して結果を取得します。

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

使用例:

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

システム情報を取得する

OS の詳細、プロセッサ、メモリ、PowerShell のバージョンなど、詳細なシステム情報を取得します。

Parameters: None

使用例:

get_system_info()

リストモジュール

インストールされているすべての PowerShell モジュールを、名前、バージョン、タイプなどの詳細とともに一覧表示します。

Parameters: None

使用例:

list_modules()

get_command_help

構文、パラメーター、例など、特定の PowerShell コマンドの詳細なヘルプを取得します。

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

使用例:

get_command_help(command: "Get-Process")

コマンドを見つける

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. パスが見つからないエラー
    • ファイルパスが絶対パスか、作業ディレクトリに対して適切な相対パスであることを確認する
    • OSに応じて適切なパス区切り文字を使用してください
  3. コマンドが見つからないエラー
    • 一部のコマンドでは特定のモジュールのインストールが必要になる場合があります
    • 必要なモジュールをインストールするには、 Install-Module ModuleNameを使用します。

ライセンス

マサチューセッツ工科大学

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

AI アシスタントが PowerShell コマンドを実行し、システム情報を取得し、モジュールを管理し、Windows システムでスクリプトを実行できるようにするモデル コンテキスト プロトコル サーバー。

  1. 要件
    1. インストール
      1. 構成
        1. クロードデスクトップ向け
        2. VSコードの場合
        3. カーソルIDEの場合
      2. 利用可能なツール
        1. 実行ps
        2. システム情報を取得する
        3. リストモジュール
        4. get_command_help
        5. コマンドを見つける
        6. スクリプトの実行
      3. 発達
        1. サーバーの拡張
          1. ツールの追加例
        2. セキュリティに関する考慮事項
          1. トラブルシューティング
            1. よくある問題
          2. ライセンス

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              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.
              Last updated -
              3
              JavaScript
              MIT License
            • A
              security
              F
              license
              A
              quality
              A Model Context Protocol server that allows secure execution of pre-approved commands, enabling AI assistants to safely interact with the user's system.
              Last updated -
              1
              3
              18
              JavaScript
            • -
              security
              F
              license
              -
              quality
              A Model Context Protocol server that enables AI assistants like Claude to perform Python development tasks through file operations, code analysis, project management, and safe code execution.
              Last updated -
              1
              Python
              • Linux
              • Apple
            • -
              security
              F
              license
              -
              quality
              A comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.
              Last updated -
              16
              TypeScript

            View all related MCP servers

            ID: fjhi52pfdt