PowerShell MCP 服务器
用于与 PowerShell 交互的模型上下文协议服务器。此服务器提供用于执行 PowerShell 命令、检索系统信息、管理模块等的工具。
要求
Node.js 18+
PowerShell 5.1 或 PowerShell Core 7+
Related MCP server: MCP Personal Assistant Agent
安装
安装依赖项:
npm install构建项目:
npm run build
配置
对于克劳德桌面
编辑配置: $HOME/Library/Application\ Support/Claude/claude_desktop_config.json
添加到 mcpServers:
对于 VS Code
编辑配置: $HOME/Library/Application\ Support/Code/User/settings.json
添加到设置:
对于 Cursor IDE
编辑配置: $HOME/.cursor/mcp.json
添加到 mcpServers:
可用工具
此 PowerShell MCP 服务器提供以下工具:
执行_ps
执行 PowerShell 命令并获取结果。
使用示例:
获取系统信息
检索详细的系统信息,包括操作系统详细信息、处理器、内存和 PowerShell 版本。
使用示例:
列表模块
列出所有已安装的 PowerShell 模块,包括名称、版本和类型等详细信息。
使用示例:
获取命令帮助
获取特定 PowerShell 命令的详细帮助,包括语法、参数和示例。
使用示例:
查找命令
按名称或模式搜索 PowerShell 命令。
使用示例:
运行脚本
运行带有可选参数的 PowerShell 脚本文件。
使用示例:
发展
要在开发模式下运行:
扩展服务器
要添加您自己的 PowerShell 工具:
编辑
src/index.ts在
registerTools()方法中添加新工具遵循现有的模式以实现一致的错误处理
使用
npm run build进行构建
添加工具示例
安全注意事项
该服务器直接在您的系统上执行 PowerShell 命令
命令以与运行 MCP 服务器的进程相同的权限执行
暴露破坏性操作时要小心
考虑对敏感命令实施额外验证
故障排除
常见问题
PowerShell 执行策略限制
您可能需要调整 PowerShell 执行策略以允许脚本执行
使用
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser允许本地脚本
未找到路径错误
确保文件路径是绝对路径或相对于工作目录正确路径
为您的操作系统使用适当的路径分隔符
未找到命令错误
某些命令可能需要安装特定模块
使用
Install-Module ModuleName安装所需的模块
执照
麻省理工学院
Appeared in Searches
- Excel and Visual Basic permissions for reading, writing, updating, and deleting data in spreadsheets
- MCP servers for retrieving system information
- MCP servers for monitoring application power and memory usage on Windows and macOS
- MCP server for real-time console interaction and log monitoring in Cursor IDE
- Assistance with PowerShell Commands or Scripts