Lightweight PowerShell MCP framework

by warm-snow-13

Not rated
GitHub

About

Lightweight PowerShell MCP framework. Expose custom PowerShell functions through a pure-PowerShell MCP server to integrate with MCP-compliant AI agents.

Details

Author
warm-snow-13
Categories
Other, Developer Tools, Infrastructure

Setup

Install Lightweight PowerShell MCP framework in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/warm-snow-13/pwsh-mcp

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

Lightweight PowerShell MCP framework. Expose custom PowerShell functions through a pure-PowerShell MCP server to integrate with MCP-compliant AI agents.

PowerShell module for implementing an MCP server

PWSH MCP — Build and expose PowerShell automation as MCP tools on demand.

- Description
-
Features
-
Architecture Overview
-
Use Cases
-
Requirements
-
Compatibility
-
Getting Started
-
Documentation
-
License
-
References

The PowerShell MCP module lets you build Model Context Protocol (MCP) servers directly from PowerShell functions.

Instead of writing a server from scratch, you define functionality as PowerShell functions and expose it to MCP clients through JSON-RPC 2.0 over stdio transport.

This approach is useful for development, infrastructure management, and CI/CD automation scenarios where PowerShell scripts already exist and need to be exposed as structured tools for AI assistants.

PowerShell is well-suited for implementing MCP servers for automation processes because it combines a rich automation ecosystem with native cross-platform capabilities.

- Large module ecosystem– You can reuse existing PowerShellmodules(Azure, AWS, VMware, Active Directory, Exchange, and many others) to quickly extend MCP server capabilities without rewriting existing automation.
- Cross-platform integration– PowerShell runs natively on Windows, Linux, and macOS, making it easy to deploy the same MCP server in different environments.
- Reuse of existing scripts– Many automation workflows already exist as PowerShell scripts or functions; the module allows you to expose them as MCP tools with minimal changes.
- Easy testability– PowerShell functions can be tested independently with Pester before wiring them into MCP, simplifying debugging and iterative development.
- Strong parameter validation– Built-in parameter attributes provide declarative input validation, reducing boilerplate and runtime errors from invalid inputs and improving tool reliability.
- Metadata-driven documentation– Comment-Based Help and parameter attributes let you keep function documentation and MCP schemas in sync. The same metadata is used both for human-readable help and for automatic JSON Schema generation.

- Pure PowerShell implementation– no external runtime dependencies, leverages native PowerShell capabilities.
- Stdio-based MCP server– stdio transport implementation for integration with MCP clients such as GitHub Copilot and Gemini CLI.
- Cross-platform support– consistent behavior across platforms (Windows, Linux, macOS) with the same codebase.
- Automatic schema generation– converts PowerShell function parameters, validation attributes, and Comment-Based Help into JSON Schema definitions for MCP tools.
- Parameter validation– leverages PowerShell's declarative validation attributes for type-safe MCP tool inputs.

The module implements the MCP lifecycle on top of stdio and JSON-RPC 2.0:

- stdio transport– Communication happens exclusively through stdin/stdout; no HTTP endpoints are required.
- JSON-RPC 2.0– Requests and responses follow the JSON-RPC 2.0 specification with strict validation and predictable error codes.
- Tool discovery(tools/list) – Discovers and exports selected PowerShell functions as MCP tools, including their schema and metadata.
- Tool execution(tools/call) – Incoming MCP tool calls are mapped to PowerShell function invocations, with automatic parameter binding and validation.
- Initialization and shutdown– Supports the core MCP methods.

- Sanitization of incoming requests to prevent unintended command execution triggered by AI-generated inputs.
- Function parameter validation ensures that inputs match the expected types, ranges, and patterns.
- Leverages native PowerShell security features such as script signing and execution policies.
- The MCP server can be run inside a Docker container for additional isolation when exposing automation capabilities.

Typical scenarios include automating repetitive tasks, exposing existing scripts as tools for AI assistants, and integrating with local tools or cloud services:

- Converting existing admin or maintenance scripts into reusable MCP tools.
- Prototyping developer utilities specific to a team or project.
- Building ad-hoc tools during a development session and immediately exposing them to AI coding assistants.

- Orchestrating deployment pipelines through MCP tools backed by existing PowerShell scripts.
- Exposing infrastructure-as-code workflows (Terraform, Ansible) via PowerShell wrappers.
- Managing build artifacts, release gates, and deployment validation steps as MCP tools.

