PoshMCP

by cezarypiatek

Not rated
GitHub

About

Expose explicitly whitelisted PowerShell commandlets as a MCP Tool

Details

Author
cezarypiatek
Categories
Other, Developer Tools

Setup

Install PoshMCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/cezarypiatek/PoshMCP

Follow the installation instructions in the repository README, then restart your MCP client.

A Model Context Protocol (MCP) server that exposes PowerShell cmdlets as tools for AI assistants like Claude or Github Copilot. Built with security in mind through explicit whitelisting of allowed cmdlets.

This MCP server dynamically loads PowerShell cmdlets from modules and scripts, automatically generating tool schemas from cmdlet documentation. Unlike traditional PowerShell remoting, this server uses awhitelist approach- only explicitly configured cmdlets are exposed, making it safer for AI interactions.

- Declarative Configuration: Define available tools in a simple JSON config file
- Automatic Schema Generation: Uses PowerShell reflection to generate MCP tool schemas from cmdlet help documentation
- Security by Whitelisting: Only explicitly listed cmdlets are exposed as tools
- Dynamic Loading: Supports both PowerShell modules (.psm1) and script files (.ps1)
- Type Conversion: Automatically handles parameter type conversions (DateTime, switch parameters, etc.)
- Configuration Loading: Readsmcp-config.jsonto determine which cmdlets to expose
- Module/Script Import: Loads specified PowerShell modules and dot-sources script files
- Schema Generation: UsesGet-CommandandGet-Helpto introspect each cmdlet:

- Extracts cmdlet synopsis as tool description
- Maps PowerShell parameter types to JSON schema types
- Identifies mandatory parameters from[Parameter(Mandatory)]attributes
- Generates camelCase parameter names for JSON (e.g.,StartDatestartDate)

Install-Module -Name PoshMCP -Scope CurrentUser

- Clone or download this repository to your local machine
- Ensure PowerShell 7+ is installed (pwsh)

Add the following to your VS Code MCP configuration file (typically%APPDATA%\Code\User\mcp.jsonon Windows):

{ "servers": { "posh-mcp": { "type": "stdio", "command": "pwsh", "args": [ "-NoProfile", "-NoLogo", "-Command", "Import-Module PoshMCP;", "Start-PoshMcp -ConfigPath C:\\path\\to\\your\\mcp-config.json" ] } } }

Editmcp-config.jsonto define which cmdlets to expose:

{ "serverInfo": { "name": "posh-mcp", "version": "1.0.0" }, "modules": [ { "name": "ModuleName", "path": "./MyModule.psm1", "cmdlets": [ "Get-MyData", "Set-MyConfig" ] } ], "scripts": [ { "path": "./my-tools.ps1", "cmdlets": [ "Get-CustomInfo", "Invoke-CustomTask" ] } ] }

-

serverInfo: Metadata about the MCP server

- name: Server name displayed to MCP clients
- version: Server version

- name: Module name (informational)
- path: Relative or absolute path to the.psm1file
- cmdlets: Array of cmdlet names to expose as tools

scripts: PowerShell script files to dot-source

- path: Relative or absolute path to the.ps1file
- cmdlets: Array of function names to expose as tools

Create a script file (e.g.,my-tools.ps1):

function Get-SystemUptime { <# .SYNOPSIS Returns the system uptime information. .DESCRIPTION Gets how long the system has been running since last boot. .EXAMPLE Get-SystemUptime Returns uptime information. .OUTPUTS Hashtable with uptime details. #> [CmdletBinding()] param() $os = Get-CimInstance Win32_OperatingSystem $uptime = (Get-Date) - $os.LastBootUpTime return @{ LastBootTime = $os.LastBootUpTime.ToString("o") UptimeDays = $uptime.Days UptimeHours = $uptime.Hours UptimeMinutes = $uptime.Minutes } }
{ "scripts": [ { "path": "./my-tools.ps1", "cmdlets": [ "Get-SystemUptime" ] } ] }

The tool will automatically be exposed asgetSystemUptime(camelCase) with schema generated from the comment-based help.

For best results, include complete comment-based help in your cmdlets:

function Get-MyData { <# .SYNOPSIS Brief one-line description (becomes tool description) .PARAMETER Name Detailed parameter description (appears in tool schema) .PARAMETER StartDate Start date for filtering results .EXAMPLE Get-MyData -Name "Test" -StartDate "2025-01-01" #> [CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$Name, [Parameter(Mandatory = $false)] [DateTime]$StartDate = (Get-Date).AddDays(-7) ) # Your implementation }

- Whitelist-Only: Only cmdlets explicitly listed inmcp-config.jsonare accessible
- No Dynamic Execution: The server doesn't execute arbitrary PowerShell commands
- Parameter Validation: All parameters go through PowerShell's native validation
- Isolated Scope: Each cmdlet runs in a controlled context

Chia Health MCP Server — Patient workflow integration for a licensed US telehealth platform. Browse GLP-1 medications (semaglutide, tirzepatide), peptide therapies (sermorelin, NAD+, glutathione), and longevity treatments. Check eligibility, complete intake, sign consents, and manage treatment plans. 30 tools, HIPAA-compliant. All prescriptions evaluated by licensed US healthcare providers and delivered from FDA-regulated pharmacies across 50 states + DC.

Broker + MCP server for last-bidder-wins games on Solana — agents register, auto-fund a Privy wallet, and bid via streamable HTTP

AI-powered no-code app builder with 17 MCP tools — create projects, generate pages from natural language, AI text/image generation (GPT, Claude, Gemini, 14+ models), page CRUD, workflow execution, publish & version control. SSE transport, API key auth.

An mcp server for your food ordering needs.

Agent-to-Agent handoff certification for multi-agent systems — validates context preservation, verifies agent capabilities before handoff, logs transfer chains, and ensures no data loss in agent orchestration.

Unified MCP & skill management gateway with progressive disclosure. Manages multiple MCP servers as Agent Apps, loading tool schemas on demand for 99% context token savings. Shared across Claude Code, Codex, OpenCode and more.

A collection of Model Context Protocol (MCP) servers for various tasks and integrations, supporting both Python and Node.js environments.

Open-souSecurely feeds real security refreshed rules into Cursor, Claude Code, and Windsurf — zero config, no API key.

Health intelligence MCP — access biomarkers, biological age, and personalized longevity action plans from your Aniva profile.

Real-time stock heatmaps and investment tools delivered as interactive React components.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.