PowerShell MCP Server

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.

Category
访问服务器

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 directory
  • execute-powershell-script - Run PowerShell script files with parameters
  • create-powershell-script - Create new PowerShell scripts

System Tools

  • get-system-info - Comprehensive Windows system information
  • get-process-list - Running processes with CPU/memory usage (sortable/filterable)
  • get-service-status - Windows services status with filtering
  • check-disk-space - Disk space usage for all or specific drives

File Tools

  • list-directory - Enhanced directory listing with filtering
  • get-file-info - Detailed file and directory metadata
  • search-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 Bypass and -NoProfile for 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

  1. Fork the repository
  2. Create feature branch: git checkout -b feature-name
  3. Make changes and test: npm test
  4. Commit: git commit -am 'Add feature'
  5. Push: git push origin feature-name
  6. 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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选