- Managing cloud resources (Azure PowerShell, AWS Tools for PowerShell, Google Cloud modules).
- Automating on-premises environments: Active Directory, Exchange, VMware, network devices, and more.
- Implementing monitoring and alerting workflows using existing PowerShell-based monitoring modules.

- Integrating with external systems via REST or SDK-based PowerShell modules.
- Implementing compliance checks and audit pipelines using security-focused PowerShell modules.
- Generating reports and analytics by combining data-processing cmdlets with MCP tooling.

- PowerShell7.5 or later (cross-platform)
- MCP client that supports stdio transport (Visual Studio Code with GitHub Copilot, Gemini CLI, Copilot CLI).

Any MCP-compliant client that implements the MCP stdio transport and the core MCP methods should be able to connect to a PowerShell MCP server with appropriate configuration.

The repository currently includes documentation and examples for the following MCP clients:

- GitHub Copilot– AI coding assistant.
-
GitHub Copilot CLI– command-line interface for GitHub Copilot.
-
Gemini CLI– command-line AI assistant with MCP support.
-
Claude Desktop– AI assistant.

The project includes ready-to-usesamplesand configuration templates for a quick start. For detailed usage and advanced configuration, refer to theuser guideanddeveloper guide.
- Ensure prerequisites are installed (see
Requirements).
- Create a PowerShell-based MCP server.
- Add an MCP server configuration entry to your MCP client.
- Call the MCP tools from the MCP client.

This example shows how to expose a simple PowerShell function as an MCP tool.

Create a PowerShell scriptthat defines one or more functions and imports the PowerShell MCP module.

# Import the MCP server module Import-Module pwsh.mcp -Force -ErrorAction Stop # Define a simple echo function function get_echo { [CmdletBinding()] param ( [Parameter(Mandatory = $false, HelpMessage = "Text to echo")] [string] $text = "Lorem Ipsum" ) return "Echo, $text!" } # Start the MCP server and pass the functions to expose. New-MCPServer -FunctionInfo (Get-Item Function:get_echo)

Add an MCP server configuration (Visual Studio Code):

Add a new entry to yourmcp.jsonfile as described in the official Visual Studio Code documentation.

Example.vscode/mcp.jsonconfiguration for the above script:

{ "servers": { "mcp-pwsh-server": { "type": "stdio", "command": "pwsh", "args": [ "-NoProfile", "-NoLogo", "-File", "${workspaceFolder}/path/to/your/script.ps1" ] } } }

The file path can be absolute or relative to the workspace folder.

Refer to theuser guidefor additional examples and advanced configuration.

To configure an MCP client, see the official documentation for the related client:

- Use MCP Servers in VS Code
-
MCP Servers with the Gemini CLI

Call the MCP toolfrom your MCP client (e.g., GitHub Copilot in Visual Studio Code):

- User Guide– detailed usage documentation, including advanced configuration, schema generation, and best practices.
-
Developer Guide– contribution guidance, including coding standards, testing, and CI/CD processes.

- Model Context Protocol Specification
-
PowerShell
-
PowerShell Documentation
-
PowerShell Cmdlet Development Guidelines
-
Visual Studio Code
-
GitHub Copilot CLI
-
Gemini CLI

This project is licensed under theMIT License.

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

Spawn production-ready MCP servers from a single YAML file

All Azure MCP tools in a single server. The Azure MCP Server implements the MCP specification to create a seamless connection between AI agents and Azure services. Azure MCP Server can be used alone or with the GitHub Copilot for Azure extension in VS Code.

Flag features, manage company data, and control feature access using Bucket.

Enable AI Agents to fix build failures from CircleCI.

interacts with ConfigCat feature flag platform. Supports managing feature flags, configs, environments, products and organizations. Helps to integrate ConfigCat SDK, implement feature flags or remove zombie (stale) flags.

Boost security in your dev lifecycle via SAST, SCA, Secrets & IaC scanning with Cycode.

Turn your favourite AI tool into a feature management assistant. DevCycle's MCP works with your favourite coding assistant so you can create and monitor feature flags using natural language right in your workflow.

Official Docker MCP Toolkit for discovering, configuring, and running containerized MCP servers through Docker Desktop and the Docker MCP gateway.

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.