PowerShell MCP Server
PowerShell MCP 服务器
用于与 PowerShell 交互的模型上下文协议服务器。此服务器提供用于执行 PowerShell 命令、检索系统信息、管理模块等的工具。
要求
Node.js 18+
PowerShell 5.1 或 PowerShell Core 7+
Related MCP server: Command Executor MCP Server
安装
安装依赖项:
npm install构建项目:
npm run build
配置
对于克劳德桌面
编辑配置: $HOME/Library/Application\ Support/Claude/claude_desktop_config.json
添加到 mcpServers:
{
"mcpServers": {
"mcp-powershell": {
"command": "node",
"args": [
"/absolute/path/to/mcp-powershell/dist/index.js"
]
}
}
}对于 VS Code
编辑配置: $HOME/Library/Application\ Support/Code/User/settings.json
添加到设置:
"mcp": {
"servers": {
"mcp-powershell": {
"command": "node",
"args": [
"/absolute/path/to/mcp-powershell/dist/index.js"
]
}
}
}对于 Cursor IDE
编辑配置: $HOME/.cursor/mcp.json
添加到 mcpServers:
{
"mcpServers": {
"mcp-powershell": {
"command": "node",
"args": [
"/absolute/path/to/mcp-powershell/dist/index.js"
]
}
}
}可用工具
此 PowerShell MCP 服务器提供以下工具:
执行_ps
执行 PowerShell 命令并获取结果。
Parameters:
- command (string): PowerShell command to execute使用示例:
execute_ps(command: "Get-Process | Select-Object -First 5")获取系统信息
检索详细的系统信息,包括操作系统详细信息、处理器、内存和 PowerShell 版本。
Parameters: None使用示例:
get_system_info()列表模块
列出所有已安装的 PowerShell 模块,包括名称、版本和类型等详细信息。
Parameters: None使用示例:
list_modules()获取命令帮助
获取特定 PowerShell 命令的详细帮助,包括语法、参数和示例。
Parameters:
- command (string): PowerShell command to get help for使用示例:
get_command_help(command: "Get-Process")查找命令
按名称或模式搜索 PowerShell 命令。
Parameters:
- search (string): Search term for PowerShell commands使用示例:
find_commands(search: "Process")运行脚本
运行带有可选参数的 PowerShell 脚本文件。
Parameters:
- scriptPath (string): Path to the PowerShell script file
- parameters (string, optional): Optional parameters to pass to the script使用示例:
run_script(scriptPath: "/path/to/script.ps1", parameters: "-Name 'Test' -Value 123")发展
要在开发模式下运行:
npm run dev扩展服务器
要添加您自己的 PowerShell 工具:
编辑
src/index.ts在
registerTools()方法中添加新工具遵循现有的模式以实现一致的错误处理
使用
npm run build进行构建
添加工具示例
// In the registerTools() method:
this.server.tool(
"my_ps_tool",
{
param1: z.string().describe("Description of parameter 1"),
param2: z.number().optional().describe("Optional numeric parameter"),
},
async ({ param1, param2 }) => {
try {
// Your PowerShell command
const command = `Your-PowerShell-Command -Param1 "${param1}" ${param2 ? `-Param2 ${param2}` : ''}`;
const { stdout, stderr } = await execAsync(`powershell -Command "${command.replace(/"/g, '\\"')}"`);
if (stderr) {
return {
isError: true,
content: [
{
type: "text" as const,
text: `Error in my_ps_tool: ${stderr}`,
},
],
};
}
return {
content: [
{
type: "text" as const,
text: stdout,
},
],
};
} catch (error) {
return {
isError: true,
content: [
{
type: "text" as const,
text: `Error in my_ps_tool: ${(error as Error).message}`,
},
],
};
}
}
);安全注意事项
该服务器直接在您的系统上执行 PowerShell 命令
命令以与运行 MCP 服务器的进程相同的权限执行
暴露破坏性操作时要小心
考虑对敏感命令实施额外验证
故障排除
常见问题
PowerShell 执行策略限制
您可能需要调整 PowerShell 执行策略以允许脚本执行
使用
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser允许本地脚本
未找到路径错误
确保文件路径是绝对路径或相对于工作目录正确路径
为您的操作系统使用适当的路径分隔符
未找到命令错误
某些命令可能需要安装特定模块
使用
Install-Module ModuleName安装所需的模块
执照
麻省理工学院
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that provides programmatic access to the Windows terminal, enabling AI models to interact with the Windows command line through standardized tools for writing commands, reading output, and sending control signals.319MIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that allows secure execution of pre-approved commands, enabling AI assistants to safely interact with the user's system.11122ISC
- AlicenseAqualityFmaintenanceA secure Model Context Protocol server that allows AI models to safely interact with Windows command-line functionality, enabling controlled execution of system commands, project creation, and system information retrieval.810MIT
- AlicenseAqualityDmaintenanceA comprehensive Model Context Protocol server that enables AI assistants to interact with and manage Windows systems, providing capabilities for file system operations, process management, system information retrieval, registry operations, service management, network diagnostics, and performance monitoring.7265Apache 2.0
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
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
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/posidron/mcp-powershell'
If you have feedback or need assistance with the MCP directory API, please join our Discord server