PowerShell MCP Server
A comprehensive Model Context Protocol (MCP) server that enables Claude and other LLM applications to execute PowerShell commands, scripts, and perform system operations on Windows systems.
README
PowerShell MCP Server
A comprehensive Model Context Protocol (MCP) server that enables Claude and other LLM applications to execute PowerShell commands, scripts, and perform system operations on Windows systems.
š Key Features
- š§ PowerShell Execution: Execute commands, run scripts, and create new PowerShell files
- š„ļø System Monitoring: Get system info, monitor processes, check services and disk space
- š File Operations: List directories, get file info, and search files with pattern matching
- āļø Simple Setup: One-command installation with automatic Claude Desktop configuration
- š”ļø Secure: Safe execution with proper error handling and session management
š ļø Available Tools
PowerShell Tools
execute-powershell- Execute PowerShell commands with optional working directoryexecute-powershell-script- Run PowerShell script files with parameterscreate-powershell-script- Create new PowerShell scripts
System Tools
get-system-info- Comprehensive Windows system informationget-process-list- Running processes with CPU/memory usage (sortable/filterable)get-service-status- Windows services status with filteringcheck-disk-space- Disk space usage for all or specific drives
File Tools
list-directory- Enhanced directory listing with filteringget-file-info- Detailed file and directory metadatasearch-files- Recursive file search with pattern matching
š Prerequisites
- Windows 10/11 or Windows Server 2016+
- Node.js 18.0.0 or higher
- PowerShell 5.1+ or PowerShell Core 7+
- Claude Desktop application
š Quick Setup
Option 1: Safe Automated Setup (Recommended)
# Clone and setup with configuration management
git clone https://github.com/gunjanjp/powershell-mcp.git
cd powershell-mcp
complete-setup.bat
Option 2: Configuration Recovery (If you had existing settings)
# If previous setup overwrote your existing configuration
node recovery.js status # Check current state
node recovery.js scan # Find backup configurations
node recovery.js restore 1 # Restore from backup
# OR
node recovery.js merge 1 # Merge backup with current config
Option 3: Manual Setup
# Clone the repository
git clone https://github.com/gunjanjp/powershell-mcp.git
cd powershell-mcp
# Install dependencies
npm install
# Safely add to existing configuration
node recovery.js add-powershell
# Restart Claude Desktop
š Usage Examples
Ask Claude:
- "Execute PowerShell: Get-Date"
- "Check my system information"
- "Show me the top 10 processes by CPU usage"
- "What's my disk space usage?"
- "List files in my Downloads folder"
- "Search for all .txt files in C:\Users"
- "Create a PowerShell script to backup my Documents folder"
š§ Commands
Server Commands
# Start the server
npm start
# Test components
npm test
# Run diagnostics
node diagnose.bat
# Start server directly
node src/server.js
Configuration Management
# Check configuration status
node recovery.js status
# Find backup configurations
node recovery.js scan
# Safely add PowerShell server
node recovery.js add-powershell
# Restore from backup
node recovery.js restore <number>
# Merge configurations
node recovery.js merge <number>
# Show backup contents
node recovery.js show <number>
Quick Setup Commands
# Complete setup with safety checks
complete-setup.bat
# Test server only
run-test.bat
š Project Structure
powershell-mcp/
āāā src/
ā āāā server.js # Main MCP server (with stderr logging fix)
ā āāā tools/ # Tool implementations
ā ā āāā powershell-tools.js
ā ā āāā system-tools.js
ā ā āāā file-tools.js
ā āāā utils/ # Utility modules
ā āāā system-utils.js
āāā examples/ # Example PowerShell scripts
āāā scripts/ # Setup utilities
āāā test/ # Test files
āāā claude_desktop_config.json # Claude Desktop configuration
āāā setup.bat # Automated setup script
āāā diagnose.bat # Diagnostic tool
āāā test-server.js # Component testing
āāā README.md
āļø Claude Desktop Configuration
The server uses this configuration (automatically applied by setup):
{
"mcpServers": {
"powershell": {
"command": "node",
"args": ["D:/claude/claude-powershell-mcp/src/server.js"],
"env": {}
}
}
}
Config location: %APPDATA%\Claude\claude_desktop_config.json
š”ļø Security Features
- Safe Execution: Uses
-ExecutionPolicy Bypassand-NoProfilefor security - Input Validation: All inputs validated with Zod schemas
- Session Management: PowerShell sessions properly disposed after use
- Error Handling: Comprehensive error handling prevents system issues
- Logging: All operations logged to stderr (not interfering with JSON-RPC)
š Troubleshooting
Server won't start
# Check Node.js version (need 18+)
node --version
# Check dependencies
npm install
# Test components
node test-server.js
Claude Desktop integration issues
# Run setup again
setup.bat
# Check configuration
type "%APPDATA%\Claude\claude_desktop_config.json"
# Restart Claude Desktop completely
PowerShell execution issues
# Test PowerShell
powershell -Command "Get-Date"
# Check execution policy
Get-ExecutionPolicy
# Run diagnostics
node diagnose.bat
š Recent Updates (v1.1.2)
Configuration Management Improvements
- ā Safe Configuration Management - No more overwriting existing configs
- ā Automatic Backups - Creates backups before any configuration changes
- ā Configuration Recovery - Tools to find and restore previous configurations
- ā Merge Capability - Intelligent merging of multiple MCP server configs
- ā Interactive Recovery - Step-by-step configuration recovery process
Previous Fixes (v1.1.1)
- ā Fixed Claude Desktop JSON parsing error - Changed console.log to console.error (stderr)
- ā Cleaned up project structure - Removed redundant server files
- ā Simplified setup - One script setup process
- ā Proper error handling - Enhanced logging and error management
š¤ Contributing
- Fork the repository
- Create feature branch:
git checkout -b feature-name - Make changes and test:
npm test - Commit:
git commit -am 'Add feature' - Push:
git push origin feature-name - Submit pull request
š License
MIT License - see LICENSE file for details.
š Links
Made with ā¤ļø for the Claude and PowerShell communities
ā ļø Important: This tool provides direct access to PowerShell commands. Use responsibly and be aware of security implications.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.